Page 1 of 1

Always reload texture

Posted: Sun Feb 06, 2011 12:38 pm
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.

Posted: Sun Feb 06, 2011 12:47 pm
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.

Posted: Sun Feb 06, 2011 1:00 pm
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.