Archived

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

supagu

D3DXCreateMeshFVF, locking buffer

Recommended Posts

supagu    148
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();
 

Share this post


Link to post
Share on other sites
Bilgates    128
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.

Share this post


Link to post
Share on other sites
supagu    148
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;
};

Share this post


Link to post
Share on other sites
Zumichu    122
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.

Share this post


Link to post
Share on other sites
Muhammad Haggag    1358
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

Share this post


Link to post
Share on other sites