Skip to main content
gamedev.net
🔒 Locked

Vertex Buffer Problems

Started by littleboy55 0 replies 200+ views
Original Post
littleboy55
littleboy55
hey, im having some trouble with vertex buffers, here is the code for it, im trying to map texture coords from one D3DXMesh to another. void CDLevel::Load(char *filename, char *lightmap) { char *c = new char[1000]; ZeroMemory(c,1000); BYTE *read = 0; BYTE *write = 0; HRESULT r; //Loads X files and converts them into correct FVF format if(FAILED(level.LoadX((char*)filename))) return; level.EnableMulti(); //assert(r==E_FAIL); if(FAILED(light.LoadX((char*)lightmap))) return; light.EnableMulti(); //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)); CopyMemory(&b[i],&read+Offset,sizeof(Multi)); Offset+=sizeof(Multi); } Offset = 0; light.m_pMesh->UnlockVertexBuffer(); // unlock vertex buffers level.m_pMesh->UnlockVertexBuffer(); // 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; } it just shutsdown after the first part. i have no idea what is going on, EnableMulti just changes the FVF format, Multi is just a format with extra texture Coords and m_pMesh is just a d3dxmesh, it crashes sometime after it loads the .X file, i think it crashes in the loop after i lock the VBs for the first time. PLEASE HELP, thankx in advance

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.