Jump to content
  • Advertisement
Sign in to follow this  
caledh

[MDX 2.0] IndexBuffer Example?

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

I have been able to put together a successful VertexBuffer example after reading this post: http://www.gamedev.net/community/forums/topic.asp?topic_id=364970 However, I tried to set up an IndexBuffer and got completely baffled. I'm looking at c-unit's tutorials and trying to modify the code for setting up an index buffer of a simple 2 triangle box. No dice so far. Has anyone been able to set up a successful IndexBuffer using the new GraphicBuffer<> and can you post your source code?

Share this post


Link to post
Share on other sites
Advertisement
I'm not a big fan of index buffers myself.

One thing I have caught on to, is that some of the overloads of certain functions might not do exactly what you expect them to. To be on the safe side, always use the overload that has the same parameters as the non-managed one does, as it's most likely to do what you expect it to.

Hope this helps :).

Share this post


Link to post
Share on other sites
something like that...

m_Verts[0].setPos(Vector(x1,y1,0));
m_Verts[1].setPos(Vector(x2,y1,0));
m_Verts[2].setPos(Vector(x1,y2,0));
m_Verts[3].setPos(Vector(x2,y2,0));

const int points = 6;
int ptrs[points] = {0,2,1,1,2,3};

vertexBuffer->lock(Verts,4);
indexbuffer->lock(ptrs,points);

Share this post


Link to post
Share on other sites
Thank you for the replies. Since this is Managed DirectX 2.0, the C++ example is correct, but doesn't apply since I am working out the C# version. Thank you though. Yes, that is definitely how you do the index buffer. The thing that has really changed here involves the use of the GraphicsBuffer<T> generic to write to the VertexBuffer. I'm just wondering if the same technique is used for the IndexBuffer. I tried to use it in the same way that the SetData() would work except it would Lock the GraphicsBuffer, write the bytes (or indices) and then unlock it. One GraphicsBuffer for the Vertexes and one for the Indexes. Then render the VB, and set the indexes to the IndexBuffer. No dice.

Probably better if I post the code.

Thanks for your responses so far.

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!