Jump to content
  • Advertisement
Sign in to follow this  
lomateron

reusing a ID3D10Buffer*

This topic is 2128 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 3D object that changes a little bit when I make a click

the mesh that is used to show this object then is incorrect

The mesh uses:

ID3D10Buffer* g_pMeshV = NULL; //for vertex
ID3D10Buffer* g_pMeshI = NULL; // for indices
 

Can I use g_pMeshV and  g_pMeshI  again?

If yes, do I have to just call g_pMeshV->Release();g_pMeshI ->Release(); and then use them again inside CreateBuffer() function?

Edited by lomateron

Share this post


Link to post
Share on other sites
Advertisement
Sure. If you did not AddRef() those buffers anywhere else  Release() will decrement the reference counter to zero and the buffers get destroyed and you can reuse those variables. Checking with the debug layer if you got leaks after app shutdown should be easy enough if you're not certain. And make sure you did not copy those pointers (and use them) elsewhere: In that case you would be using dangling pointers. The g_ prefix makes me assume they are globals, so you're probably fine (Not saying that using globals is a good programming style. It isn't !!!)
 
But actually I'd vouch for a different approach: You don't need to recreate buffers for such a use case. You can update existing buffers with ID3D10Buffer::Map or ID3D10Device::UpdateSubresource depending on what flags you used at creation. Make your buffers big enough, keep the values around as arrays, change the arrays and then update. Only if you happen to need more space, recreating the buffer is needed.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!