X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Fsplash.cxx;h=ce9d4361ea09fe8174a47c490c88fca5ecfd1621;hb=df472fe0f5542d570feab42ce9ac1076a07419eb;hp=01beffb68224baef860910d1806d12bfd3235946;hpb=182fd42b4017fa54d680508c092ea1b216398a00;p=flightgear.git diff --git a/src/Main/splash.cxx b/src/Main/splash.cxx index 01beffb68..ce9d4361e 100644 --- a/src/Main/splash.cxx +++ b/src/Main/splash.cxx @@ -34,64 +34,53 @@ # include #endif -#include -#include - #include +#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 - xglGenTextures(1, &splash_texid); - xglBindTexture(GL_TEXTURE_2D, splash_texid); -#elif GL_EXT_texture_object - xglGenTexturesEXT(1, &splash_texid); - xglBindTextureEXT(GL_TEXTURE_2D, splash_texid); -#else -# error port me -#endif - xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - xglTexParameterf(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); - char num_str[256]; - sprintf(num_str, "%d", num); + SGPath tpath( globals->get_fg_root() ); + 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); - FGPath tpath( globals->get_fg_root() ); - tpath.append( "Textures/Splash" ); - tpath.concat( num_str ); - tpath.concat( ".rgb" ); + tpath.append( "Textures/Splash" ); + tpath.concat( num_str ); + tpath.concat( ".rgb" ); + } else + tpath.append( splash_texture ); - if ( (splash_texbuf = - read_rgb_texture(tpath.c_str(), &width, &height)) == NULL ) + splash.read_rgb_texture(tpath.c_str()); + if (!splash.usable()) { // Try compressed - FGPath fg_tpath = tpath; + 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,16 +88,15 @@ void fgSplashInit ( void ) { } } - xglTexImage2D( 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; + int xsize = 512; + int ysize = 512; if ( !fgGetInt("/sim/startup/xsize") || !fgGetInt("/sim/startup/ysize") ) { @@ -121,49 +109,48 @@ void fgSplashUpdate ( double progress ) { ymin = (fgGetInt("/sim/startup/ysize") - ysize) / 2; ymax = ymin + ysize; - // first clear the screen; - xglClearColor(0.0, 0.0, 0.0, 1.0); - xglClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT ); - - // now draw the logo - xglMatrixMode(GL_PROJECTION); - xglPushMatrix(); - xglLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); gluOrtho2D(0, fgGetInt("/sim/startup/xsize"), 0, fgGetInt("/sim/startup/ysize")); - xglMatrixMode(GL_MODELVIEW); - xglPushMatrix(); - xglLoadIdentity(); - - xglDisable(GL_DEPTH_TEST); - xglDisable(GL_LIGHTING); - xglEnable(GL_TEXTURE_2D); -#ifdef GL_VERSION_1_1 - xglBindTexture(GL_TEXTURE_2D, splash_texid); -#elif GL_EXT_texture_object - xglBindTextureEXT(GL_TEXTURE_2D, splash_texid); -#else -# error port me -#endif - xglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); - - xglBegin(GL_POLYGON); - xglTexCoord2f(0.0, 0.0); glVertex2f(xmin, ymin); - xglTexCoord2f(1.0, 0.0); glVertex2f(xmax, ymin); - xglTexCoord2f(1.0, 1.0); glVertex2f(xmax, ymax); - xglTexCoord2f(0.0, 1.0); glVertex2f(xmin, ymax); - xglEnd(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + 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(); - xglutSwapBuffers(); - - xglEnable(GL_DEPTH_TEST); - xglEnable(GL_LIGHTING); - xglDisable(GL_TEXTURE_2D); - - xglMatrixMode(GL_PROJECTION); - xglPopMatrix(); - xglMatrixMode(GL_MODELVIEW); - xglPopMatrix(); + // now draw the logo + glEnable(GL_TEXTURE_2D); + 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); + glTexCoord2f(1.0, 1.0); glVertex2f(xmax, ymax); + glTexCoord2f(0.0, 1.0); glVertex2f(xmin, ymax); + glEnd(); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); }