I have two programs that do exactly the same thing, drawing a triangle to the screen. One uses DXUT and the other does not. The program that does not use DXUT renders the triangle fine, while using DXUT nothing gets drawn.
Not using DXUT:
------------------------------------------------------------------------------
void render(){ d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); d3ddev->BeginScene(); // create the vertices using the CUSTOMVERTEX struct CUSTOMVERTEX vertices[] = { { 400.0f, 62.5f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), }, { 650.0f, 500.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), }, { 150.0f, 500.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), }, }; LPDIRECT3DVERTEXBUFFER9 v_buffer = NULL; d3ddev->CreateVertexBuffer(3*sizeof(CUSTOMVERTEX), 0, CUSTOMFVF, D3DPOOL_MANAGED, &v_buffer, NULL); VOID* pVoid; v_buffer->Lock(0, 0, (void**)&pVoid, 0); memcpy(pVoid, vertices, sizeof(vertices)); v_buffer->Unlock(); d3ddev->SetFVF(CUSTOMFVF); d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); d3ddev->EndScene(); d3ddev->Present(NULL, NULL, NULL, NULL);}
------------------------------------------------------------------------------
Using DXUT
------------------------------------------------------------------------------
void GameApp::vOnFrameRender (void) // render callback{ DXUTGetD3D9Device ()->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); DXUTGetD3D9Device ()->BeginScene (); CUSTOMVERTEX vertices[] = { { 400.0f, 62.5f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), }, { 650.0f, 500.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), }, { 150.0f, 500.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), }, }; LPDIRECT3DVERTEXBUFFER9 v_buffer = NULL; DXUTGetD3D9Device ()->CreateVertexBuffer(3*sizeof(CUSTOMVERTEX), 0, CUSTOMFVF, D3DPOOL_MANAGED, &v_buffer, NULL); VOID* pVoid; v_buffer->Lock(0, 0, (void**)&pVoid, 0); memcpy(pVoid, vertices, sizeof(vertices)); v_buffer->Unlock(); DXUTGetD3D9Device ()->SetFVF(CUSTOMFVF); DXUTGetD3D9Device ()->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); DXUTGetD3D9Device ()->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); g_HUD.OnRender( m_timer.getDelta ()); DXUTGetD3D9Device ()->EndScene();}
------------------------------------------------------------------------------
I know the verticies should be declared in a initialization function, Im just simplifying the code for now. Help with this would be greatly appreciated.