Game Development Community

How to dump textures to disk (1.7.2)?

by Dmitriy Stukalov · in Torque Game Builder · 03/20/2008 (10:39 am) · 6 replies

Hello,

Recently I've finished porting my game from TGB 1.1.3 to TGB 1.7.2! Just now I've tried to dump game textures to disk with
$pref::T2D::imageMapDumpTextures = 1;
Excuse me for the stupid post but I can't find the dump folder! May be I'm wrong with command syntax? I've readed the TGB reference and what I found in Image Maps chapter is
Let's introduce these preferences now:

$prefs::T2D::imageMapEchoErrors
$prefs::T2D::imageMapShowPacking
$prefs::T2D::imageMapDumpTextures
$prefs::T2D::imageMapFixedMaxTextureSize
$prefs::T2D::imageMapFixedMaxTextureError
$pref::T2D::imageMapPreloadDefault
$pref::T2D::imageMapAllowUnloadDefault
Wow! What is $prefs? I've opened the file defaultPrefs.cs but I don't found $prefs! Is this the documentation error?

Thank you!

#1
03/21/2008 (11:12 am)
Hey,

There are actually two errors here. First, you are correct that it is a documentation error, it really should read pref instead of "prefs". Second, even if you set the pref it won't save out, due to the file IO changes in 1.5. I've located and fixed the button in our existing repo, unfortunately there's not a work around for non-pro users. Thanks for posting this issue.
#2
03/24/2008 (4:59 am)
Thank you for your answer Matthew,

Now I use $pref::T2D::imageMapShowPacking to control the packing process.
#3
03/26/2008 (12:23 pm)
Matthew, you hinted that there is a workaround for Pro users... I would certainly like to dump textures, but like Dmitriy, I've never been able to get this to work, in 1.5 or earlier versions. (I'm on a Mac... might this be a problem too?) In any case, if there is some way to dump textures on the Mac version using 1.5 or later, I'd appreciate knowing how!
#4
03/26/2008 (1:10 pm)
I changed this in the source code to get it working. t2dImageMapDablock.cc around line 1503

// Are we dumping the imageMap textures?
        if ( imageMapDump )
        {
            // Dump packed textures to disk.
            static FileStream stream;
            char packFile[1024];
            dSprintf( packFile, 1024, "imageMapDump/%s_Page_%d.png", getName(), n );

	    // Expand relative paths.
            char buffer[1024];
            if ( packFile )
               if ( Con::expandToolScriptFilename( buffer, sizeof( buffer ), packFile ) )
                  dSprintf( packFile, 1024, buffer);

            bool opened = ResourceManager->openFileForWrite( stream, packFile, FileStream::Write );
               
	    if(opened)
	    {
	       texturePage.mpPageBitmap->writePNG( stream );
               stream.close();
	    }
        }

In the end this is more of a shortsight in the way the new File IO works. The game app is now supposed to only have access to the proper application data directories, not it's own working directory... the original write code here is assuming you have access to the working directory. I'm not sure if this is going to be the final solution (probably not actually) but it's a workaround for now.
#5
03/26/2008 (3:30 pm)
Sweet, I'll try that out real soon. Quick question though: the textures dumped... does that represent what is in main memory, or VRAM? Or are both simply a mirror of each other? (i.e. everything in main memory is also in VRAM?) I'd like to learn more about how torque handles swapping of textures in and out of VRAM, if such swapping occurs.
#6
03/26/2008 (3:40 pm)
Oooooh, it works! (For the first time.) Thanks so much Matthew, the texture dump feature is very helpful!