X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Fsplash.cxx;h=ce9d4361ea09fe8174a47c490c88fca5ecfd1621;hb=df472fe0f5542d570feab42ce9ac1076a07419eb;hp=bb02009a044a97e4634a5b24c4fdb84337cfb95b;hpb=43e48070fec3ff8299be0e6aa5a709711def50fe;p=flightgear.git diff --git a/src/Main/splash.cxx b/src/Main/splash.cxx index bb02009a0..ce9d4361e 100644 --- a/src/Main/splash.cxx +++ b/src/Main/splash.cxx @@ -34,63 +34,53 @@ # include #endif -#include GLUT_H - #include +#include + #include +#include #include #include -#include - #include "globals.hxx" #include "fg_props.hxx" #include "splash.hxx" +#include "fg_os.hxx" -static GLuint splash_texid; -static GLubyte *splash_texbuf; +static SGTexture splash; -// Initialize the splash screen -void fgSplashInit ( void ) { - int width, height; +// Initialize the splash screen +void fgSplashInit ( const char *splash_texture ) { 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); - - // load in the texture data - int num = (int)(sg_random() * 4.0 + 1.0); - char num_str[256]; - sprintf(num_str, "%d", num); + splash.bind(); SGPath tpath( globals->get_fg_root() ); - tpath.append( "Textures/Splash" ); - tpath.concat( num_str ); - tpath.concat( ".rgb" ); - - if ( (splash_texbuf = - read_rgb_texture(tpath.c_str(), &width, &height)) == NULL ) + if (splash_texture == NULL || !strcmp(splash_texture, "")) { + // load in the texture data + int num = (int)(sg_random() * 5.0 + 1.0); + char num_str[5]; + snprintf(num_str, 4, "%d", num); + + tpath.append( "Textures/Splash" ); + tpath.concat( num_str ); + tpath.concat( ".rgb" ); + } else + tpath.append( splash_texture ); + + 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() ); @@ -98,16 +88,15 @@ 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, float alpha ) { int xmin, ymin, xmax, ymax; - int xsize = 480; - int ysize = 380; + int xsize = 512; + int ysize = 512; if ( !fgGetInt("/sim/startup/xsize") || !fgGetInt("/sim/startup/ysize") ) { @@ -143,13 +132,7 @@ void fgSplashUpdate ( double progress, float alpha ) { // 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 + splash.bind(); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glColor4f( 1.0, 1.0, 1.0, alpha ); @@ -160,8 +143,6 @@ void fgSplashUpdate ( double progress, float alpha ) { glTexCoord2f(0.0, 1.0); glVertex2f(xmin, ymax); glEnd(); - glutSwapBuffers(); - glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glDisable(GL_TEXTURE_2D);