views:

25

answers:

1

I'm currently dealing with some old DirectX code that looks (quite often at very different places) something like this:

LPDIRECT3DVERTEXBUFFER9 buffer;
//create the vertex buffer correctly here ...
buffer->Lock(...);
//loop through the buffer to check something
for(...) {
    if(checkPositive) return true;
    //some other code still inside the loop
}
buffer->Unlock();

I was just wondering if there is something like a scoped lock in DirectX, that automatically unlocks the buffer at the end of the locks lifetime. I think it will be much easier to use such a lock than manually checking every line of code now and in the future.

So before I start writing my own lock I just wanted to make sure, there's no implementation already available in the depths of the DirectX SDK.

thanks, Lenny

+1  A: 

I don't think such a thing exists. It'll only take you about 5 lines of code so go right ahead.

Kylotan