Trouble with Windows/DirectX programming

This is a discussion on Trouble with Windows/DirectX programming within the Windows Programming forums, part of the Platform Specific Boards category; Everytime you create an object (g_pDirect3D, g_pDirect3D_Device) you have to check if it has been created or if an error ...

  1. #16
    Registered User
    Join Date
    May 2007
    Posts
    41
    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

    Code:
    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

    Code:
    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

    Code:
    g_pDirect3D_Device->Release();
    g_pDirect3D->Release();
    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:
    Code:
    #pragma comment(lib, "d3d9.lib")

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

Page 2 of 2 FirstFirst 12
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, 02:02 PM
  3. Is it so trouble?
    By Yumin in forum Tech Board
    Replies: 4
    Last Post: 01-30-2006, 03:10 PM
  4. trouble scanning in... and link listing
    By panfilero in forum C Programming
    Replies: 14
    Last Post: 11-21-2005, 11:58 AM
  5. C++ program trouble
    By senrab in forum C++ Programming
    Replies: 7
    Last Post: 04-29-2003, 11:55 PM

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