Sign in to follow this  
robert p

Creating a ID3DXMesh from a list of vertices

Recommended Posts

I have a wierd problem creating a ID3DXMesh from an array of vertices. The problem is that when I call LockVertexBuffer and try to copy the points I overrun the end of the pointer they give me to write into, but I'm confused because I just created the mesh and used the same variable for the number of vertices for it to be created with. I think I'm confused how CreateMesh works but I'm not really sure. Anyways this is the code I have, I've changed the amount of vertices around I know it's not too many. And I know the vertices are good because I was drawing them not in a D3DXMesh before. Also I copy the indices just fine, I'm just trying to get this to work so right now so they are in a list like 0,1,2,3,4,5,6... Here is my code D3DXCreateMeshFVF(numMeshFaces, numMeshVerts, 0, VERTEX_FVF, device, &pMesh); Vertex *verts; pMesh->LockVertexBuffer(0, (void **)&verts); for(int j = 0; j < numMeshVerts; j++) verts[j] = originalVerts[j]; // Crashes right here, over runs the end of they verts array // about 2/3 of the way through, // but I just created the mesh with the same numMeshVerts amount // of vertices ??!!?? pMesh->UnlockVertexBuffer();

Share this post


Link to post
Share on other sites

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