My Triangle isnt showing up

Started by
1 comment, last by SuperFunHappyMeowCat 18 years, 9 months ago
Hey everyone, im learning Direct3D using the book "Introduction to 3D game programming with directx 9.0" by Luna. And im trying to get a triangle to show, but all i get is the cleared screen. here are my setup, and drawing functions: void tileEngine::Setup() { device->CreateVertexBuffer(3 * sizeof(Vertex), 0, D3DFVF_XYZ | D3DFVF_DIFFUSE, D3DPOOL_MANAGED, &VB, 0); D3DVERTEXBUFFER_DESC VBdesc; VB->GetDesc(&VBdesc); Vertex* verts; VB->Lock(0, sizeof(verts), (void **)&verts, 0); verts[0] = Vertex(-0.5f, -0.5f, 0.0f); verts[1] = Vertex(0.5f, -0.5f, 0.0f); verts[2] = Vertex(0.0f, 0.3f, 0.0f); VB->Unlock(); device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); }; /////////////////////////////////////////////////////////////////////////// void tileEngine::Display() { device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0); device->BeginScene(); device->SetStreamSource(0, VB, 0, sizeof(Vertex)); device->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE); device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); device->EndScene(); device->Present(0, 0, 0, 0); }; I'm pretty confident that the window is initialized fine, but I cant seem to figure out why nothing is showing up... I really hope this is a stupid mistake :D
Advertisement
Did you set up a ZBuffer, becouse clearing a z buffer
without a z buffer result in pixel pulp. And if you have
lightning on shut it down becouse if lightning is on and
you don't set up some lights you end up your tiangles
rendered black, and you don't set a color for the vetices (uncolored
vertices are rendered white).

Tjaalie,
if (*pYou == ASSHOLE) { pYou->Die(); delete pYou; };
ahhh thank you very much! It was because of the lighting.

This topic is closed to new replies.

Advertisement