Jump to content
  • Advertisement

Archived

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

littleboy55

VertexBuffer Problems please help

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

Hi, iv been working for hours on this problem and still i can find no information. i just cant figure out whats wrong someone please help here is the code void CDLevel::Load(char *filename, char *lightmap) { BYTE *read = 0; BYTE *write = 0; D3DVERTEXBUFFER_DESC desc; LPDIRECT3DVERTEXBUFFER8 vb; g_Debug->Out("hello","hello"); HRESULT r; //assert(read!=0); //Loads X files and converts them into correct FVF format if(FAILED(level.LoadX((char*)filename))) return; level.EnableMulti(); if(FAILED(light.LoadX((char*)lightmap))) return; light.EnableMulti(); light.m_pMesh->GetVertexBuffer(&vb); vb->GetDesc(&desc); cerr << light.GetNumVerts() << "\n" << level.GetNumVerts(); //assert(level.GetNumVerts()<=light.GetNumVerts()); //assert(r==E_FAIL); //assert(r==S_OK); const unsigned int size = level.GetNumVerts(); // storage space Multi *a = new Multi[size]; Multi *b = new Multi[size]; // locks the vertex buffers of the lightmap mesh + level mesh light.m_pMesh->LockVertexBuffer( D3DLOCK_READONLY, &read); level.m_pMesh->LockVertexBuffer( D3DLOCK_READONLY, &write); int Offset = 0; for( int i= 0;i,&write+Offset,sizeof(Multi)); MoveMemory(&b[i],&read+Offset,sizeof(Multi)); Offset+=sizeof(*read); } Offset = 0; light.m_pMesh->UnlockVertexBuffer(); // unlock vertex buffers level.m_pMesh->UnlockVertexBuffer(); assert(r==E_FAIL); // lock the vertex buffer agian this time to write over it level.m_pMesh->LockVertexBuffer( D3DLOCK_DISCARD , &write); Offset=0; for(i = 0;iUnlockVertexBuffer(); // release storage delete []a; delete []b; } level and light are just wrappers for D3DXMeshes, Enable Multi just clones the m_pMesh onto itself with a new FVF format, i dont know what could possobly be wrong m_pMesh is just a D3DXMesh please please help this problem is killing me

Share this post


Link to post
Share on other sites
Advertisement
shit, i knew i was forgeting something duh um the program shuts down in the first read loop which is why i think that something is wrong with my FVF but here is the code tat changes the FVF format

void CDMesh::EnableMulti()
{
LPD3DXMESH pTempMesh = 0;
m_pMesh->CloneMeshFVF(
D3DXMESH_MANAGED,
D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_SPECULAR|D3DFVF_TEX2,
g_pDevice,
&pTempMesh);
D3DXComputeNormals(pTempMesh);
m_pMesh->Release();
m_pMesh = pTempMesh;
}

thanx alot

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!