// then on.
static void fgIdleFunction ( void ) {
- // printf("idle state == %d\n", idle_state);
-
if ( idle_state == 0 ) {
idle_state++;
+ fgSplashProgress("setting up scenegraph & user interface");
+
+ } else if ( idle_state == 1 ) {
+ idle_state++;
// This seems to be the absolute earliest in the init sequence
// that these calls will return valid info. Too bad it's after
// we've already created and sized out window. :-(
// passing off control to the OS main loop and before
// fgInitGeneral to get our fonts !!!
guiInit();
+ fgSplashProgress("reading aircraft list");
- } else if ( idle_state == 1 ) {
+ } else if ( idle_state == 2 ) {
idle_state++;
// Read the list of available aircrafts
fgReadAircraft();
} else
glPointParameterIsSupported = false;
}
+ fgSplashProgress("reading navigation data");
- } else if ( idle_state == 2 ) {
+ } else if ( idle_state == 3 ) {
idle_state++;
fgInitNav();
+ fgSplashProgress("setting up scenery");
- } else if ( idle_state == 3 ) {
+ } else if ( idle_state == 4 ) {
idle_state++;
// based on the requested presets, calculate the true starting
// lon, lat
globals->set_model_mgr(new FGModelMgr);
globals->get_model_mgr()->init();
globals->get_model_mgr()->bind();
+ fgSplashProgress("loading aircraft");
- } else if ( idle_state == 4 ) {
+ } else if ( idle_state == 5 ) {
idle_state++;
////////////////////////////////////////////////////////////////////
// Initialize the 3D aircraft model subsystem (has a dependency on
globals->set_viewmgr( viewmgr );
viewmgr->init();
viewmgr->bind();
+ fgSplashProgress("generating sky elements");
- } else if ( idle_state == 5 ) {
+ } else if ( idle_state == 6 ) {
idle_state++;
// Initialize the sky
SGPath ephem_data_path( globals->get_fg_root() );
// build our custom render states
globals->get_renderer()->build_states();
+ fgSplashProgress("initializing subsystems");
- } else if ( idle_state == 6 ) {
+ } else if ( idle_state == 7 ) {
idle_state++;
// Initialize audio support
#ifdef ENABLE_AUDIO_SUPPORT
"Subsystem initializations failed ..." );
exit(-1);
}
+ fgSplashProgress("setup time & renderer");
- } else if ( idle_state == 7 ) {
- idle_state++;
+ } else if ( idle_state == 8 ) {
+ idle_state = 1000;
// Initialize the time offset (warp) after fgInitSubsystem
// (which initializes the lighting interpolation tables.)
fgInitTimeOffset();
// setup OpenGL view parameters
globals->get_renderer()->init();
- // Read the list of available aircrafts
- fgReadAircraft();
-
-
- } else if ( idle_state == 8 ) {
- idle_state = 1000;
-
SG_LOG( SG_GENERAL, SG_INFO, "Panel visible = " << fgPanelVisible() );
globals->get_renderer()->resize( fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize") );
+ fgSplashProgress("loading scenery objects");
}
- if ( idle_state < 1000 ) {
- fgSplashUpdate( 1.0 );
-
- } else {
+ if ( idle_state == 1000 ) {
// We've finished all our initialization steps, from now on we
// run the main loop.
- fgSetBool("sim/sceneryloaded",false);
+ fgSetBool("sim/sceneryloaded", false);
fgRegisterIdleHandler( fgMainLoop );
}
}
# include <math.h>
#endif
-#ifdef HAVE_WINDOWS_H
+#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#include <string.h>
+#include <plib/pu.h>
#include <simgear/compiler.h>
#include SG_GLU_H
#include "splash.hxx"
#include "fg_os.hxx"
+static const int fontsize = 19;
+static const char fontname[] = "default.txf";
+static const char *text = 0;
static SGTexture splash;
+static fntTexFont font;
+static fntRenderer info;
// Initialize the splash screen
void fgSplashInit ( const char *splash_texture ) {
+ fgRequestRedraw();
+
if (!fgGetBool("/sim/startup/splash-screen"))
return;
SG_LOG( SG_GENERAL, SG_INFO, "Initializing splash screen" );
+
+ SGPath fontpath;
+ char* envp = ::getenv("FG_FONTS");
+ if (envp != NULL) {
+ fontpath.set(envp);
+ } else {
+ fontpath.set(globals->get_fg_root());
+ fontpath.append("Fonts");
+ }
+ SGPath path(fontpath);
+ path.append(fontname);
+
+ font.load((char *)path.c_str());
+
+ info.setFont(&font);
+ info.setPointSize(fontsize);
+
+
splash.bind();
SGPath tpath( globals->get_fg_root() );
splash.read_rgb_texture(tpath.c_str());
if (!splash.usable())
{
- // Try compressed
- SGPath fg_tpath = tpath;
- fg_tpath.concat( ".gz" );
+ // Try compressed
+ SGPath fg_tpath = tpath;
+ fg_tpath.concat( ".gz" );
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() );
- exit(-1);
- }
- }
+ if ( !splash.usable() )
+ {
+ SG_LOG( SG_GENERAL, SG_ALERT,
+ "Error in loading splash screen texture " << tpath.str() );
+ exit(-1);
+ }
+ }
splash.select();
}
+void fgSplashProgress ( const char *s )
+{
+ text = s;
+ fgRequestRedraw();
+}
+
+
// Update the splash screen with alpha specified from 0.0 to 1.0
void fgSplashUpdate ( float alpha ) {
- int xmin, ymin, xmax, ymax;
- int xsize = 512;
- int ysize = 512;
+ int screen_width = fgGetInt("/sim/startup/xsize", 0);
+ int screen_height = fgGetInt("/sim/startup/ysize", 0);
- if ( !fgGetInt("/sim/startup/xsize")
- || !fgGetInt("/sim/startup/ysize") ) {
- return;
- }
+ if (!screen_width || !screen_height)
+ return;
- xmin = (fgGetInt("/sim/startup/xsize") - xsize) / 2;
- xmax = xmin + xsize;
+ int size = screen_width < (screen_height - 5 * fontsize)
+ ? screen_width : screen_height - 5 * fontsize;
+ if (size > 512)
+ size = 512;
- ymin = (fgGetInt("/sim/startup/ysize") - ysize) / 2;
- ymax = ymin + ysize;
+ int xmin, ymin, xmax, ymax;
+ xmin = (screen_width - size) / 2;
+ xmax = xmin + size;
+
+ ymin = (screen_height - size) / 2;
+ ymax = ymin + size;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
- gluOrtho2D(0, fgGetInt("/sim/startup/xsize"),
- 0, fgGetInt("/sim/startup/ysize"));
+ gluOrtho2D(0, screen_width, 0, screen_height);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
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"));
+ glVertex2f(screen_width, 0.0);
+ glVertex2f(screen_width, screen_height);
+ glVertex2f(0.0, screen_height);
glEnd();
// now draw the logo
- if (fgGetBool("/sim/startup/splash-screen") && splash.usable()) {
+ if (fgGetBool("/sim/startup/splash-screen", true)) {
glEnable(GL_TEXTURE_2D);
splash.bind();
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
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);
+ glTexCoord2f(0.0, 1.0); glVertex2f(xmin, ymax);
glEnd();
}
+ if (text && fgGetBool("/sim/startup/splash-progress", true)) {
+ glEnable(GL_ALPHA_TEST);
+ glEnable(GL_BLEND);
+ glAlphaFunc(GL_GREATER, 0.1f);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+
+ float left, right, bot, top;
+
+ info.begin();
+ glColor3f(1.0, 0.9, 0.0);
+ font.getBBox(text, fontsize, 0, &left, &right, &bot, &top);
+ info.start2f((screen_width - right) / 2.0, 10.0 - bot);
+ info.puts(text);
+
+ const char *s = fgGetString("/sim/startup/splash-title", "");
+ font.getBBox(s, fontsize, 0, &left, &right, &bot, &top);
+ info.start2f((screen_width - right) / 2.0, screen_height - top - bot - 10.0);
+ info.puts(s);
+ info.end();
+ }
+
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);