Sign in to follow this  
Christoph

locking dynamic index buffers

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

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