*pIndices = 3;
++pIndices;
*pIndices = 4;
++pIndices;
*pIndices = 1;
++pIndices;
*pIndices = 1;
++pIndices;
*pIndices = 2;
++pIndices;
*pIndices = 3;
When I do the triangle, it renders the first 3 indices *fine*. But if I switch to a square, it has a cry, and complains that 4 is an invalid index.
The only thing i change is the face number, and I don't know what I'm doing wrong, so any help would be much appreciated.
Problem ID3DXMesh
Hi everybody,
I'm having trouble using the ID3DXMesh object.
I can create the object:
TRIANGLE:
D3DXCreateMeshFVF(1, 4, 0, D3DFVF, gpDevice, &gpMesh);
SQUARE:
D3DXCreateMeshFVF(2, 4, 0, D3DFVF, gpDevice, &gpMesh);
and fill it with vertices and set the attribute and index buffers up fine.
But this only works with a triangle. If I try to get a square to display using only 4 vertices, I set the vertex buffer up to this:
I'm not too familiar with indexed meshes, but perhaps using the range 0 to 3 rather than 1 to 4 would help.
Steele.
Steele.
Use a range 0-3 definitely. If nothing displays, try switching the cullmode or turning it off via SetRenderState.
ok... i have no culling on
I'll check back on using 0-3. I tried it before, but I'll try it again. I'll edit this post once I get VC++ working again.
CUSTOMVERTEX gcVertices[] = { { -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, }, // |- { -1.0f, 0.0f, -1.0f, 0.0f, 1.0f, }, // |_ { 1.0f, 0.0f, -1.0f, 1.0f, 1.0f, }, // _| { 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, }, // -| //{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, }, };// then later on void* pVertices; gpMesh->LockVertexBuffer(0, &pVertices); memcpy(pVertices, gcVertices, sizeof(gcVertices)); gpMesh->UnlockVertexBuffer();
I'll check back on using 0-3. I tried it before, but I'll try it again. I'll edit this post once I get VC++ working again.
I assume you are positioning the camera at an angle to the z axis or straight above it...right? And what RenderTarget said.
If no luck, can you display the code you used to make the triangle show up okay?
Chris
If no luck, can you display the code you used to make the triangle show up okay?
Chris
Don't worry, I solved the problem.
Yes, using 0-3 did work, but the first time I tried it it didn't work.
Anyway, a big thankyou to everybody who helped me, it was much appreciated.
- Kawahee
Yes, using 0-3 did work, but the first time I tried it it didn't work.
Anyway, a big thankyou to everybody who helped me, it was much appreciated.
- Kawahee
Final Problem
---------------------------------------------------------
When I go to release the mesh, it goes:
Unhandled exception at 0x77f75554 in engine.exe: User breakpoint.
which ends up being:
HeapFree(_crtheap, 0, pBlock);
I don't know what to do. Any ideas?
If I don't release the mesh the D3D debug systems seem to do it for me without error, but I know when I switch to release libs it won't.
---------------------------------------------------------
When I go to release the mesh, it goes:
Unhandled exception at 0x77f75554 in engine.exe: User breakpoint.
which ends up being:
HeapFree(_crtheap, 0, pBlock);
I don't know what to do. Any ideas?
If I don't release the mesh the D3D debug systems seem to do it for me without error, but I know when I switch to release libs it won't.
Are you calling gpMesh->Release() and then immediately setting gpMesh to NULL? Both are required. It may not make sense at first, but my software would crash in strange places when I didn't have the NULL assignment after the Release. It wasn't that I was using the value elsewhere either like (if(gpMesh != NULL) then gpMesh->DoSomething());
Good luck,
Chris
Good luck,
Chris
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement