Jump to content
  • Advertisement
Sign in to follow this  
devronious

index buffer

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

Advertisement
You need to be more specific. What are you having trouble with? In the most recent SDK (August 2005), there are a couple of pretty good topics explaining how to create index buffers and what the parameters to DrawIndexedPrimitive actually mean.

The topics in the SDK docs are "Index Buffers" and "Rendering from Vertex and Index Buffers"

neneboricua

Share this post


Link to post
Share on other sites
this is what I have so far...

ib = new IndexBuffer(device, 192, Usage.None, Pool.Default, true);
ib.Lock(0, 0, LockFlags.None);
ib.SetData(p1.indices, 0, LockFlags.None);
ib.Unlock();
device.Indices = ib;

vb = new VertexBuffer(device, 288, Usage.None, CustomVertex.PositionColored.Format, Pool.Default);
GraphicsStream gstr = vb.Lock(0, 0, LockFlags.None);
gstr.Write(p1.verts);
vb.Unlock();
.
.
.

device.SetStreamSource(0, vb, 0);
device.VertexFormat = CustomVertex.PositionColored.Format;
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 18, 0, 32);

Share this post


Link to post
Share on other sites
what do you need to know about idexBuffers?What do you want to do?anyway if you use ib.SetData(p1.indices, 0, LockFlags.None);,..you don't need lock and unlock.

Share this post


Link to post
Share on other sites
Cool thanks, This doesn't actually show anything on the screen. Any ideas why? just blank screen, but if I don't use indexbuffer then it does show stuff on screen. I'm just wondering what I'm doing wrong.

Share this post


Link to post
Share on other sites
Quote:
Original post by devronious
Cool thanks, This doesn't actually show anything on the screen. Any ideas why? just blank screen, but if I don't use indexbuffer then it does show stuff on screen. I'm just wondering what I'm doing wrong.

Then the data in your index buffer is probably incorrect.

If your buffers are set up so that you could just call DrawPrimitive on the original vertex buffers and everything is rendered fine, then your vertex buffer is probably set up so that each vertex needed for drawing the mesh is repeated however many times that is necessary. This will work but isn't as efficient as storing each vertex just once and using the index buffer to specify which vertices to use during rendering.

If its the case that your vertex buffer specifies all repeated vertices in the mesh itself, then the contents of your index buffer will probably be something like this:
{0,1,2,3,4,5,6,...}

neneboricua

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!