• Advertisement

Archived

This topic is now archived and is closed to further replies.

Directx wont remember my vertex

This topic is 5188 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

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
oops i forgot that when i update the vertices, i only update the first 8.... Sorry... Tnx anyway

Share this post


Link to post
Share on other sites

  • Advertisement