Jump to content
  • Advertisement
Sign in to follow this  
mrmrcoleman

Vertex buffer lock problem...

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

My apologies if this is a bit of a lame question but I think this should work:
EditableVert *pVertices;
if(vbuffer->Lock(0, 4*sizeof(EditableVert), (BYTE**)&pVertices, 0))
return false;

EditableVert is defined as:
struct EditableVert
{
    D3DXVECTOR3 position;
    D3DCOLOR color;
    float tu, tv;
};


But I get this error:
C:\Documents and Settings\Mark\StarChart\Testing\Non-Unicode\ScreenEntityDynamicFire.cpp(93) : error C2664: 'Lock' : cannot convert parameter 3 from 'unsigned char ** ' to 'void ** '
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


I understand the error message but I am sure that I have had code like this work in the past? Thanks in advance for any help on this one, it may just be that I have had a long day!! Kind regards. Mark Coleman

Share this post


Link to post
Share on other sites
Advertisement
This is the prototype of the Lock method in DX8:

HRESULT Lock(
UINT OffsetToLock,
UINT SizeToLock,
BYTE** ppbData,
DWORD Flags
);


This is how it's defined in 9:
HRESULT Lock( UINT OffsetToLock,
UINT SizeToLock,
VOID **ppbData,
DWORD Flags
);


As you can see, they changed the 3rd parameter from pointer to pointer to BYTE, to pointer to pointer to void. That's why the code used to work - now you need to do a cast to get it to work, that's all.

Quote:
if(vbuffer->Lock(0, 4*sizeof(EditableVert), (BYTE**)&pVertices, 0))
return false;

If vbuffer is of type IDirect3DVertexBuffer9, then this code is wrong in checking the return value. You should use FAILED() when detecting failure, because there success codes that are non-zero. If it's a wrapper call, forget what I said [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!