Code:
#include <windows.h>
#include <d3d9.h>
/// Update 1
LPDIRECT3D9 g_pDirect3D = NULL;
LPDIRECT3DDEVICE9 g_pDirect3D_Device = NULL;
// Update 2, changed WinProc to WndProc, silly typo xD
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lParam);
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShow)
{
MSG msg;
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_VREDRAW|CS_HREDRAW|CS_OWNDC,WndProc,
0,0,hInstance, NULL, NULL, (HBRUSH)(COLOR_WINDOW+1),NULL, "DX9_TUTORIAL1_CLASS", NULL };
RegisterClassEx(&wc);
HWND hMainWnd = CreateWindow(
"DX9_TUTORIAL1_CLASS",
"DirectX9 test",
WS_OVERLAPPEDWINDOW,
100,100,
300,300,
NULL,
NULL,
hInstance,
NULL);
g_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS PresentParams;
memset(&PresentParams, 0, sizeof(D3DPRESENT_PARAMETERS));
PresentParams.Windowed = TRUE;
PresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
g_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &PresentParams, &g_pDirect3D_Device);
ShowWindow(hMainWnd, nShow);
UpdateWindow(hMainWnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
g_pDirect3D_Device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255),1.0f, 0);
g_pDirect3D_Device->Present(NULL, NULL, NULL, NULL);
ValidateRect(hwnd, NULL);
return 0;
}
g_pDirect3D_Device->Release();
g_pDirect3D->Release();
return DefWindowProc(hwnd, msg, wParam, lParam);
}
Most of the errors are just saying an unidentifier