Jump to content
  • Advertisement
Sign in to follow this  

DrawIndexedPrimitive Problem

This topic is 3003 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:


with DXDevice do

SetStreamSource(0, VertexBuffer, 0, Sizeof(TVRVertex));

for i := 0 to cVertexCount div 4 - 1 do
if not Failed(VertexBuffer.Lock(0, 0, Pointer(Vertexs), 0)) then
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;

DXDevice.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);




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

Share this post

Link to post
Share on other sites
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

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!