• Advertisement

Archived

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

D3DXCreateMeshFVF, locking buffer

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

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
Advertisement
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
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
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
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
thanks guys, it works, but ive never needed to do something like that with the other lock buffers

Share this post


Link to post
Share on other sites

  • Advertisement