26 errors! Why??

This is a discussion on 26 errors! Why?? within the Windows Programming forums, part of the Platform Specific Boards category; I have this code. You don't have to read it. Just copy - paste it on your compiler , compile ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    124

    26 errors! Why??

    I have this code. You don't have to read it. Just copy - paste it on your compiler , compile it and tell me if it works. I compile it and it has 26 errors! If it works, press Alt+F4 to exit. If you want to read it, let me know where is the problem please...

    Code:
    #include <windows.h>
    #include <ddraw.h>
    
    HWND hWndMain;
    IDirectDraw7		*pDD;
    IDirectDrawSurface7	*lpPrimary, *lpBackBuffer;
    
    // Initialise DirectDraw and go to full screen mode.
    void InitDirectDraw()
    {
    	// Create the DirectDraw object, through which we will create surfaces.
    	DirectDrawCreateEx(NULL, (void **)&pDD, IID_IDirectDraw7, NULL);
    
    	// Set the co-operative level to exclusive and full-screen.
    	pDD->SetCooperativeLevel(hWndMain, 
    		DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT);
    
    	// Set the display mode to 640x480, 16-bit colour, default refresh rate.
    	pDD->SetDisplayMode(640, 480, 16, 0, 0);
    
    	DDSURFACEDESC2	ddsd;
    
    	// Create the primary surface with two back buffers.
    	ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
    	ddsd.dwSize = sizeof(DDSURFACEDESC2);
    	ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
    	ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
    			DDSCAPS_FLIP |
    			DDSCAPS_COMPLEX;
    	ddsd.dwBackBufferCount = 2;
    	pDD->CreateSurface(&ddsd, &lpPrimary, NULL);
    	
    	// Get the back buffer pointer, to which we will do all drawing.
    	ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
    	lpPrimary->GetAttachedSurface(&ddsd.ddsCaps, &lpBackBuffer);
    }
    
    void ExitDirectDraw()
    {
    	// Release the primary surface. Note that the back buffer is automatically released 
    	//  (since it was created at the same time).
    	lpPrimary->Release();
    	lpPrimary = NULL;
    
    	// Release the DirectDraw object.
    	pDD->Release();
    	pDD = NULL;
    }
    
    // Handle all messages for the main window.
    LRESULT CALLBACK MainWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (uMsg)
    	{
    	case WM_CLOSE:
    		ExitDirectDraw();
    		DestroyWindow(hWnd);
    		return 0;
    
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		return 0;
    	}
    	return DefWindowProc(hWnd, uMsg, wParam, lParam);
    }
    
    // Register the window class for the main window.
    void RegisterWindowClass()
    {
    	WNDCLASSEX	wcx;
    
    	ZeroMemory(&wcx, sizeof(WNDCLASSEX));
    	wcx.cbSize = sizeof(WNDCLASSEX);
    	wcx.lpfnWndProc = MainWindowProc;
    	wcx.hInstance = GetModuleHandle(NULL);
    	// Windows-default icon. Replace with your own.
    	wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    	wcx.hCursor = NULL;
    	// Black background for the window.
    	wcx.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    	wcx.lpszMenuName = NULL;
    	wcx.lpszClassName = "SampleWindowClass";
    	RegisterClassEx(&wcx);
    }
    
    // Idle-time processing function.
    
    void OnIdle(void)
    {
    }
    
    // Program entry point.
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) 
    {
    	MSG	msg;
    
    	RegisterWindowClass();
    
    	// Create a window that fills the screen.
    	hWndMain = CreateWindowEx(WS_EX_APPWINDOW,
    		"SampleWindowClass", "DirectDraw Bare-Bones Sample", WS_POPUP,
    		0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
    		NULL, NULL, hInstance, NULL);
    	
    	ShowWindow(hWndMain, SW_SHOW);
    
    	InitDirectDraw();
    
    	// Message loop. Note that this has been modified to allow
    	//  us to execute even if no messages are being processed.
    	for ( ; ; )
    	{
    		if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
    		{
    			if (!GetMessage(&msg, NULL, 0, 0))
    				break;
    			
    			// If you want WM_CHAR messages, add
    			//  TranslateMessage(&msg);
    			DispatchMessage(&msg);
    		}
    		
    		// Idle-time processing
    		OnIdle();
    	}
    
    	return 0;
    }
    Thanks in advance...
    Loading.....
    ( Trying to be a good C Programmer )

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    What do the errors say? Whe I copied your code and pasted it my compiler smushed some variable types and names together giving me 22 errors. I just separated them and it compiled fine. If you are getting linking errors make sure you are linking to the appropriate libraries.

    dxguid.lib
    ddraw.lib

    Let me know your specific errors.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    124
    Because i cannot copy-past the errors:
    Attached Images Attached Images  
    Loading.....
    ( Trying to be a good C Programmer )

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Do you have the DirectX SDK?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    124
    Because i cannot copy-past the errors, i post this image:
    Attached Images Attached Images  
    Loading.....
    ( Trying to be a good C Programmer )

  6. #6
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Did you even look at my post?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  7. #7
    Registered User
    Join Date
    Jun 2003
    Posts
    124
    DirectX SDK --> what is this?
    Loading.....
    ( Trying to be a good C Programmer )

  8. #8
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    Posts
    355
    LMAO that response is classic.

    You need the SDK to make DX apps, get it from here:

    http://www.microsoft.com/downloads/d...DisplayLang=en
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

  9. #9
    Registered User
    Join Date
    Jun 2003
    Posts
    124
    It is 223 Mega Bytes! That's too much! I 'll have to wait some days untill i downloed it! Thanks a lot anyway. But do you have a better suggestion?

  10. #10
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Either you download the DirectX SDK, or you don't use DirectX.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  11. #11
    Registered User
    Join Date
    Dec 2002
    Posts
    15
    SDK which stands for 'Software developers kit' is what you need to link the header files to what functions you are trying to call from DirectX itself.

    It would be like that too, say for instance you want to use a lot of the functionality of Winamp (stick with me here) in your program/app. You would have to download there SDK to 'plug in' there features/functions.

    Hope that helps.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 11:50 AM
  2. Winsock compilation errors
    By jmd15 in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-03-2005, 09:00 AM
  3. Unknown Errors in simple program
    By neandrake in forum C++ Programming
    Replies: 16
    Last Post: 04-06-2004, 03:57 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  5. Help me with these errors... :-(
    By major_small in forum C++ Programming
    Replies: 6
    Last Post: 09-07-2003, 09:18 PM

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