* (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>
#include "../aircraft/aircraft.h"
#include "../scenery/scenery.h"
#include "../mat3/mat3.h"
+#include "../timer/fg_timer.h"
#define DEG_TO_RAD 0.017453292
/**************************************************************************
- * 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 = ¤t_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);
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 );
}
* ready for the next move?*/
static void fgMainLoop( void )
{
- fgSlewUpdate();
+ printf("Time interval is = %d\n", fgGetTimeInterval());
aircraft_debug(1);
-
fgUpdateVisuals();
}
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 );
/* $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.)
*
#---------------------------------------------------------------------------
-TARGET=viewer
+TARGET=proto
CC = gcc
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
#---------------------------------------------------------------------------
# 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
#---------------------------------------------------------------------------
# $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.
#
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);
/* $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.)
*