Jump to content
  • Advertisement
Sign in to follow this  
Neoforce

DirectX 1.0.2902 VertexBuffer problem (Fixed)

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

Hey all, I'm having a problem using a VertexBuffer with C# and directx 1.0.2902. My code is: private void AddVertexBuffer(byte[] vertBytes) { int x=2; int numVerts = BitConverter.ToInt16(vertBytes,0); VertexBuffer vb = new VertexBuffer(device,numVerts,Usage.Dynamic | Uasge.WriteOnly,CustomVertex.PositionColored.Format, Pool.Default); CustomVertex.PositionColored[] verts = new CustomVertex.PositionColored[numVerts]; for(int i = 0; i<numVerts; i++) { int[] temp = new int[3]; for(int y=0; y<3; y++) { temp[y] = BitConverter.ToInt32(vertBytes,x); x+=4; } verts = new CustomVertex.PositionColored(temp[0],temp[1],temp[2],Color.Gray.ToArgb()); } vb.SetData(verts,0,LockFlags.None); m_VertexBuffers.Add(vb); } Everything is fine until vb.SetData(verts,0,LockFlags.None); This results in a stackoverflow exception. Any ideas on how to fix this or what I might be doing wrong? [Edited by - Neoforce on March 10, 2005 12:50:22 AM]

Share this post


Link to post
Share on other sites
Advertisement
The problem was with the instantiation of my VertexBuffer. I wasn't setting it to contain the correct type. I changed it to:

VertexBuffer vb = new VertexBuffer(typeof(CustomVertex.PositionColored),numVerts,device,Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default);

and it works fine.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!