D3DXCreateMeshFVF, locking buffer

Started by
6 comments, last by supagu 21 years, 1 month ago
right, the first part of the code creates a vertex buffer, for a LPD3DXMESH, which works fine, how ever when i lock it to right in my data, it fails, i have also tryed using D3DLOCK_DISCARD as the first parameter of the lock buffer, but with no success. any ideas?


	LPD3DXMESH pMesh;
	if( FAILED(D3DXCreateMeshFVF(1, 3, D3DXMESH_WRITEONLY, D3DFVF_QUADFVF, pD3DDevice, &pMesh) ))
	{
		systemLog.WriteLog("Create FVF Mesh [FAILED]");
	}

	//fill vertex buffer with shiz
	void* pVertices;

	if( FAILED(pMesh->LockVertexBuffer( 0, (void**)pVertices) ))
	{
		systemLog.WriteLog("Lock Vertex Buffer QUAD [FAILED]");
	}

	//memcpy(pVertices, quad, sizeof(QUAD_VERTEX)*6 );

	pMesh->UnlockVertexBuffer();
 
Advertisement
*bmp* sorry... just need to know, im really stuck here
Just a guess (and it''s probably wrong) but maybe you defined D3DFVF_QUADFVF worng. But it''s hard to tell with just this snippet of code.
this is what i have for my structure and fvf

#define D3DFVF_QUADFVF (D3DFVF_XYZ|D3DFVF_TEX1)//X,Y,Z & texture coords.struct QUAD_VERTEX{    float x, y, z;    float tu,tv;}; 
*bmp* real stuck ...any one?
hey,

I think you want to pass the address of your pVertices pointer.

change:
if( FAILED(pMesh->LockVertexBuffer( 0, (void**)pVertices) ))

To:
if( FAILED(pMesh->LockVertexBuffer( 0, (void**)&pVertices) ))

Maybe.
[I did absolutely nothing, and it was everything that I thought it could be]
quote:change:
if( FAILED(pMesh->LockVertexBuffer( 0, (void**)pVertices) ))

To:
if( FAILED(pMesh->LockVertexBuffer( 0, (void**)&pVertices) ))

Maybe.

There''s no reason to be hesitated here unless it''s a typo, then this is a bug.

Always use the debug runtime (with debug level set to the max) and always check the debug spew. It would''ve told you that you''re passing an invalid pointer.

Cheers,
Muhammad Haggag

thanks guys, it works, but ive never needed to do something like that with the other lock buffers

This topic is closed to new replies.

Advertisement