Sign in to follow this  

DirectX 1.0.2902 VertexBuffer problem (Fixed)

This topic is 4665 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[i] = 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
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

This topic is 4665 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this