Free the splash texture memory when it's no longer needed. Nowadays splash
textures are mostly 512x512 pixels, so we wasted 786 kB (RGB) or 1MB (RGBA) during the whole fgfs runtime for mere startup prettification.
This commit is contained in:
parent
1f07903cd6
commit
9438288755
3 changed files with 21 additions and 9 deletions
|
@ -153,6 +153,8 @@ public:
|
||||||
|
|
||||||
glPopClientAttrib();
|
glPopClientAttrib();
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
|
} else {
|
||||||
|
fgSplashExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
state.popStateSet();
|
state.popStateSet();
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
#include "renderer.hxx"
|
#include "renderer.hxx"
|
||||||
|
|
||||||
static const char *progress_text = 0;
|
static const char *progress_text = 0;
|
||||||
static SGTexture splash;
|
static SGTexture *splash = new SGTexture;
|
||||||
SGPropertyNode_ptr style = 0;
|
SGPropertyNode_ptr style = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ void fgSplashInit ( const char *splash_texture ) {
|
||||||
if (!fgGetBool("/sim/startup/splash-screen"))
|
if (!fgGetBool("/sim/startup/splash-screen"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
splash.bind();
|
splash->bind();
|
||||||
|
|
||||||
SGPath tpath( globals->get_fg_root() );
|
SGPath tpath( globals->get_fg_root() );
|
||||||
if (splash_texture == NULL || !strcmp(splash_texture, "")) {
|
if (splash_texture == NULL || !strcmp(splash_texture, "")) {
|
||||||
|
@ -85,15 +85,15 @@ void fgSplashInit ( const char *splash_texture ) {
|
||||||
} else
|
} else
|
||||||
tpath.append( splash_texture );
|
tpath.append( splash_texture );
|
||||||
|
|
||||||
splash.read_rgba_texture(tpath.c_str());
|
splash->read_rgba_texture(tpath.c_str());
|
||||||
if (!splash.usable())
|
if (!splash->usable())
|
||||||
{
|
{
|
||||||
// Try compressed
|
// Try compressed
|
||||||
SGPath fg_tpath = tpath;
|
SGPath fg_tpath = tpath;
|
||||||
fg_tpath.concat( ".gz" );
|
fg_tpath.concat( ".gz" );
|
||||||
|
|
||||||
splash.read_rgba_texture(fg_tpath.c_str());
|
splash->read_rgba_texture(fg_tpath.c_str());
|
||||||
if ( !splash.usable() )
|
if ( !splash->usable() )
|
||||||
{
|
{
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT,
|
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||||
"Error in loading splash screen texture " << tpath.str() );
|
"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
|
// now draw the logo
|
||||||
if (fgGetBool("/sim/startup/splash-screen", true)) {
|
if (fgGetBool("/sim/startup/splash-screen", true)) {
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
splash.bind();
|
splash->bind();
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
|
||||||
glColor4f( 1.0, 1.0, 1.0, alpha );
|
glColor4f( 1.0, 1.0, 1.0, alpha );
|
||||||
|
|
|
@ -38,7 +38,10 @@ void fgSplashInit ( const char *splash_texture );
|
||||||
void fgSplashUpdate ( float alpha );
|
void fgSplashUpdate ( float alpha );
|
||||||
|
|
||||||
// Set progress information
|
// Set progress information
|
||||||
void fgSplashProgress( const char *text );
|
void fgSplashProgress ( const char *text );
|
||||||
|
|
||||||
|
// Free texture memory
|
||||||
|
void fgSplashExit ();
|
||||||
|
|
||||||
|
|
||||||
#endif // _SPLASH_HXX
|
#endif // _SPLASH_HXX
|
||||||
|
|
Loading…
Reference in a new issue