# 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.

## 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 on other sites
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 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?

1. 1
Rutin
54
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633412
• Total Posts
3011736
• ### Who's Online (See full list)

There are no registered users currently online

×