reloading model textures

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
netpipe
Posts: 669
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

reloading model textures

Post by netpipe »

in my main loop i have

Code: Select all

if (counter > 500){
    myobject=   smgr->addAnimatedMeshSceneNode(smgr->getMesh("./xcube/mdl/Cube.irrmesh"));
myobject->setScale(core::vector3df(135,135,135));
 
    counter = 0;
} else {
counter++;
}
but the textures arnt updated after being changed was wondering how i should do this. does it need to be dropped first ?
Last edited by netpipe on Wed Nov 27, 2019 5:52 pm, edited 1 time in total.
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
CuteAlien
Admin
Posts: 9647
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: reloading model textures

Post by CuteAlien »

Yeah, the problem is that textures are still in the texture-cache. Unfortuntly we don't have a way yet to "force" texture-reloading. So you have to find out which textures are used and clear those from cache first with IVideoDriver::removeTexture (and be careful you can't just delete the full texture-cache or the default-font is gone... and that one is used in the UI).
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
netpipe
Posts: 669
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Re: reloading model textures

Post by netpipe »

worked like a charm for the textured cube i may put this with the rollovericons for some kinda image browser, possibly arcball rotation for it

Code: Select all

if (counter > 500){
ITexture *textmp = driver->getTexture( "./tex/picture4.jpg" );
driver->removeTexture( textmp );
driver->getTexture( "./tex/picture4.jpg" );
    counter = 0;
} else {
counter++;
}
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
netpipe
Posts: 669
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Re: reloading model textures

Post by netpipe »

after trying again it did not work but caused crash this time. will investigate more soon.
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
CuteAlien
Admin
Posts: 9647
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: reloading model textures

Post by CuteAlien »

In theory OK, but you can optimize it by using findTexture (which searchs only cache) instead of getTexture. Otherwise on first time you load the texture twice. Crash maybe because you still use the old texture somewhere?
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
netpipe
Posts: 669
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Re: reloading model textures

Post by netpipe »

there is an autoTexReload example for irrlicht too that does not seem to work anymore either. maybe something happened to the texture cache system.
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
CuteAlien
Admin
Posts: 9647
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: reloading model textures

Post by CuteAlien »

Which example do you mean?
edit: OK, seeing your second post, guess you mean that :-)
edit2: Thought that one is using a bit different mechanism as it tries to keep the texture-pointer intact.
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
netpipe
Posts: 669
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Re: reloading model textures

Post by netpipe »

Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
netpipe
Posts: 669
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Re: reloading model textures

Post by netpipe »

viewtopic.php?f=9&t=43269&p=306263 solved here. only works with png not jpg
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
Post Reply