]> git.mxchange.org Git - flightgear.git/blobdiff - Main/GLUTmain.cxx
Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
[flightgear.git] / Main / GLUTmain.cxx
index c47f4eed8a06ee3314fc5998168d1e99c389cdc6..d7f420e59291247604f72d9797af050f081a5c08 100644 (file)
@@ -1,10 +1,8 @@
-
-//
 // GLUTmain.cxx -- top level sim routines
 //
 // Written by Curtis Olson for OpenGL, started May 1997.
 //
-// Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
+// Copyright (C) 1997  Curtis L. Olson  - curt@me.umn.edu
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -52,7 +50,7 @@
 #include <Include/fg_constants.h>  // for VERSION
 #include <Include/general.h>
 
-#include <Aircraft/aircraft.h>
+#include <Aircraft/aircraft.hxx>
 #include <Astro/sky.hxx>
 #include <Astro/stars.hxx>
 #include <Astro/solarsystem.hxx>
 #include <Cockpit/cockpit.hxx>
 #include <Debug/fg_debug.h>
 #include <GUI/gui.h>
-#include <Joystick/joystick.h>
-#include <Math/fg_geodesy.h>
+
+#ifdef ENABLE_JOYSTICK_SUPPORT
+#  include <Joystick/joystick.hxx>
+#endif
+
+#include <Math/fg_geodesy.hxx>
 #include <Math/mat3.h>
 #include <Math/polar3d.hxx>
 #include <PUI/pu.h>
@@ -77,7 +79,7 @@
 #include <Time/fg_time.hxx>
 #include <Time/fg_timer.hxx>
 #include <Time/sunpos.hxx>
-#include <Weather/weather.h>
+#include <Weather/weather.hxx>
 
 #include "GLUTkey.hxx"
 #include "fg_init.hxx"
@@ -302,7 +304,7 @@ static void fgRenderFrame( void ) {
        // setup transformation for drawing astronomical objects
        xglPushMatrix();
        // Translate to view position
-       xglTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
+       xglTranslatef( v->view_pos.x(), v->view_pos.y(), v->view_pos.z() );
        // Rotate based on gst (sidereal time)
        // note: constant should be 15.041085, Curt thought it was 15
        angle = t->gst * 15.041085;
@@ -458,7 +460,6 @@ static const double alt_adjust_m = alt_adjust_ft * FEET_TO_METER;
 // What should we do when we have nothing else to do?  Let's get ready
 // for the next move and update the display?
 static void fgMainLoop( void ) {
-    fgCONTROLS *c;
     fgFLIGHT *f;
     fgGENERAL *g;
     fgTIME *t;
@@ -466,10 +467,7 @@ static void fgMainLoop( void ) {
     int elapsed, multi_loop;
     int i;
     double accum;
-    // double joy_x, joy_y;
-    // int joy_b1, joy_b2;
 
-    c = &cur_control_params;
     f = current_aircraft.flight;
     g = &general;
     t = &cur_time_params;
@@ -477,6 +475,8 @@ static void fgMainLoop( void ) {
     fgPrintf( FG_ALL, FG_DEBUG, "Running Main Loop\n");
     fgPrintf( FG_ALL, FG_DEBUG, "======= ==== ====\n");
 
+    fgWeatherUpdate();
+
     // Fix elevation.  I'm just sticking this here for now, it should
     // probably move eventually
 
@@ -511,12 +511,10 @@ static void fgMainLoop( void ) {
     // update "time"
     fgTimeUpdate(f, t);
 
-    // Read joystick
-    /* fgJoystickRead( &joy_x, &joy_y, &joy_b1, &joy_b2 );
-    printf( "Joystick X %f  Y %f  B1 %d  B2 %d\n",  
-           joy_x, joy_y, joy_b1, joy_b2 );
-    fgElevSet( -joy_y );
-    fgAileronSet( joy_x ); */
+#ifdef ENABLE_JOYSTICK_SUPPORT
+    // Read joystick and update control settings
+    fgJoystickRead();
+#endif
 
     // Get elapsed time for this past frame
     elapsed = fgGetTimeInterval();
@@ -576,8 +574,8 @@ static void fgMainLoop( void ) {
 
     // Run audio scheduler
 #ifdef ENABLE_AUDIO_SUPPORT
-    if ( current_options.get_sound() && !audio_sched->not_working() ) {
-       double param = c->throttle[0] * 2.0 + 1.0;
+    if ( current_options.get_sound() && audio_sched->working() ) {
+       double param = controls.get_throttle( 0 ) * 2.0 + 1.0;
 
        pitch_envelope.setStep  ( 0, 0.01, param );
        volume_envelope.setStep ( 0, 0.01, param );
@@ -698,7 +696,7 @@ static void fgIdleFunction ( void ) {
               s1 -> getRate(), s1 -> getBps(), s1 -> getStereo());
        audio_sched -> loopSample ( s1 );
 
-       if ( !audio_sched->not_working() ) {
+       if ( audio_sched->working() ) {
            pitch_envelope.setStep  ( 0, 0.01, 0.6 );
            volume_envelope.setStep ( 0, 0.01, 0.6 );
 
@@ -894,6 +892,27 @@ int main( int argc, char **argv ) {
 
 
 // $Log$
+// Revision 1.61  1998/10/25 14:08:47  curt
+// Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
+//
+// Revision 1.60  1998/10/25 10:57:18  curt
+// Changes to use the new joystick library if it is available.
+//
+// Revision 1.59  1998/10/17 01:34:21  curt
+// C++ ifying ...
+//
+// Revision 1.58  1998/10/16 23:27:52  curt
+// C++-ifying.
+//
+// Revision 1.57  1998/10/16 00:54:00  curt
+// Converted to Point3D class.
+//
+// Revision 1.56  1998/10/02 12:46:47  curt
+// Added an "auto throttle"
+//
+// Revision 1.55  1998/09/29 14:58:18  curt
+// Use working() instead of !not_working() for audio.
+//
 // Revision 1.54  1998/09/29 02:03:38  curt
 // Autopilot mods.
 //