• Advertisement
Sign in to follow this  

DrawIndexedPrimitive Problem

This topic is 2732 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

First, I create VertexBuffer and IndexBuffer by IDirect3DDevice9.CreateVertexBuffer and IDirect3DDevice9.CreateIndexBuffer, at OnRender, I call DrawIndexedPrimitive some times, but preview one rectangle.
OnReder's Code:

Device.BeginScene
Device.Clear(....);

with DXDevice do
begin
SetRenderState(D3DRS_ALPHABLENDENABLE, D3DZB_FALSE);
SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);

SetFVF(VRVertexFVF);
SetIndices(IndexBuffer);
SetStreamSource(0, VertexBuffer, 0, Sizeof(TVRVertex));
end;

for i := 0 to cVertexCount div 4 - 1 do
begin
if not Failed(VertexBuffer.Lock(0, 0, Pointer(Vertexs), 0)) then
begin
Vertexs[0].Pos := Point4(i * (cWidth + 10), 0, 0);
Vertexs[1].Pos := Point4(i * (cWidth + 10) + cWidth, 0, 0);
Vertexs[2].Pos := Point4(i * (cWidth + 10), cHeight, 0);
Vertexs[3].Pos := Point4(i * (cWidth + 10) + cWidth, cHeight, 0);

Vertexs[0].TexAxis := Point2(0, 0);
Vertexs[1].TexAxis := Point2(1, 0);
Vertexs[2].TexAxis := Point2(0, 1);
Vertexs[3].TexAxis := Point2(1, 1);

Vertexs[0].Color := clWhite4.Value;
Vertexs[1].Color := clWhite4.Value;
Vertexs[2].Color := clWhite4.Value;
Vertexs[3].Color := clWhite4.Value;

Vertexs[0].Specular := 0;
Vertexs[1].Specular := 0;
Vertexs[2].Specular := 0;
Vertexs[3].Specular := 0;

VertexBuffer.Unlock;
end;
DXDevice.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);

end;

Device.EndScene;


Thanks.

[Edited by - billwillman on August 31, 2010 3:39:16 AM]

Share this post


Link to post
Share on other sites
Advertisement
1. How many triangles are you trying to draw?
2. Which one(s) draw?
3. How big is your vertex and index buffer?
4. If you have 10 vertices, you're trying to draw 5 triangles - is that right? It sounds like you don't have enough vertices to draw that many triangles; If you have 4 vertices per rectangle, that should be vertex count div 4 (or shr 2) surely?
5. What does your index buffer contain?
6. Any output from the debug runtimes?

Share this post


Link to post
Share on other sites
This is a test code.

From Evil Steve to answer:

1.How many triangles are you trying to draw?
2 triangles, 4 Vertor Point per DrawIndexedPrimitive

3.How big is your vertex and index buffer?
VertexBuffer contains 4000 vertors
IndexBuffer contains 4000 * 6/4 indexs(INDEX_16)

Thanks Evil Steve

Share this post


Link to post
Share on other sites
Are you sure the vertex coordinates you fill the vertex buffer with are correct? Do the debug runtimes say anything?

Share this post


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

  • Advertisement