Here's a minimal snippet that creates a window and renders to it via D3D9.
#include <windows.h>#include <d3d9.h>HWND hWindow;IDirect3D9* D3D;IDirect3DDevice9* Device;struct Vertex{ float x, y, z, rhw; D3DCOLOR Color;};#define FVF_VERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)LRESULT WINAPI WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ){ switch( msg ) { case WM_CLOSE: PostQuitMessage( 0 ); return 0; case WM_PAINT: ValidateRect( hWnd, NULL ); return 0; } return DefWindowProc( hWnd, msg, wParam, lParam );}int main(){ HINSTANCE hInstance = GetModuleHandle( NULL ); //create a window WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0, 0, hInstance, NULL, NULL, NULL, NULL, "MiniD3D", NULL }; RegisterClassEx( &wc ); hWindow = CreateWindowEx( WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, "MiniD3D", "MiniD3D", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, NULL, NULL, hInstance, NULL ); ShowWindow( hWindow, SW_SHOW ); UpdateWindow( hWindow ); //Set up d3d D3D = Direct3DCreate9( D3D_SDK_VERSION ); D3DPRESENT_PARAMETERS d3dpp = { 0 }; d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; D3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &Device ); //now create our triangle Vertex Triangle[3] = { { 150.0f, 50.0f, 0.5f, 1.0f, D3DCOLOR_XRGB( 255, 0, 0 ) }, { 250.0f, 250.0f, 0.5f, 1.0f, D3DCOLOR_XRGB( 0, 255, 0 ) }, { 50.0f, 250.0f, 0.5f, 1.0f, D3DCOLOR_XRGB( 0, 0, 255 ) } }; MSG msg; bool RunApp = true; while( RunApp ) { if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { if( msg.message == WM_QUIT ) RunApp = false; TranslateMessage( &msg ); DispatchMessage( &msg ); } //render stuff Device->Clear( 0, 0, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 0 ), 1.0f, 0 ); Device->BeginScene(); Device->SetFVF( FVF_VERTEX ); Device->DrawPrimitiveUP( D3DPT_TRIANGLELIST, 1, Triangle, sizeof(Vertex) ); Device->EndScene(); Device->Present( 0, 0, 0, 0 ); } Device->Release(); D3D->Release(); DestroyWindow( hWindow ); return 0;}
That should definitely compile, as well as being relatively straightforward.