Thread: Trouble with Windows/DirectX programming

  1. #16
    Registered User
    Join Date
    May 2007
    Everytime you create an object (g_pDirect3D, g_pDirect3D_Device) you have to check if it has been created or if an error has occured.

    add this

    g_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION);
    if (g_pDirect3D == NULL)
        MessageBox(hMainWnd, L"Error creating Direct3D object!", L"Error", MB_ICONERROR);
        return -1;
    and this

    g_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd, 
    		D3DCREATE_SOFTWARE_VERTEXPROCESSING, &PresentParams, &g_pDirect3D_Device);
    if (g_pDirect3D_Device == NULL)
        MessageBox(hMainWnd, L"Error creating Direct3DDevice object!", L"Error", MB_ICONERROR);
        return -1;
    also leave

    from the WndProc function and insert them in WinMain, just above the instruction
    return 0;

    then insert this at the first line of the source file:
    #pragma comment(lib, "d3d9.lib")

  2. #17
    Registered User
    Join Date
    May 2008
    Alright, thanks guys! Also, is #pragma comment allowed for me to add new libraries that way?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble with assignment in C
    By mohanlon in forum C Programming
    Replies: 17
    Last Post: 06-23-2009, 10:44 AM
  2. Replies: 6
    Last Post: 01-03-2007, 03:02 PM
  3. Is it so trouble?
    By Yumin in forum Tech Board
    Replies: 4
    Last Post: 01-30-2006, 04:10 PM
  4. trouble scanning in... and link listing
    By panfilero in forum C Programming
    Replies: 14
    Last Post: 11-21-2005, 12:58 PM
  5. C++ program trouble
    By senrab in forum C++ Programming
    Replies: 7
    Last Post: 04-29-2003, 11:55 PM