X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Fsplash.cxx;h=0c6e68e45b57a3e357ee9f5313813a0754e51c50;hb=d53b612e2a72f06b51a9a4c24e6aefc992984b46;hp=092a3d3714f933b811159d1758bf940545eae71e;hpb=a0d50000ba0aef47f52bedbd7e335501c291bb9b;p=flightgear.git diff --git a/src/Main/splash.cxx b/src/Main/splash.cxx index 092a3d371..0c6e68e45 100644 --- a/src/Main/splash.cxx +++ b/src/Main/splash.cxx @@ -34,45 +34,28 @@ # include #endif -#include -#include +#include GLUT_H #include #include #include #include - -#include +#include #include "globals.hxx" #include "fg_props.hxx" #include "splash.hxx" -static GLuint splash_texid; -static GLubyte *splash_texbuf; +static SGTexture splash; // Initialize the splash screen void fgSplashInit ( void ) { - int width, height; - SG_LOG( SG_GENERAL, SG_INFO, "Initializing splash screen" ); -#ifdef GL_VERSION_1_1 - glGenTextures(1, &splash_texid); - glBindTexture(GL_TEXTURE_2D, splash_texid); -#elif GL_EXT_texture_object - glGenTexturesEXT(1, &splash_texid); - glBindTextureEXT(GL_TEXTURE_2D, splash_texid); -#else -# error port me -#endif - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + splash.bind(); // load in the texture data int num = (int)(sg_random() * 4.0 + 1.0); @@ -84,14 +67,15 @@ void fgSplashInit ( void ) { tpath.concat( num_str ); tpath.concat( ".rgb" ); - if ( (splash_texbuf = - read_rgb_texture(tpath.c_str(), &width, &height)) == NULL ) + splash.read_rgb_texture(tpath.c_str()); + if (!splash.usable()) { // Try compressed SGPath fg_tpath = tpath; fg_tpath.concat( ".gz" ); - if ( (splash_texbuf = - read_rgb_texture(fg_tpath.c_str(), &width, &height)) == NULL ) + + splash.read_rgb_texture(fg_tpath.c_str()); + if ( !splash.usable() ) { SG_LOG( SG_GENERAL, SG_ALERT, "Error in loading splash screen texture " << tpath.str() ); @@ -99,13 +83,12 @@ void fgSplashInit ( void ) { } } - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, - GL_UNSIGNED_BYTE, (GLvoid *)(splash_texbuf) ); + splash.select(); } // Update the splash screen with progress specified from 0.0 to 1.0 -void fgSplashUpdate ( double progress ) { +void fgSplashUpdate ( double progress, float alpha ) { int xmin, ymin, xmax, ymax; int xsize = 480; int ysize = 380; @@ -121,11 +104,6 @@ void fgSplashUpdate ( double progress ) { ymin = (fgGetInt("/sim/startup/ysize") - ysize) / 2; ymax = ymin + ysize; - // first clear the screen; - glClearColor(0.0, 0.0, 0.0, 1.0); - glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT ); - - // now draw the logo glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); @@ -137,16 +115,22 @@ void fgSplashUpdate ( double progress ) { glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); + + // draw the background + glColor4f( 0.0, 0.0, 0.0, alpha ); + glBegin(GL_POLYGON); + glVertex2f(0.0, 0.0); + glVertex2f(fgGetInt("/sim/startup/xsize"), 0.0); + glVertex2f(fgGetInt("/sim/startup/xsize"), fgGetInt("/sim/startup/ysize")); + glVertex2f(0.0, fgGetInt("/sim/startup/ysize")); + glEnd(); + + // now draw the logo glEnable(GL_TEXTURE_2D); -#ifdef GL_VERSION_1_1 - glBindTexture(GL_TEXTURE_2D, splash_texid); -#elif GL_EXT_texture_object - glBindTextureEXT(GL_TEXTURE_2D, splash_texid); -#else -# error port me -#endif - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + splash.bind(); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glColor4f( 1.0, 1.0, 1.0, alpha ); glBegin(GL_POLYGON); glTexCoord2f(0.0, 0.0); glVertex2f(xmin, ymin); glTexCoord2f(1.0, 0.0); glVertex2f(xmax, ymin);