Skip to main content
GameDev.net gamedev.net
🔒 Locked

Geometry Problem

Started by Roaders Jan 10, 2003 at 6:14 AM 2 replies 200+ views
Original Post
Roaders
Roaders
Right, I have just started delving into Direct 3D and I have a lot of it ahead of me but at the moment I am very new. I have Special Effects game programming for DirectX 8 and have been looking at some of the samples. One fo them very simply rotates a triangle. I am trying to add another vertex to the triangle to make it into a quanrangle but I still get a triangle. The relevant bit of code (I think) is: struct CUSTOMVERTEX { FLOAT x, y, z; // The untransformed, 3D position for the vertex DWORD color; // The vertex color }; HRESULT InitGeometry() { // Initialize three vertices for rendering a triangle CUSTOMVERTEX g_Vertices[] = { { -1.0f,-1.0f, 0.0f, 0xffff0000, }, { 1.0f,-1.0f, 0.0f, 0xff0000ff, }, { 0.0f, 1.0f, 0.0f, 0xffffffff, }, { 2.0f, 1.0f, 0.0f, 0xffffffff, }, }; // Create the vertex buffer. if( FAILED( g_pd3dDevice->CreateVertexBuffer( 4*sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB ) ) ) { return E_FAIL; } // Fill the vertex buffer. VOID* pVertices; if( FAILED( g_pVB->Lock( 0, sizeof(g_Vertices), (BYTE**)&pVertices, 0 ) ) ) return E_FAIL; memcpy( pVertices, g_Vertices, sizeof(g_Vertices) ); g_pVB->Unlock(); return S_OK; } I added the extra vertex and changed the size of the buffer that is creted from 3*sizeof(CUSTOMVERTEX) to 4. Why am I still getting a triangle? Thanks for your help. Giles Roadnight giles.roadnight.name
gzito
gzito
The problem isn''t here but probably where you really draw the quad, using DrawPrimitive() or DrawIndexedPrimitive().

Can you show me the relevant code fragment?


-G.Z.-
Roaders
Roaders
Ahhh, thanks. FOr some reason I thought I was using a vertex list or whatever it is you call it when you have a list of vertices and each vertex draws a new triangle.

Thanks for the help.

Giles Roadnight

giles.roadnight.name

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.