Skip to main content
gamedev.net
🔒 Locked

Question about locking buffers

Started by LevyDee 1 reply 750+ views
Original Post
LevyDee
LevyDee
In a lot of examples when working with buffers, it follows a pretty standard approach of locking, mem copying and unlocking:

VOID* pVoid;

_vBuffer->Lock(0, 0, (void**)&pVoid, 0);
memcpy(pVoid, source, size);
_vBuffer->Unlock();


My question is, I am working on an algo that loads vertice information, and than will create a vertex buffer on a per object basis. So say at point A, i pass an object that contains a vertex buffer, create the vertex buffer with my d3d device, lock, memcpy and unlock. Then say at point C I want to pass a different object that contains a vertex buffer, and create the buffer, fill the memory and unlock. Do I need a new VOID pointer, or is it reusable so I can just declare it on the stack each time the function is called to create my buffers?

Thanks.
Buckeye
Buckeye
Once you've Unlocked the buffer, the variable pVoid can be (re-)used. It's an invalid pointer to a buffer at that point, but feel free to overwrite it with a new value (if that's you're question).

EDIT:
I assume you're asking about:

VOID *pVoid;
// use pVoid to load buffer A
bufferA->Unlock();

bufferC->Lock(0, 0, (void**)&pVoid, 0);
// do stuff
bufferC->Unlock();
Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly. You don't forget how to play when you grow old; you grow old when you forget how to play.
LevyDee
LevyDee
That was my question, thanks for the quick response.

Topic Locked

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

Sign in to reply to this topic.