Jump to content
  • Advertisement
Sign in to follow this  
Captain Logic

Noob question re multiple vertex buffers

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

Just starting with D3D and trying to get my head around the "correct" way to do things. Say I have a vertex buffer with 3 vertices representing a triangle, and I want to render 5 copies of this triangle on the screen in different locations (translations). Can I do a DrawPrimitive 5 times with 5 different world transformations with the same vertex buffer? Or do I need 5 different vertex buffers, one for each triangle, even though the vertex coords will be identical?

Share this post


Link to post
Share on other sites
Advertisement
You can (technically) do it either way, however since matrix transforms are much faster than switching between vertex streams, you should use just one buffer and render it multiple times with different transforms.

Using only one buffer also uses less memory. Which is good :D

Share this post


Link to post
Share on other sites
Whenever I try the first method (single vertex buffer) I only get one triangle on the screen if I do 5 transforms, the render is at the location of the final transform. I don't get 5 images on the screen.

This is what i'm doing (pseudo-code) in my render method:

Clearscreen()
BeginScene()
SetFVF(...)
SetStream(...) // use the vertexbuffer

// Draw tri 1
D3DMatrixTranslation(...) // translate 2 units to the right
SetTransform() // world transform
DrawPrimitive(triangle ,0, 1)

// Draw tri 2
D3DMatrixTranslation(...) // translate 4 units to the right
SetTransform()
DrawPrimitive(triangle ,0, 1)

// repeat above 3 lines for 3 more tris, each translation 2 units further on

Present(...)
EndScene()

Only the final transform is rendered. How do I get all 5 triangles to render at the 5 different translations?

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!