]> git.mxchange.org Git - flightgear.git/blobdiff - Main/GLUTmain.cxx
Attempting to iron out seg faults and crashes.
[flightgear.git] / Main / GLUTmain.cxx
index 689080dd11a7d4c1ae9a6998bd3a0cbfb87c863e..a3a1761244715e52fe1d08fae3a6af29a585b4ea 100644 (file)
@@ -174,75 +174,6 @@ static void fgInitVisuals( void ) {
 }
 
 
-// Update the view volume, position, and orientation
-static void fgUpdateViewParams( void ) {
-    fgFLIGHT *f;
-    fgLIGHT *l;
-    fgVIEW *v;
-
-    f = current_aircraft.flight;
-    l = &cur_light_params;
-    v = &current_view;
-
-    v->Update(f);
-    v->UpdateWorldToEye(f);
-
-    // if (!o->panel_status) {
-    // xglViewport( 0, (GLint)((v->winHeight) / 2 ) , 
-    // (GLint)(v->winWidth), (GLint)(v->winHeight) / 2 );
-    // Tell GL we are about to modify the projection parameters
-    // xglMatrixMode(GL_PROJECTION);
-    // xglLoadIdentity();
-    // gluPerspective(o->fov, v->win_ratio / 2.0, 1.0, 100000.0);
-    // } else {
-    xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) );
-    // Tell GL we are about to modify the projection parameters
-    xglMatrixMode(GL_PROJECTION);
-    xglLoadIdentity();
-    if ( FG_Altitude * FEET_TO_METER - scenery.cur_elev > 10.0 ) {
-       gluPerspective(current_options.get_fov(), v->win_ratio, 10.0, 100000.0);
-    } else {
-       gluPerspective(current_options.get_fov(), v->win_ratio, 0.5, 100000.0);
-       // printf("Near ground, minimizing near clip plane\n");
-    }
-    // }
-
-    xglMatrixMode(GL_MODELVIEW);
-    xglLoadIdentity();
-    
-    // set up our view volume (default)
-    fg_gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
-              v->view_pos.x + v->view_forward[0], 
-              v->view_pos.y + v->view_forward[1], 
-              v->view_pos.z + v->view_forward[2],
-              v->view_up[0], v->view_up[1], v->view_up[2]);
-
-    // look almost straight up (testing and eclipse watching)
-    /* fg_gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
-              v->view_pos.x + v->view_up[0] + .001, 
-              v->view_pos.y + v->view_up[1] + .001, 
-              v->view_pos.z + v->view_up[2] + .001,
-              v->view_up[0], v->view_up[1], v->view_up[2]); */
-
-    // lock view horizontally towards sun (testing)
-    /* fg_gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
-              v->view_pos.x + v->surface_to_sun[0], 
-              v->view_pos.y + v->surface_to_sun[1], 
-              v->view_pos.z + v->surface_to_sun[2],
-              v->view_up[0], v->view_up[1], v->view_up[2]); */
-
-    // lock view horizontally towards south (testing)
-    /* fg_gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
-              v->view_pos.x + v->surface_south[0], 
-              v->view_pos.y + v->surface_south[1], 
-              v->view_pos.z + v->surface_south[2],
-              v->view_up[0], v->view_up[1], v->view_up[2]); */
-
-    // set the sun position
-    xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
-}
-
-
 #ifdef IS_THIS_BETTER_THAN_A_ZERO_CHARLIE
 // Draw a basic instrument panel
 static void fgUpdateInstrViewParams( void ) {
@@ -322,11 +253,11 @@ static void fgRenderFrame( void ) {
        //        FG_Altitude * FEET_TO_METER);
     
        // this is just a temporary hack, to make me understand Pui
-       timerText -> setLabel (ctime (&t->cur_time));
+       // timerText -> setLabel (ctime (&t->cur_time));
        // end of hack
 
        // update view volume parameters
-       fgUpdateViewParams();
+       v->UpdateViewParams();
 
        clear_mask = GL_DEPTH_BUFFER_BIT;
        if ( current_options.get_wireframe() ) {
@@ -813,7 +744,7 @@ static void fgReshape( int width, int height ) {
        // yes we've finished all our initializations and are running
        // the main loop, so this will now work without seg faulting
        // the system.
-       fgUpdateViewParams();
+       v->UpdateViewParams();
     }
     
     // xglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
@@ -833,7 +764,14 @@ int fgGlutInit( int *argc, char **argv ) {
     xglutInitWindowSize(640, 480);
 
     // Initialize windows
-    xglutCreateWindow("Flight Gear");
+    if ( current_options.get_game_mode() == 0 ) {
+       // Open the regular window
+       xglutCreateWindow("Flight Gear");
+    } else {
+       // Open the cool new 'game mode' window
+       glutGameModeString("width=640 height=480 bpp=16");
+       glutEnterGameMode();
+    }
 
     return(1);
 }
@@ -881,17 +819,6 @@ int main( int argc, char **argv ) {
 
     fgPrintf(FG_GENERAL, FG_INFO, "Flight Gear:  Version %s\n\n", VERSION);
 
-    // Initialize the Window/Graphics environment.
-    if( !fgGlutInit(&argc, argv) ) {
-       fgPrintf( FG_GENERAL, FG_EXIT, "GLUT initialization failed ...\n" );
-    }
-
-    // Initialize the various GLUT Event Handlers.
-    if( !fgGlutInitEvents() ) {
-       fgPrintf( FG_GENERAL, FG_EXIT, 
-                 "GLUT event handler initialization failed ...\n" );
-    }
-
     // Attempt to locate and parse a config file
     // First check fg_root
     current_options.get_fg_root(config);
@@ -915,6 +842,17 @@ int main( int argc, char **argv ) {
        fgPrintf( FG_GENERAL, FG_EXIT, "\nExiting ...\n");
     }
     
+    // Initialize the Window/Graphics environment.
+    if( !fgGlutInit(&argc, argv) ) {
+       fgPrintf( FG_GENERAL, FG_EXIT, "GLUT initialization failed ...\n" );
+    }
+
+    // Initialize the various GLUT Event Handlers.
+    if( !fgGlutInitEvents() ) {
+       fgPrintf( FG_GENERAL, FG_EXIT, 
+                 "GLUT event handler initialization failed ...\n" );
+    }
+
     // First do some quick general initializations
     if( !fgInitGeneral()) {
        fgPrintf( FG_GENERAL, FG_EXIT, 
@@ -934,6 +872,17 @@ int main( int argc, char **argv ) {
 
 
 // $Log$
+// Revision 1.46  1998/08/22 14:49:56  curt
+// Attempting to iron out seg faults and crashes.
+// Did some shuffling to fix a initialization order problem between view
+// position, scenery elevation.
+//
+// Revision 1.45  1998/08/20 20:32:31  curt
+// Reshuffled some of the code in and around views.[ch]xx
+//
+// Revision 1.44  1998/08/20 15:10:33  curt
+// Added GameGLUT support.
+//
 // Revision 1.43  1998/08/12 21:01:47  curt
 // Master volume from 30% -> 80%
 //