]> git.mxchange.org Git - flightgear.git/commitdiff
Free the splash texture memory when it's no longer needed. Nowadays splash
authormfranz <mfranz>
Wed, 2 May 2007 18:49:31 +0000 (18:49 +0000)
committermfranz <mfranz>
Wed, 2 May 2007 18:49:31 +0000 (18:49 +0000)
textures are mostly 512x512 pixels, so we wasted 786 kB (RGB) or 1MB (RGBA)
during the whole fgfs runtime for mere startup prettification.

src/Main/renderer.cxx
src/Main/splash.cxx
src/Main/splash.hxx

index f3dd310c5358a7a7c8ac681f25894b0882028de3..f6522af0a97f97a2448b1e2c076e2c8878ec9fdf 100644 (file)
@@ -153,6 +153,8 @@ public:
 
       glPopClientAttrib();
       glPopAttrib();
+    } else {
+      fgSplashExit();
     }
 
     state.popStateSet();
index 608ab425a8ffd2ce9bab6bf8ee54655e4a5e3c4f..761c14e5b74e9038a2381416ab126d51ba2d8127 100644 (file)
@@ -55,7 +55,7 @@
 #include "renderer.hxx"
 
 static const char *progress_text = 0;
-static SGTexture splash;
+static SGTexture *splash = new SGTexture;
 SGPropertyNode_ptr style = 0;
 
 
@@ -70,7 +70,7 @@ void fgSplashInit ( const char *splash_texture ) {
     if (!fgGetBool("/sim/startup/splash-screen"))
         return;
 
-    splash.bind();
+    splash->bind();
 
     SGPath tpath( globals->get_fg_root() );
     if (splash_texture == NULL || !strcmp(splash_texture, "")) {
@@ -85,15 +85,15 @@ void fgSplashInit ( const char *splash_texture ) {
     } else
         tpath.append( splash_texture );
 
-    splash.read_rgba_texture(tpath.c_str());
-    if (!splash.usable())
+    splash->read_rgba_texture(tpath.c_str());
+    if (!splash->usable())
     {
         // Try compressed
         SGPath fg_tpath = tpath;
         fg_tpath.concat( ".gz" );
 
-        splash.read_rgba_texture(fg_tpath.c_str());
-        if ( !splash.usable() )
+        splash->read_rgba_texture(fg_tpath.c_str());
+        if ( !splash->usable() )
         {
             SG_LOG( SG_GENERAL, SG_ALERT,
                     "Error in loading splash screen texture " << tpath.str() );
@@ -101,7 +101,14 @@ void fgSplashInit ( const char *splash_texture ) {
         }
     }
 
-    splash.select();
+    splash->select();
+}
+
+
+void fgSplashExit ()
+{
+    delete splash;
+    splash = 0;
 }
 
 
@@ -167,7 +174,7 @@ void fgSplashUpdate ( float alpha ) {
     // now draw the logo
     if (fgGetBool("/sim/startup/splash-screen", true)) {
         glEnable(GL_TEXTURE_2D);
-        splash.bind();
+        splash->bind();
         glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 
         glColor4f( 1.0, 1.0, 1.0, alpha );
index e50c489e839aa824141106ed715e08939cb88a9b..7ee57e856f7ab300099dad7b814639c3a0aa8dfb 100644 (file)
@@ -38,7 +38,10 @@ void fgSplashInit ( const char *splash_texture );
 void fgSplashUpdate ( float alpha );
 
 // Set progress information
-void fgSplashProgress( const char *text );
+void fgSplashProgress ( const char *text );
+
+// Free texture memory
+void fgSplashExit ();
 
 
 #endif // _SPLASH_HXX