Jump to content
  • Advertisement

Archived

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

Zumichu

OpenGL .x files / opengl

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

I''ve posted this in both the DirectX board and the Opengl board because I''m not sure wich part has the problem. I''m using OpenGL to render a .X file mesh. My problem is that I get mangled meshes. Below is my code: void bfXFile::CopyVertices(vector& vertices) { assert( D3DXGetFVFVertexSize(m_pMesh->GetFVF()) == sizeof(bfVertex)); vertices.resize(m_NumVertices); bfVertex* pVertexBuffer = NULL; HRESULT hr = m_pMesh->LockVertexBuffer(D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK,(VOID**)&pVertexBuffer); if (m_DXError.LogError(hr,this)) return; for (DWORD i = 0 ; i < m_NumVertices ; ++i) { vertices.Position.x = pVertexBuffer[i].Position.x; vertices[i].Position.y = pVertexBuffer[i].Position.y; vertices[i].Position.z = pVertexBuffer[i].Position.z; vertices[i].Normal.x = pVertexBuffer[i].Normal.x; vertices[i].Normal.y = pVertexBuffer[i].Normal.y; vertices[i].Normal.z = pVertexBuffer[i].Normal.z; vertices[i].TextureCoord.s = pVertexBuffer[i].TextureCoord.s; vertices[i].TextureCoord.t = pVertexBuffer[i].TextureCoord.t; } m_pMesh->UnlockVertexBuffer(); } void bfXFile::CopyIndices(vector& indices) { int NumIndices = m_NumFaces*3; indices.resize(NumIndices); WORD* pIndexBuffer = NULL; HRESULT hr = m_pMesh->LockIndexBuffer(D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK,(VOID**)&pIndexBuffer); if (m_DXError.LogError(hr,this)) return; for (int i = 0 ; i < NumIndices ; ++i) { indices[i] = pIndexBuffer[i]; } m_pMesh->UnlockIndexBuffer(); } void bfMesh::DrawImediate() { glBegin(GL_TRIANGLES); for (DWORD i = 0 ; i < m_Indices.size() ; ++i) { glNormal3fv(m_Vertices[m_Indices[i]].Normal); glVertex3fv(m_Vertices[m_Indices[i]].Position); } glEnd(); } It seems very strait forward, but I''m missing something.

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!