Jump to content
  • Advertisement
Sign in to follow this  

Index Buffer Doesn't Render Anything

This topic is 4773 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I don't know why I am not able to render a simple triangle with index buffer. With vertex buffer it runs but when I modifie to make it with indexes it doesn't want to render. Somebody have an idea? Here is the pascal code: g_pD3DDevice.SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); vertices: array[0..2] of TCustomVertex = ( (x: -10.0; y: -10.0; z: 0; color: $00000000), // x, y, z, rhw, color), (x: -10.0; y: 10.0; z: 0; color: $00000000), (x: 10.0; y: -10.0; z: 0; color: $00000000) ); index: array[0..2] of integer = ( 0,1,2 );$ if FAILED(g_pd3dDevice.CreateVertexBuffer(3*SizeOf(TCustomVertex), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, g_pVB, nil)) then Exit; if FAILED(g_pVB.Lock(0, SizeOf(vertices), pVertices, 0)) then Exit; CopyMemory(pVertices, @vertices, SizeOf(vertices)); g_pVB.Unlock; g_pd3dDevice.CreateIndexBuffer(sizeof(integer) * 3,D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_MANAGED, g_pIB, nil); g_pIB.Lock(0,SizeOf(index), pIndex, 0); CopyMemory(pIndex, @index, SizeOf(index)); g_pIB.Unlock; g_pd3dDevice.SetStreamSource(0, g_pVB, 0, SizeOf(TCustomVertex)); g_pd3dDevice.SetIndices(g_pIB); g_pd3dDevice.DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,3,0,1); Thanks

Share this post


Link to post
Share on other sites
Advertisement
One thing it might be worth doing is changing D3DFMT_INDEX16 to D3DFMT_INDEX32, i mean thats what ive always used, probably wont make a difference though. Another thing might be to check that every DX function call succeeds, turn on D3D Debugging and look at the output, and also read the vertices from the vertex buffer back into an array or sumthing, ot make sure theyre actually in there.

ace

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!