SG_USING_STD(endl);
#include "main.hxx"
+#include "globals.hxx"
#ifdef HAVE_WINDOWS_H
# include <console.h> // -dw- for command line dialog
#endif
+// foreward declaration.
+void fgExitCleanup();
#if defined(__linux__) && defined(__i386__)
}
#endif
+int _bootstrap_OSInit;
+
// Main entry point; catch any exceptions that have made it this far.
int main ( int argc, char **argv ) {
+ _bootstrap_OSInit = 0;
+
// Enable floating-point exceptions for Linux/x86
#if defined(__linux__) && defined(__i386__)
initFPE();
PSN psn;
fgOSInit (&argc, argv);
+ _bootstrap_OSInit++;
CPSGetCurrentProcess(&psn);
CPSSetProcessName(&psn, "FlightGear");
// FIXME: add other, more specific
// exceptions.
try {
+ atexit(fgExitCleanup);
fgMainInit(argc, argv);
} catch (sg_throwable &t) {
// We must use cerr rather than
return 0;
}
+// do some clean up on exit. Specifically we want to call alutExit()
+// which happens in the sound manager destructor.
+void fgExitCleanup() {
+
+ if (_bootstrap_OSInit != 0)
+ fgSetMouseCursor(MOUSE_CURSOR_POINTER);
+
+ if (globals)
+ delete globals;
+}
SGTimeStamp last_time_stamp;
SGTimeStamp current_time_stamp;
+// The atexit() functio handler should know when the graphical subsystem
+// is initialized.
+extern int _bootstrap_OSInit;
+
void fgBuildRenderStates( void ) {
default_state = new ssgSimpleState;
}
-// do some clean up on exit. Specifically we want to call alutExit()
-// which happens in the sound manager destructor.
-void fgExitCleanup() {
- fgSetMouseCursor(MOUSE_CURSOR_POINTER);
- delete globals;
-// fgOSExit(0);
-}
-
-
// Main top level initialization
bool fgMainInit( int argc, char **argv ) {
// set default log levels
sglog().setLogLevels( SG_ALL, SG_ALERT );
- atexit(fgExitCleanup);
-
string version;
#ifdef FLIGHTGEAR_VERSION
version = FLIGHTGEAR_VERSION;
// from main(), in bootstrap.cxx. Andy doesn't know why, someone
// feel free to add comments...
fgOSInit(&argc, argv);
+ _bootstrap_OSInit++;
#endif
fgRegisterWindowResizeHandler( fgReshape );