Do Direct3D objects automatically have Release called from their destructor?

Started by
1 comment, last by Jason Z 11 years, 1 month ago

I am saying this, because I use a wrapper class that in its destructor deletes its content and I'm using it for many kinds of objects, some of them have release methods(like d3d buffers) and some of them don't, so I was wondering if it's sufficient to only call delete on the pointer.I couldn't find any info on this in MSDN, but I'm almost sure they did some safety measure like that, I mean why wouldn't they?

Advertisement

D3D objects don't have destructors - they're not C++ objects as you understand them, but COM objects instead. If you look at the D3D header files you'll see that they're declared as neither classes nor structs, and you'll know from your own code that they're not instantiated via "new" but rather returned as a pointer from a Create call.

So you must manually Release them all yourself.

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

And of course, you should only release it once for each proper acquisition of the object that you have performed. If you do it too many times (accessing illegal memory area) or too few (memory leak) times, then you will get some issues.

This topic is closed to new replies.

Advertisement