Jump to content
  • Advertisement

Archived

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

bitforge

D3D - Whackass Vertex buffer problem

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

Ok, heres the problem, I''ve got 2 vertex buffers, the first one holds D3DVERTEX vertices (D3DFVF_VERTEX) and the second holds D3DTLVERTEX vertices (D3DFVF_TLVERTEX)... I copy some vertex data into the first buffer and then call ProcessVertices, to transform and light the first vertex buffer and store the new vertices in the 2nd. The problem is, the new TL Vertices in the 2nd buffer all have the correct data, except the Z component for all the TLvertices is set to 0.00, thus all the depth information is lost in the transform, and Z-buffering is useless.. Anyone have a clue why the depth information is getting lost? Here''s the code I use: LPDIRECT3DVERTEXBUFFER7 pNonTransformedVertices; LPDIRECT3DVERTEXBUFFER7 pTransformedVertices; D3DVERTEX *pVertices; D3DVERTEXBUFFERDESC desc; memset(&desc, 0, sizeof(D3DVERTEXBUFFERDESC)); desc.dwSize = sizeof(D3DVERTEXBUFFERDESC); desc.dwCaps = D3DVBCAPS_WRITEONLY; desc.dwFVF = D3DFVF_VERTEX; desc.dwNumVertices = dwNumVertices; // Create the non-transformed vertex buffer m_pD3D->CreateVertexBuffer(&desc, pNonTransformedVertices, 0); // Lock the vertex buffer and copy the vertex data pNonTransformedVertices->Lock(DDLOCK_SURFACEMEMORYPTR / DDLOCK_WAIT / DDLOCK_WRITEONLY / DDLOCK_DISCARDCONTENTS, (void**) &pVertices, NULL); memcpy(pVertices, pVertexData, dwNumVertices*sizeof(D3DVERTEX)); pNonTransformedVertices->Unlock(); // Create the TL Vertex Buffer desc.dwFVF = D3DFVF_TLVERTEX; m_pD3D->CreateVertexBuffer(&desc, pTransformedVertices, 0); // Do the transform and lighting pTransformedVertices->ProcessVertices(D3DVOP_CLIP / D3DVOP_LIGHT / D3DVOP_TRANSFORM, 0, dwNumVertices, pNonTransformedVertices, 0, m_pD3DDevice, 0); // At this point, the vertex buffer pTransformedVertices has 0.0 for the .sz component on all the vertices, But the .sz value should be the actual depth information for this vertex The world, view, and projection matrices are all corrent, cause I can render the 2nd buffer and the mesh shows up correctly, the only problem is the z information is gone, so z-buffering doesnt work

Share this post


Link to post
Share on other sites
Advertisement
I really have no idea, but you might want to double check your projection matrix (what ya got it set to?).

What happens when you render directly from the first (non-transformed) VB? Do the Z Values still appear to get messed up?

Share this post


Link to post
Share on other sites
It turned out to be a driver issue, It wasnt reproing on any other machines so I updated my drivers and it worked.. Oh well.. thx for the suggestions though

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!