IVideoDriver::getTexture(...) question

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
AticAtac
Posts: 29
Joined: Mon Mar 22, 2004 2:46 pm
Location: Germany

IVideoDriver::getTexture(...) question

Post by AticAtac »

Does the texture which is loaded with "IVideoDriver::getTexture(...)" remain in (System)Memory ?
The reason why i ask this is, because in my app i will have many different "gui-screens" each with its own background-picture and by switching the gui-screen i want its background-picture to be removed from the memory.
Is the "getTexture"-method the proper one for the above purpose ? :?:
Ishtm
Posts: 37
Joined: Mon May 09, 2005 8:03 pm

Post by Ishtm »

You can texture->drop(); when no need no more
Guest

Post by Guest »

is it ->drop() or is it ->release()?. I thought I read it was the latter somewhere but "what the hey" ;)
AticAtac
Posts: 29
Joined: Mon Mar 22, 2004 2:46 pm
Location: Germany

Post by AticAtac »

There is no release() method for ITexture and
drop() is not an option:
The API-doc says:
".... This pointer should not be dropped. See IUnknown::drop() for more information."

Maybe i am missing some concept here. Correct me if i understood it wrong:
Irrlicht is keeping the texture in memory and will get rid of it automatically at the end of the program ? This would mean that its "wasting" texture.
It would be great if someone could enlight this.

What i am trying to do:
I am setting up several Gui-screens which will be loaded and shown depending on user-interaction. Each screen will have a background-image which in construct like this (got it from the examples):

gui::IGUIImage* img = guienv->addImage(core::rect<int>(0,0,512,384));
img->setImage(driver->getTexture("../../media/demoback.bmp"));

I see one problem with the above code: its creating MIP-Maps by default or ? Is that the right method to create background images anyway ?

Another question:
How do you folks handle background-images in your app/games ? Usually "fullscreens" are like 800x600 or 1024x768, but images can only be loaded with power of 2 (512x512, ...). I know that it could be done by breaking the background-image into pieces and storing the in several 512x512 pictures, but is there a better or more elegant method ?
AticAtac
Posts: 29
Joined: Mon Mar 22, 2004 2:46 pm
Location: Germany

Post by AticAtac »

anyone ?
ProSoft
Posts: 59
Joined: Thu Sep 08, 2005 10:55 am
Location: Brasil

Post by ProSoft »

virtual void irr::video::IVideoDriver::removeTexture ( ITexture * texture ) [pure virtual]

Removes a texture from the texture cache and deletes it, freeing lot of memory.

Please note that after calling this, the pointer to the ITexture may not be longer valid, if it was not grabbed before by other parts of the engine for storing it longer. So it would be a good idea to set all materials which are using this texture to null or another texture first.

Parameters:
texture,: Texture to delete from the engines cache.
AticAtac
Posts: 29
Joined: Mon Mar 22, 2004 2:46 pm
Location: Germany

Post by AticAtac »

Thx for the answer !

I am still thinking about how to handle GUI-background images (after searching and reading some forum posts).
As i understand correctly Irrlicht can only display background-images properly if its power of 2. Having a 1024x768 background-Image means that one has to break this picture into pieces of power of 2, e.g. like 3 x 1024 x 256.
Since this seems like an obvious task, i wonder if there are already codes/routines to handle this internally so you dont have always to break your pictures.

Update:
ok, i thought about IGUImage and i dont like it because it has to be power of 2 and usually many Gui-Image elements (including background-picture) are not power of 2. What i did now is to load for each "gui-page" a 1024x1024 texture which will include the background-image and/or other gui-images which should be drawn for this page and i draw all these with driver->draw2DImage(...). Basically the background picture i map to screen-sizes and all other images have their own source-destination rectangles.
Soma

Post by Soma »

- drop() objects constructed with function containing "create" in the function-name
- remove() all other objects
Post Reply