Archived

This topic is now archived and is closed to further replies.

Oddball

Vertex buffer question

Recommended Posts

I''m using a vertex buffer to render primitives to the screen, and a matrix to move them around. However, I''d like to render another primitive to the screen, without it being moved around by the matrix. I was thinking of creating a different vertex buffer to hold those primitives. Is this the best way to go about it? Does having 2 vertex buffers cause a significant performance loss? Thanks.

Share this post


Link to post
Share on other sites
Whoops... it turns out that creating a vertex buffer still doesn't solve the problem- the matrix effects both. So how do I make the matrix's transformations apply to only one? I don't need another D3D Device, do I? Thanks.

Edited by - Oddball on August 9, 2001 8:56:48 PM

Share this post


Link to post
Share on other sites
Hey there,

Your problem is relatively easy to fix.

You can either:

- Set the matrix.
- Render the first primitive.
- Load the Identity Matrix.
- Render the Second Primitive.

* Or *

- Render the Second Primitive.
- Set the Matrix.
- Render the First Primitive.

A matrix doesn''t effect just the object you are rendering. It effects the whole world. After moving your first object according to the matrix, you have to reset the matrix to its default position; or set a new position, before rendering your next polygon.

I hope that wasn''t too confusing. Just ask if you need more help.

Derek Sauer
dereksauer@hotmail.com

Share this post


Link to post
Share on other sites
SetTransform(...);
DrawPrimitive(...);
SetTransform(...);
DrawPrimitive(...);

If you''re drawing 2 of the same object, then you can just render it twice. If there are 2 different objects you can either use multiple vertex buffers, or a single vertex buffer and multiple index buffers.

Share this post


Link to post
Share on other sites