]> git.mxchange.org Git - flightgear.git/commitdiff
Starting to add general timer support.
authorcurt <curt>
Mon, 16 Jun 1997 19:32:50 +0000 (19:32 +0000)
committercurt <curt>
Mon, 16 Jun 1997 19:32:50 +0000 (19:32 +0000)
Main/GLmain.c
Main/Makefile
Main/mesh2GL.c
Simulator/Makefile
Simulator/README

index bb1b6aad9fca965cbd7c6d471a3b688a084d72f0..c3244a8e63fe9b57bc8b87f685f9dcda5a75b597 100644 (file)
  * (Log is kept at end of this file)
  **************************************************************************/
 
-
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <signal.h>    /* for timer routines */
 
-#if defined(__WATCOMC__) || defined(__MSC__)
-#  include <time.h>
-#else
-#  include <sys/time.h>
-#endif
 
 #ifdef GLUT
     #include <GL/glut.h>
@@ -47,6 +40,7 @@
 #include "../aircraft/aircraft.h"
 #include "../scenery/scenery.h"
 #include "../mat3/mat3.h"
+#include "../timer/fg_timer.h"
 
 
 #define DEG_TO_RAD       0.017453292
@@ -211,31 +205,14 @@ static void fgUpdateVisuals( void ) {
 
 
 /**************************************************************************
- * Timer management routines
+ * Update internal time dependent calculations (i.e. flight model)
  **************************************************************************/
 
-static struct itimerval t, ot;
-
-/* This routine catches the SIGALRM */
-void fgTimerCatch() {
+void fgUpdateTimeDepCalcs() {
     struct flight_params *f;
-    static double lastSimtime = -99.9;
-    int Overrun;
-
-    /* ignore any SIGALRM's until we come back from our EOM iteration */
-    signal(SIGALRM, SIG_IGN);
 
     f = &current_aircraft.flight;
 
-    /* printf("In fgTimerCatch()\n"); */
-
-    Overrun = (lastSimtime == Simtime);
-
-    /* add this back in when you get simtime working */
-    /* if ( Overrun ) {
-       printf("OVERRUN!!!\n");
-    } */
-
     /* update the flight model */
     fgFlightModelUpdate(FG_LARCSIM, f, DEFAULT_MULTILOOP);
 
@@ -262,29 +239,12 @@ void fgTimerCatch() {
            view_offset += PI2;
        }
     }
-
-    lastSimtime = Simtime;
-    signal(SIGALRM, fgTimerCatch);
 }
 
-/* this routine initializes the interval timer to generate a SIGALRM after
- * the specified interval (dt) */
-void fgTimerInit(float dt) {
-    int terr;
-    int isec;
-    float usec;
-
-    isec = (int) dt;
-    usec = 1000000* (dt - (float) isec);
-
-    t.it_interval.tv_sec = isec;
-    t.it_interval.tv_usec = usec;
-    t.it_value.tv_sec = isec;
-    t.it_value.tv_usec = usec;
-    /* printf("fgTimerInit() called\n"); */
-    fgTimerCatch();   /* set up for SIGALRM signal catch */
-    terr = setitimer( ITIMER_REAL, &t, &ot );
-    if (terr) perror("Error returned from setitimer");
+
+void fgInitTimeDepCalcs() {
+    /* initialize timer */
+    fgTimerInit( 1.0 / DEFAULT_MODEL_HZ, fgUpdateTimeDepCalcs );
 }
 
 
@@ -318,9 +278,8 @@ static void fgSceneryDraw() {
  * ready for the next move?*/
 static void fgMainLoop( void )
 {
-    fgSlewUpdate();
+    printf("Time interval is = %d\n", fgGetTimeInterval());
     aircraft_debug(1);
-
     fgUpdateVisuals();
 }
 
@@ -436,12 +395,13 @@ int main( int argc, char *argv[] ) {
 
     fgFlightModelInit(FG_LARCSIM, f, 1.0/(DEFAULT_MODEL_HZ*DEFAULT_MULTILOOP));
 
+    printf("Ready to initialize timer\n");
+    /* init timer routines, signals, etc. */
+    fgInitTimeDepCalcs();
+
     /* build all objects */
     fgSceneryInit();
 
-    /* initialize timer */
-    fgTimerInit( 1.0 / DEFAULT_MODEL_HZ );
-
     #ifdef GLUT
       /* call fgReshape() on window resizes */
       glutReshapeFunc( fgReshape );
@@ -483,9 +443,12 @@ int main( int argc, char *argv[] ) {
 
 
 /* $Log$
-/* Revision 1.13  1997/06/02 03:40:06  curt
-/* A tiny bit more view tweaking.
+/* Revision 1.14  1997/06/16 19:32:51  curt
+/* Starting to add general timer support.
 /*
+ * Revision 1.13  1997/06/02 03:40:06  curt
+ * A tiny bit more view tweaking.
+ *
  * Revision 1.12  1997/06/02 03:01:38  curt
  * Working on views (side, front, back, transitions, etc.)
  *
index e5e54484e4934470ca00865d031b2d7a8af056b9..3c343496cb2346be548399f49f6f03ec86bc76a2 100644 (file)
@@ -24,7 +24,7 @@
 #---------------------------------------------------------------------------
 
 
-TARGET=viewer
+TARGET=proto
 
 CC = gcc
 
@@ -68,7 +68,8 @@ CFILES = GLmain.c $(INTERFACE_FILES) mesh2GL.c
 OFILES = $(CFILES:.c=.o)
 AFILES = ../aircraft/libaircraft.a ../controls/libcontrols.a \
        ../flight/libflight.a ../flight/LaRCsim/libLaRCsim.a \
-       ../flight/slew/libslew.a ../mat3/libmat3.a ../scenery/libscenery.a
+       ../flight/slew/libslew.a ../mat3/libmat3.a ../scenery/libscenery.a \
+       ../timer/libtimer.a
 
 
 #---------------------------------------------------------------------------
@@ -88,7 +89,8 @@ clean:
 # Secondary Targets
 #---------------------------------------------------------------------------
 
-GLmain.o: GLmain.c GLUTkey.h ../aircraft/aircraft.h ../scenery/scenery.h
+GLmain.o: GLmain.c GLUTkey.h ../aircraft/aircraft.h ../scenery/scenery.h \
+       ../timer/fg_timer.h
        $(CC) $(CFLAGS) $(INCLUDES) -c GLmain.c
 
 GLUTkey.o: GLUTkey.c GLUTkey.h ../aircraft/aircraft.h
@@ -103,6 +105,9 @@ mesh2GL.o: mesh2GL.c ../scenery/mesh.h
 
 #---------------------------------------------------------------------------
 # $Log$
+# Revision 1.12  1997/06/16 19:32:51  curt
+# Starting to add general timer support.
+#
 # Revision 1.11  1997/05/31 19:16:25  curt
 # Elevator trim added.
 #
index cd0b59635fa646c87db5bbd83af45cea381f946a..ebbd5ce509fa54a284cf22a82916e649ee1ddca1 100644 (file)
@@ -44,7 +44,7 @@ GLint mesh2GL(struct mesh *m) {
     int i, j, istep, jstep, iend, jend;
     float temp;
 
-    istep = jstep = 20;  /* Detail level 1 -- 1200 ... */
+    istep = jstep = 15;  /* Detail level 1 -- 1200 ... */
 
     mesh = glGenLists(1);
     glNewList(mesh, GL_COMPILE);
@@ -104,9 +104,12 @@ GLint mesh2GL(struct mesh *m) {
 
 
 /* $Log$
-/* Revision 1.16  1997/06/02 03:40:07  curt
-/* A tiny bit more view tweaking.
+/* Revision 1.17  1997/06/16 19:32:52  curt
+/* Starting to add general timer support.
 /*
+ * Revision 1.16  1997/06/02 03:40:07  curt
+ * A tiny bit more view tweaking.
+ *
  * Revision 1.15  1997/06/02 03:01:38  curt
  * Working on views (side, front, back, transitions, etc.)
  *
index 2f535c671d555d1e046e6f71cf72772e2d38331e..6380c973211456e6a72b7db2c1b6f13492d5bf5a 100644 (file)
@@ -28,7 +28,7 @@ CC = gcc
 
 
 SUBSUBDIRS = flight/LaRCsim flight/slew
-SUBDIRS = aircraft controls flight mat3 scenery
+SUBDIRS = aircraft controls flight mat3 scenery timer
 MAIN = OpenGL
 
 
@@ -53,6 +53,9 @@ clean:
 
 #---------------------------------------------------------------------------
 # $Log$
+# Revision 1.6  1997/06/16 19:32:50  curt
+# Starting to add general timer support.
+#
 # Revision 1.5  1997/05/30 19:26:56  curt
 # The LaRCsim flight model is starting to look like it is working.
 #
index af84417d80f77df0273f3ce02952704d9a13fac9..597253556ffd2816d2a2415b9bffead25414dab6 100644 (file)
@@ -30,3 +30,8 @@ Contains miscellaneous matrix/vector routines.
 scenery/
 --------
 Scenery parsing/generating code.
+
+
+timer/
+------
+Code to handle time and timing of events.