Skip to main content
GameDev.net gamedev.net
🔒 Locked

VertexBuffer with multiple textures

Started by ProgrammerDX Sep 21, 2010 at 5:47 AM 2 replies 1.9k views
Original Post
ProgrammerDX
ProgrammerDX
Hey

When you have a vertex buffer you use DrawPrimitive. And if you have a texture you use SetTexture first.

But if you have a vertex buffer that uses alot of textures, what to do?
Evil Steve
Evil Steve
Assuming you mean you want the textures displayed seperately and not combined in some way, you make multiple calls to SetTexture and DrawPrimitive to draw only the primitives textured with one particular material.

For instance, if you have a cube, where each face has a different texture applied, you'd make 8 calls to SetTexture and 8 calls to DrawPrimitive, one for each face.
ProgrammerDX
ProgrammerDX
Thanks for your answer.

But the Vertex Buffer defines the whole Cube object? Wouldnt DirectX (underlying Graphic Card) try to draw the full cube every call to DrawPrimitive, which would create more load?
Evil Steve
Evil Steve
Quote:
Original post by ProgrammerDX
Thanks for your answer.

But the Vertex Buffer defines the whole Cube object? Wouldnt DirectX (underlying Graphic Card) try to draw the full cube every call to DrawPrimitive, which would create more load?
The vertex buffer contains vertices, not objects. You define the object based on the parameters you pass to DrawPrimitive().

So, your loop would be something like:
for(int i=0; i<8; ++i){   pDevice->SetTexture(0, textures);   pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, i*4, 2);}

I.e. draw two triangles, starting from vertex 0, 4, 8, 12, 16, 20, 24, or 28.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.