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.
g_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION);
if (g_pDirect3D == NULL)
MessageBox(hMainWnd, L"Error creating Direct3D object!", L"Error", MB_ICONERROR);
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);
from the WndProc function and insert them in WinMain, just above the instruction
then insert this at the first line of the source file:
#pragma comment(lib, "d3d9.lib")
Alright, thanks guys! Also, is #pragma comment allowed for me to add new libraries that way?