Controlling How Buffers Are Locked

Last, we need to talk about the flags you can use when locking the buffer. The only valid flags when locking a vertex buffer are

  • LockFlags.None

  • LockFlags.Discard

  • LockFlags.NoOverwrite

  • LockFlags.NoDirtyUpdate

  • LockFlags.NoSystemLock

  • LockFlags.ReadOnly

Obviously, when using no lock flags, the default locking mechanism is used. However, if you want more control over your locking, the other flags can be used for a variety of options.

The “Discard” flag can only be used on dynamic buffers. For Vertex and Index buffers, the entire buffer will be discarded, and a new chunk of memory will be returned to you in case there is anything else still accessing the old memory. This flag is useful if you are filling a vertex buffer ...

Get Managed DirectX® 9 Kick Start: Graphics and Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.