Jump to content
  • Advertisement
Sign in to follow this  
Christoph

locking dynamic index buffers

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

Hi, I get an error (access violation) when locking a dynamic index buffer. Removing the D3DUSAGE_DYNAMIC flag solves the problem - However, I want to work with a dynamic index buffer. There it is: device->CreateIndexBuffer(sizeof(short)*a, D3DUSAGE_WRITEONLY || D3DUSAGE_DYNAMIC, D3DFMT_INDEX16, D3DPOOL_MANAGED, &ib[6], NULL); index[6] = new short[a]; short *ind; ib[6]->Lock(0,0,(void**)&ind, D3DLOCK_DISCARD); //ERROR! How can I avoid this error? thx, Chris [Edited by - Christoph on July 4, 2005 6:34:17 PM]

Share this post


Link to post
Share on other sites
Advertisement
D3DUSAGE_DYNAMIC and D3DPOOL_MANAGED are incompatible and should not be used together. (from the DX Docs)

EDIT: change D3DPOOL_MANAGED to something different, probablY D3DPOOL_DEFAULT.

Share this post


Link to post
Share on other sites
Quote:
Original post by Christoph
D3DUSAGE_WRITEONLY || D3DUSAGE_DYNAMIC


It's probably not even getting created. Use only 1 bar for bitwise OR.

D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC

Share this post


Link to post
Share on other sites
Quote:
Original post by Christoph
device->CreateIndexBuffer(sizeof(short)*a, D3DUSAGE_WRITEONLY || D3DUSAGE_DYNAMIC, D3DFMT_INDEX16, D3DPOOL_MANAGED, &ib[6], NULL);


That || should be a |.

EDIT: I'm slow :/ . Also, as RhoneRanger says, you need to use D3DPOOL_DEFAULT.

Share this post


Link to post
Share on other sites
Also be aware now that with the D3DPOOL_DEFAULT setting, you will have to release that index buffer before you call IDirect3DDevice9::Reset(), and reallocate it after the method return. For instance, if you change video mode, resize the backbuffer(s), or for many other reasons you may call ::Reset().

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!