Game Development Community

Texture Reload

by Alexandre Ribeiro de Sa · in Torque Game Engine Advanced · 02/07/2009 (6:47 am) · 9 replies

Hello everyone, I've got the TGEA yesterday, so this question can be a little newbie, so take easy :p hehehe...

Ok, my question is, how can I reload a texture?
The original idea was, find the texture with materialManager.cpp, close this texture and load it again, but it isn't working...

What I've already done:
char scriptFullNameBuffer[1024];
Platform::makeFullPathName( "scriptsAndAssets/data/shapes/crossbow/crossbow.jpg", scriptFullNameBuffer, sizeof(scriptFullNameBuffer) );

ResourceObject *Object = new ResourceObject();
Object = gResourceManager->find(scriptFullNameBuffer, false);

gResourceManager->freeResource(Object);

Platform::makeFullPathName( "scriptsAndAssets/data/shapes/crossbow/clip.jpg", scriptFullNameBuffer, sizeof(scriptFullNameBuffer) );
Object = gResourceManager->load(scriptFullNameBuffer, true);

And the gResourceManager->reload do not work too :)

Thanks!

#1
02/07/2009 (9:45 am)

GFX->reloadTextureResource( filename );
#2
02/07/2009 (11:32 am)
Hi Jaimi!

The GFX->reloadTextureResource didn't exist here, but I found the GFX->getTextureManager()->reloadTextureResource...

I think is the same thing, but it didn't work too :'(

Here what I'm doing:
GFX->getTextureManager()->reloadTextureResource("scriptsAndAssets/data/client/ui/background");
#3
02/07/2009 (12:06 pm)
There any way to do something like that with script!?
If there it can solve my problem too :)
#4
02/07/2009 (2:38 pm)
Looks like you also need to force the ResourceManager to reload the file from disk:

In 1.7, this should work:

ResourceManager->reload( filename, true );
GFX->reloadTextureResource( filename );

in 1.8, it should be like this:

gResourceManager->reload( filename, true );
GFX->getTextureManager()->reloadTextureResource(filename);

From script (only in 1.7) you can reload all textures with reloadMaterials(); However, this is commented out in 1.8.
#5
02/07/2009 (2:43 pm)
hum... I'm with 1.8... I'll download the 1.7 and check here too...
#6
02/07/2009 (2:44 pm)
@Alexandre - I edited the post above at the same time you were responding. Sorry! Please see the updated post.
#7
02/07/2009 (3:23 pm)
Didn't work... Just to check if everything is right... Here what I did:

char scriptFullNameBuffer[1024];
Platform::makeFullPathName( "scriptsAndAssets/data/shapes/crossbow/crossbow.jpg",
scriptFullNameBuffer, sizeof(scriptFullNameBuffer) );

gResourceManager->reload( scriptFullNameBuffer, true ); 
GFX->getTextureManager()->reloadTextureResource( scriptFullNameBuffer );

Just a note:
scriptFullNameBuffer = c:/Torque/TGEA_1_8_0/.../shapes/crossbow/crossbow.jpg

Downloading the 1.7 to test...
#8
02/07/2009 (4:29 pm)
not Sure - Have you stepped into gResourceManager->reload to see if it's finding it in the tree? I'm not sure whether it wants a relative path or a full path or not...
#9
02/07/2009 (5:23 pm)
Ok...

1.7 - WORK!!! :D
1.8 - break :'(

I'll try to find WHY and post here...