]> git.mxchange.org Git - flightgear.git/blobdiff - Main/GLUTmain.c
Integrated new event manager with subsystem initializations.
[flightgear.git] / Main / GLUTmain.c
index 0c3e11a6b77034fcd65c30bd71bc8645341c4df2..4bec38867d4004a3539a517e9bef77847c77d2c1 100644 (file)
@@ -62,6 +62,7 @@ struct fgGENERAL general;
 
 /* view parameters */
 static GLfloat win_ratio = 1.0;
+static GLint winWidth, winHeight;
 
 /* temporary hack */
 /* pointer to scenery structure */
@@ -75,6 +76,9 @@ int use_signals = 0;
 /* Yet another hack. This one used by the HUD code. Michele */
 int show_hud;
 
+/* Yet another other hack. Used for my prototype instrument code. (Durk) */
+int displayInstruments; 
+
 
 /**************************************************************************
  * fgInitVisuals() -- Initialize various GL/view parameters
@@ -135,10 +139,22 @@ static void fgUpdateViewParams() {
 
     fgViewUpdate(f, v, l);
 
-    /* Tell GL we are about to modify the projection parameters */
-    xglMatrixMode(GL_PROJECTION);
-    xglLoadIdentity();
-    gluPerspective(55.0, 1.0/win_ratio, 1.0, 100000.0);
+    if (displayInstruments)
+      {
+       xglViewport(0, (GLint)(winHeight / 2 ) , (GLint)winWidth, (GLint)winHeight / 2);
+       /* Tell GL we are about to modify the projection parameters */    
+       xglMatrixMode(GL_PROJECTION);
+       xglLoadIdentity();
+       gluPerspective(55.0, 2.0/win_ratio, 1.0, 100000.0);
+      }
+    else
+      {
+       xglViewport(0, 0 , (GLint)winWidth, (GLint) winHeight);
+       /* Tell GL we are about to modify the projection parameters */    
+       xglMatrixMode(GL_PROJECTION);
+       xglLoadIdentity();
+       gluPerspective(55.0, 1.0/win_ratio, 1.0, 100000.0);
+      }
 
     xglMatrixMode(GL_MODELVIEW);
     xglLoadIdentity();
@@ -185,7 +201,7 @@ static void fgUpdateViewParams() {
 
     /* sky_brightness = 0.15; */ /* to force a dark sky (for testing) */
 
-    if ( ambient < 0.1 ) { ambient = 0.1; }
+    if ( ambient < 0.02 ) { ambient = 0.02; }
     if ( diffuse < 0.0 ) { diffuse = 0.0; }
 
     if ( sky_brightness < 0.1 ) { sky_brightness = 0.1; }
@@ -215,6 +231,47 @@ static void fgUpdateViewParams() {
 }
 
 
+/*************************************************************************
+ * Draw a basic instrument panel
+ ************************************************************************/
+static void fgUpdateInstrViewParams() {
+    xglViewport(0, 0 , (GLint)winWidth, (GLint)winHeight / 2);
+  
+    xglMatrixMode(GL_PROJECTION);
+    xglPushMatrix();
+  
+    xglLoadIdentity();
+    gluOrtho2D(0, 640, 0, 480);
+    xglMatrixMode(GL_MODELVIEW);
+    xglPushMatrix();
+    xglLoadIdentity();
+    
+    xglColor3f(1.0, 1.0, 1.0);
+    xglIndexi(7);
+  
+    xglDisable(GL_DEPTH_TEST);
+    xglDisable(GL_LIGHTING);
+  
+    xglLineWidth(1);
+    xglColor3f (0.5, 0.5, 0.5);
+
+    xglBegin(GL_QUADS);
+    xglVertex2f(0.0, 0.00);
+    xglVertex2f(0.0, 480.0);
+    xglVertex2f(640.0,480.0);
+    xglVertex2f(640.0, 0.0);
+    xglEnd();
+
+    xglRectf(0.0,0.0, 640, 480);
+    xglEnable(GL_DEPTH_TEST);
+    xglEnable(GL_LIGHTING);
+    xglMatrixMode(GL_PROJECTION);
+    xglPopMatrix();
+    xglMatrixMode(GL_MODELVIEW);
+    xglPopMatrix();
+}
+
+
 /**************************************************************************
  * Update all Visuals (redraws anything graphics related)
  **************************************************************************/
@@ -291,8 +348,14 @@ static void fgRenderFrame( void ) {
     fgSceneryRender();
 
     /* display HUD */
-    /* if( show_hud )
-       fgCockpitUpdate(); */
+    if( show_hud ) {
+       fgCockpitUpdate();
+    }
+
+    /* display instruments */
+    if (displayInstruments) {
+       fgUpdateInstrViewParams();
+    }
 
     #ifdef GLUT
       xglutSwapBuffers();
@@ -449,6 +512,7 @@ void fgInitTimeDepCalcs() {
 }
 */
 
+
 /* What should we do when we have nothing else to do?  How about get
  * ready for the next move and update the display? */
 static void fgMainLoop( void ) {
@@ -492,6 +556,7 @@ static void fgMainLoop( void ) {
     printf("Model iterations needed = %d, new remainder = %d\n", multi_loop, 
           remainder);
 
+    /* Run flight model */
     if ( ! use_signals ) {
        /* flight model */
        fgUpdateTimeDepCalcs(multi_loop);
@@ -517,6 +582,9 @@ static void fgMainLoop( void ) {
 
     fgAircraftOutputCurrent(a);
 
+    /* Process/manage pending events */
+    fgEventProcess();
+
     /* redraw display */
     fgRenderFrame();
 }
@@ -533,8 +601,11 @@ static void fgReshape( int width, int height ) {
        win_ratio = (GLfloat) height / (GLfloat) width;
     }
 
-    /* Inform gl of our view window size */
-    xglViewport(0, 0, (GLint)width, (GLint)height);
+    winWidth = width;
+    winHeight = height;
+
+    /* Inform gl of our view window size (now handled elsewhere) */
+    /* xglViewport(0, 0, (GLint)width, (GLint)height); */
 
     fgUpdateViewParams();
     
@@ -623,9 +694,18 @@ int main( int argc, char *argv[] ) {
 
 
 /* $Log$
-/* Revision 1.40  1997/12/30 01:38:37  curt
-/* Switched back to per vertex normals and smooth shading for terrain.
+/* Revision 1.43  1997/12/30 20:47:43  curt
+/* Integrated new event manager with subsystem initializations.
 /*
+ * Revision 1.42  1997/12/30 16:36:47  curt
+ * Merged in Durk's changes ...
+ *
+ * Revision 1.41  1997/12/30 13:06:56  curt
+ * A couple lighting tweaks ...
+ *
+ * Revision 1.40  1997/12/30 01:38:37  curt
+ * Switched back to per vertex normals and smooth shading for terrain.
+ *
  * Revision 1.39  1997/12/22 23:45:45  curt
  * First stab at sunset/sunrise sky glow effects.
  *