What is wrong with my code?

This is a discussion on What is wrong with my code? within the Game Programming forums, part of the General Programming Boards category; -Visual Studio 2003 -Win32 Console Project -C++ Source File -HAPI is the API -DirectX 9.0 SDK Create function to clear ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    13

    What is wrong with my code?

    -Visual Studio 2003
    -Win32 Console Project
    -C++ Source File
    -HAPI is the API
    -DirectX 9.0 SDK

    Create function to clear screen, create function to clear pixel on screen to arbitrary colour (star-filled background)

    Code:
    #include <HAPI_lib.h>
    #include <stdlib.h>
    
    typedef unsigned long int DWORD;
    
    void clearScreen ( BYTE, BYTE, BYTE, int, int );
    void setPixel ( BYTE *, int, int, int, BYTE, BYTE, BYTE );
    
    void main()
    {
         int screenWidth=400;
         int screenHeight=300;
    
         if (!HAPI_Initialise(&screenWidth,&screenHeight))
             return;
    
       while(HAPI_Update())
         { 
    		int NumberOfStars;
    		int rand();
    	
    		BYTE red = 255;
    		BYTE green = 255;
    		BYTE blue = 0;
    		BYTE *screen;
    		
    		clearScreen ( red, green, blue, screenWidth, screenHeight );
    	 
    		for(int i = 0; i < NumberOfStars; i++)
    		{
    			int x = rand() % screenWidth;
    			int y = rand() % screenHeight;
    
    			setPixel( screen, x, y, screenWidth, red, green, blue );
    		}
    
    	 }
    
       return;
    }
    
    void clearScreen (BYTE r, BYTE g, BYTE b, int screenWidth, int screenHeight )
    {
    	BYTE *screen = HAPI_GetScreenPtr();
    	
    	DWORD colour = ( r << 24 | g << 16 | b << 8 );
    	DWORD *Ptr = ( DWORD * ) screen; 
    	
    	for ( int y = 0; y < screenWidth * screenHeight; y++ )
    	{
    		memcpy ( Ptr, &colour, 4 );
    		Ptr += 4;
    	}
    }
    
    void setPixel ( BYTE *destinationPtr, int x, int y, int screenWidth, BYTE r, BYTE g, BYTE b )
    {
    	int offset = ( x+y*screenWidth )*4;
    	destinationPtr += offset;
    }
    apparently, in the function body of clearScreen, the HAPI_GetScreenPtr(); comes up with the build error 'identifier not found, even with argument dependent look-up'

    im stumped, anyone got any ideas?

    if you need wana download the API and have a go click here and go to HAPI. remember you need DirectX installed.

    The project is under Milestone 1.

    <Mod edit - You'll get more help if you ask nicely. I've edited your thread title.>

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Did you add the dx and hapi libs to yor project so that they are linked?

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    1

    Unhappy yeh...

    i agree recheck then try again might work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what is wrong in this simple code
    By vikingcarioca in forum C Programming
    Replies: 4
    Last Post: 04-23-2009, 07:10 AM
  2. what is wrong with this code please
    By korbitz in forum Windows Programming
    Replies: 3
    Last Post: 03-05-2004, 09:11 AM
  3. I cant find what is wrong with this code
    By senegene in forum C Programming
    Replies: 1
    Last Post: 11-12-2002, 05:32 PM
  4. Anyone see what is wrong with this code?
    By Wise1 in forum C Programming
    Replies: 2
    Last Post: 02-13-2002, 01:01 PM
  5. very simple code, please check to see whats wrong
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-10-2001, 12:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21