Sign in to follow this  

Vertex Buffer Locks

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

Alright, I'm trying to think of the uses for the offset in vertex buffer locks.
HRESULT Lock(          UINT OffsetToLock,
    UINT SizeToLock,
    VOID **ppbData,
    DWORD Flags
);
Now, why exactly shouldn't this value be set to 0? I'm trying to eliminate useless parameters in a function declaration and if this is going to be set to 0 anyway it's not worthwhile having it.

Share this post


Link to post
Share on other sites
Yeah, thats right.. suppose you have 4 particles, each takes up 16 bytes, to lock the 2nd particle you set the offset to 16 and the size to 16.

If you retrieve the info from the vb (reading from the VB is not recommended), then you only get that particle, or you can decide only to write to that particle.

I would skip using lock() and unlock() if you can avoid it, and use a vertex shader.

Share this post


Link to post
Share on other sites
Quote:
Original post by PumpkinPieman
So if I had 4 objects in the vertex buffer I could lock and unlock it to edit one of those objects based on the offset?

Yes, though usually static buffers hold objects that aren't edited. What's more likely is that you're using a dynamic vertex buffer with the DISCARD/NOOVERWRITE scheme, where you fill in a batch, render, lock with NOOVERWRITE starting at an empty position, fill in another batch, and render, ...etc

Share this post


Link to post
Share on other sites

This topic is 4731 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this