Jump to content
  • Advertisement
Sign in to follow this  
schupf

Is a VertexBuffer always readable?

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

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)?

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!