Always reload texture

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
z4rd0z
Posts: 11
Joined: Sat Jan 12, 2008 9:11 am

Always reload texture

Post by z4rd0z »

Hi all,

In tutorial#9, there is a comment and some code I can't understand. I tried to search the forum but there are 11500+ posts with "always reload texture"...

Code: Select all

{
                video::ITexture * texture =
                        Device->getVideoDriver()->getTexture( filename );
                if ( texture && Model )
                {
                        // always reload texture
                        Device->getVideoDriver()->removeTexture(texture);
                        texture = Device->getVideoDriver()->getTexture( filename );

                        Model->setMaterialTexture(0, texture);
                }
                return;
        }
Can someone just tell me why once a texture is loaded we have to remove it and reload it again? Should I have to do the same in my projects?

Thanks in advance.
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I didn't write that part, but the reason is probably that you want to make sure in a model-viewer that it loads a texture again in case it has changed in the meantime. In games you don't need that.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
z4rd0z
Posts: 11
Joined: Sat Jan 12, 2008 9:11 am

Post by z4rd0z »

I see, it's just to be sure to clear the cache if the texture has been changed outside. That makes sense.

Thanks.
Post Reply