DirectX 1.0.2902 VertexBuffer problem (Fixed)

Started by
0 comments, last by Neoforce 19 years, 1 month ago
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]
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.

This topic is closed to new replies.

Advertisement