Hi.
The title says it al. is it possible to change a texture at runtime and release the old one?
and is it also possible to remove a mesh that isn't any longer required at runtime.
All this has to be done without removing other textures/ objects
Thanx in advance
changing, removing textures and meshes at runtime
Oh, please first have a search at the docu and/or the forums for any questions !!!
Who would ever thought of it that you need two functions:
removeTexture(...) and removeMesh(...) !?!?!
Well, it's really dificult to guess this...
Perhaps you'll be able to find the function to change a texture on your own !?!?!?!
Little hint: Tutorial#1
Who would ever thought of it that you need two functions:
removeTexture(...) and removeMesh(...) !?!?!
Well, it's really dificult to guess this...
Perhaps you'll be able to find the function to change a texture on your own !?!?!?!
Little hint: Tutorial#1
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Hmmm...
Well, I think the mesh or texture was removed, but at the end something wants to remove them again or use them, and because they are already removed it gives an AccessViolationError...
You have to be really carefull if you remove something from the engine...
Well, I think the mesh or texture was removed, but at the end something wants to remove them again or use them, and because they are already removed it gives an AccessViolationError...
You have to be really carefull if you remove something from the engine...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Those nodes are declared as private class attributes.
- within my constructor, I assign them a value like it is done in the tutorials.
- The only method that can remove is my public sub destroy()
( tested this function when i press the x key to remove, other events works, so that isn't the problem )
- this is done with the functions mentioned by you.
they stay when that is called and as said, that exception occurs when i close my form.
I need those functions working for unloading old parts of for example: a dungeon and after that loading new parts, so the memory usage will not raise to high.
- within my constructor, I assign them a value like it is done in the tutorials.
- The only method that can remove is my public sub destroy()
( tested this function when i press the x key to remove, other events works, so that isn't the problem )
- this is done with the functions mentioned by you.
they stay when that is called and as said, that exception occurs when i close my form.
I need those functions working for unloading old parts of for example: a dungeon and after that loading new parts, so the memory usage will not raise to high.
Well, just guessing what you coded is something hard...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
A texture or mesh should only be remove()'d when the only valid pointer to it is held by the video driver base class's (CNullDriver's) texture cache or the scene manager's mesh cache (IMeshCache). Like almost everything else in Irrlicht, meshes and textures inherit from IUnknown, giving them reference counting through grab() and drop(). Newly created objects have a reference count of 1, which increases as new objects take a pointer and call grab() and decrease when they release the pointer with drop(). when the reference count reaches 0, the destructor is called. When you call a get*() function, the burden of destruction is passed to some internal manager, while when you call a create*() function or use 'new' to create a class, you hold the 'last' pointer and are responsible for dropping it.
from what I can see, mesh loaders and materials don't grab textures, so you're going to have a hard time knowing which ones you can safely remove. and it wouldn't help anyway because there's no access to IUnknown's reference count.
So, I guess the easy hacky way would be to empty your scene manager(s) and GUI, flush the SceneManager's mesh cache, then flush all textures from the driver and load everything back up again as needed.
The hard and nicer way would be to add a getRefCount function to IUnknown, make sure every class in the engine that holds a texture pointer uses grab and drop properly (~70 files plus possible class changes ), and add functions to the texture and mesh caches to release everything with a reference count of 1. Then it would be as simple as calling the clean-up functions periodically to claw back unreferenced memory.
from what I can see, mesh loaders and materials don't grab textures, so you're going to have a hard time knowing which ones you can safely remove. and it wouldn't help anyway because there's no access to IUnknown's reference count.
So, I guess the easy hacky way would be to empty your scene manager(s) and GUI, flush the SceneManager's mesh cache, then flush all textures from the driver and load everything back up again as needed.
The hard and nicer way would be to add a getRefCount function to IUnknown, make sure every class in the engine that holds a texture pointer uses grab and drop properly (~70 files plus possible class changes ), and add functions to the texture and mesh caches to release everything with a reference count of 1. Then it would be as simple as calling the clean-up functions periodically to claw back unreferenced memory.