Declare a varialbe

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
aelmetwaly
Posts: 7
Joined: Sat Oct 11, 2003 8:20 pm

Declare a varialbe

Post by aelmetwaly »

What is the proper way to declar a variable in irrlicht engine
is it on the stack or on the heap
lich

Code: Select all

IAnimateMesh* mesh = 0;
does the engine deletes it for me?
sirshane

Post by sirshane »

For the most part I believe the engine will delete stuff for you. Meshes, textures and nodes are reference counted by the engine. When a node is no longer being used it gets automatically deleted. Optionally, you can have a mesh, node etc. delete it's self by calling the drop( ) method of it's IUnknown interface. This is generally a bad idea though, since you never know if it's being referenced still or not.

Just let the engine handle the memory. :)
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Re: Declare a varialbe

Post by [dx/x]=HUNT3R »

aelmetwaly wrote:What is the proper way to declar a variable in irrlicht engine
is it on the stack or on the heap
lich

Code: Select all

IAnimateMesh* mesh = 0;
does the engine deletes it for me?
Thats how I declare mine, and sirshane said let the engine delete stuff for you except for a few select types that can be dropped when you're done. Check out the API and it will tell you if it should be dropped or not.
Saalen
Posts: 51
Joined: Thu Sep 04, 2003 7:49 am
Location: Germany
Contact:

Post by Saalen »

As stated in the API docs, you have to drop all objects you got from a create-Method. Pointers which are results of add-Methods do not need to be dropped.
Post Reply