Is a VertexBuffer always readable?

Started by
2 comments, last by 21st Century Moose 12 years, 8 months ago
I have a class Mesh, that holds a VertexBuffer and now I want to lock the vertex buffer to calculate the bounding box of the mesh. I wonder if it
is ALWAYS possible to lock a VertexBuffer for reading.
As you know there are several options for DX9 vertex buffers (Static, Dynamic, DEFAULT Pool, Managed Pool etc.).

Can I lock EVERY vertex buffer for reading regardless of the used options?
Even a vertex buffer that has been created with flag D3DUSAGE_WRITEONLY (and locked with lock flag 0)?
Advertisement
[color=#1C2837][size=2]
[color=#1C2837][size=2]

[color=#1C2837][size=2]Hi,
[color=#1C2837][size=2]
D3DUSAGE_WRITEONLY means that you can't read from the buffer.
[color=#1C2837][size=2]

[color=#1C2837][size=2]So, usually you can't read from the buffers unless specified at creation time.
[color=#1C2837][size=2]

[color=#1C2837][size=2]I'd keep copy of the data for the bound box calculations.
[color=#1C2837][size=2]

[color=#1C2837][size=2]Cheers!
Well, but even if I create the buffer with usage flag D3DUSAGE_WRITEONLY, I can lock the vertex buffer with flag 0:


g_pVertexBuffer->Lock( 0, sizeof(g_quadVertices), (void**)&pVertices, 0 );

Nothing can prevent me from reading from pVertices now. Or did I miss something?
Your driver might stop you from doing it. And - worse - it may work on one driver but crash horribly on another. So don't do it.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement