Directx wont remember my vertex
heeyy, Ive used some tutorials to see how directx works. But when i tried to make a primitive of more then 8 vertices, directx thinks that the vertex 9 is at 0,0,0. When i launch the program, i see the cube with a triangle from the cube to 0,0,0.
heres bit of source code...
m_Vertices=new mrVertex[9];
ZeroMemory(m_Vertices,sizeof(mrVertex)*9);
m_Vertices[0].x=-1.0f;
m_Vertices[0].y=-1.0f;
m_Vertices[0].z=-1.0f;
.......
m_Vertices[8].x=1.0f; //9th vertex
m_Vertices[8].y=2.0f;
m_Vertices[8].z=1.0f;
m_pD3DDevice->CreateVertexBuffer(sizeof(mrVertex)*9, 0, m_FVF, D3DPOOL_DEFAULT,&m_pVertexBuffer);
BYTE* pVerticeLock=0;
m_pVertexBuffer->Lock(0, sizeof(mrVertex)*9,&pVerticeLock, 0);
CopyMemory(pVerticeLock, &m_Vertices, sizeof(m_Vertices));
m_pVertexBuffer->Unlock();
//And in the rendering function:
m_pD3DDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(mrVertex));
m_pD3DDevice->SetIndices(m_pIndexBuffer,0);
m_pD3DDevice->DrawIndexedPrimitive(m_RenderType,0, 16,0,m_Triangles);
Im using Directx8. I think the problem is something with the vertexbuffer, but what? Plz help, tnx.
Ishtar
m_Vertices seems to be a pointer. Do you now that sizeof(a pointer) gives you the size of the pointer (4 on a 32 bit machine). So you copy less than you expected.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement