From d19c5f0b6f9f80190967fd367bbb14da1fa1d22e Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 15 Dec 1997 23:54:25 +0000 Subject: [PATCH] Add xgl wrappers for debugging. Generate terrain normals on the fly. --- Aircraft/aircraft.c | 12 ++- Aircraft/depend | 2 +- Cockpit/cockpit.c | 12 ++- Cockpit/depend | 24 +++--- Cockpit/hud.c | 12 ++- Controls/controls.h | 12 ++- Controls/depend | 5 +- LaRCsim/depend | 2 +- Main/GLUTkey.c | 17 ++-- Main/GLUTmain.c | 153 ++++++++++++++++++---------------- Main/Makefile | 8 +- Main/depend | 51 ++++++------ Main/fg_init.c | 12 ++- Main/views.c | 12 ++- Main/views.h | 12 ++- Scenery/astro.c | 27 +++--- Scenery/depend | 56 +++++++------ Scenery/mesh.c | 12 ++- Scenery/moon.c | 75 +++++++++-------- Scenery/obj.c | 199 +++++++++++++++++++++++++++++++------------- Scenery/orbits.c | 12 ++- Scenery/scenery.c | 22 +++-- Scenery/scenery.h | 12 ++- Scenery/stars.c | 79 ++++++++++-------- Scenery/sun.c | 68 ++++++++------- Simulator/Makefile | 7 +- Simulator/make.inc | 27 ++++-- Slew/depend | 4 +- Slew/slew.c | 10 ++- Time/depend | 18 ++-- Time/fg_time.c | 10 ++- Time/fg_time.h | 12 ++- Time/sunpos.c | 12 ++- Time/sunpos.h | 2 +- Weather/depend | 2 +- 35 files changed, 608 insertions(+), 404 deletions(-) diff --git a/Aircraft/aircraft.c b/Aircraft/aircraft.c index e19a08186..097f96084 100644 --- a/Aircraft/aircraft.c +++ b/Aircraft/aircraft.c @@ -27,7 +27,7 @@ #include #include "aircraft.h" -#include "../constants.h" +#include "../Include/constants.h" /* This is a record containing all the info for the aircraft currently @@ -53,10 +53,14 @@ void fgAircraftOutputCurrent(struct fgAIRCRAFT *a) { /* $Log$ -/* Revision 1.12 1997/12/10 22:37:37 curt -/* Prepended "fg" on the name of all global structures that didn't have it yet. -/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}" +/* Revision 1.13 1997/12/15 23:54:30 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.12 1997/12/10 22:37:37 curt + * Prepended "fg" on the name of all global structures that didn't have it yet. + * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" + * * Revision 1.11 1997/09/13 02:00:05 curt * Mostly working on stars and generating sidereal time for accurate star * placement. diff --git a/Aircraft/depend b/Aircraft/depend index 5de52b7c6..24540f83c 100644 --- a/Aircraft/depend +++ b/Aircraft/depend @@ -1,4 +1,4 @@ aircraft.o: aircraft.c aircraft.h ../Flight/flight.h \ ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ ../Flight/LaRCsim/../flight.h ../Controls/controls.h \ - ../Controls/../limits.h ../constants.h + ../Controls/../Include/limits.h ../Include/constants.h diff --git a/Cockpit/cockpit.c b/Cockpit/cockpit.c index bef2cbf37..93774f546 100644 --- a/Cockpit/cockpit.c +++ b/Cockpit/cockpit.c @@ -29,7 +29,7 @@ #include #include "cockpit.h" -#include "../constants.h" +#include "../Include/constants.h" #include "../Aircraft/aircraft.h" #include "../Scenery/mesh.h" @@ -87,10 +87,14 @@ void fgCockpitUpdate() /* $Log$ -/* Revision 1.2 1997/12/10 22:37:38 curt -/* Prepended "fg" on the name of all global structures that didn't have it yet. -/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}" +/* Revision 1.3 1997/12/15 23:54:33 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.2 1997/12/10 22:37:38 curt + * Prepended "fg" on the name of all global structures that didn't have it yet. + * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" + * * Revision 1.1 1997/08/29 18:03:20 curt * Initial revision. * diff --git a/Cockpit/depend b/Cockpit/depend index a271456de..1e0cb8cc7 100644 --- a/Cockpit/depend +++ b/Cockpit/depend @@ -3,28 +3,28 @@ cockpit.o: cockpit.c cockpit.h hud.h ../Aircraft/aircraft.h \ ../Aircraft/../Flight/LaRCsim/ls_interface.h \ ../Aircraft/../Flight/LaRCsim/../flight.h \ ../Aircraft/../Controls/controls.h \ - ../Aircraft/../Controls/../limits.h ../Flight/flight.h \ - ../Controls/controls.h ../constants.h ../Scenery/mesh.h \ - ../Scenery/scenery.h ../Scenery/../types.h ../Math/mat3.h \ - ../Math/polar.h ../Math/../types.h ../Time/fg_timer.h \ + ../Aircraft/../Controls/../Include/limits.h ../Flight/flight.h \ + ../Controls/controls.h ../Include/constants.h ../Scenery/mesh.h \ + ../Scenery/scenery.h ../Scenery/../Include/types.h ../Math/mat3.h \ + ../Math/polar.h ../Math/../Include/types.h ../Time/fg_timer.h \ ../Math/fg_random.h ../Weather/weather.h hud.o: hud.c hud.h ../Aircraft/aircraft.h \ ../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \ ../Aircraft/../Flight/LaRCsim/ls_interface.h \ ../Aircraft/../Flight/LaRCsim/../flight.h \ ../Aircraft/../Controls/controls.h \ - ../Aircraft/../Controls/../limits.h ../Flight/flight.h \ - ../Controls/controls.h ../constants.h ../Scenery/mesh.h \ - ../Scenery/scenery.h ../Scenery/../types.h ../Math/mat3.h \ - ../Math/polar.h ../Math/../types.h ../Time/fg_timer.h \ + ../Aircraft/../Controls/../Include/limits.h ../Flight/flight.h \ + ../Controls/controls.h ../Include/constants.h ../Scenery/mesh.h \ + ../Scenery/scenery.h ../Scenery/../Include/types.h ../Math/mat3.h \ + ../Math/polar.h ../Math/../Include/types.h ../Time/fg_timer.h \ ../Math/fg_random.h ../Weather/weather.h test.o: test.c test.h ../Aircraft/aircraft.h \ ../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \ ../Aircraft/../Flight/LaRCsim/ls_interface.h \ ../Aircraft/../Flight/LaRCsim/../flight.h \ ../Aircraft/../Controls/controls.h \ - ../Aircraft/../Controls/../limits.h ../Flight/flight.h \ - ../Controls/controls.h ../constants.h ../Scenery/mesh.h \ - ../Scenery/scenery.h ../Scenery/../types.h ../Math/mat3.h \ - ../Math/polar.h ../Math/../types.h ../Time/fg_timer.h \ + ../Aircraft/../Controls/../Include/limits.h ../Flight/flight.h \ + ../Controls/controls.h ../Include/constants.h ../Scenery/mesh.h \ + ../Scenery/scenery.h ../Scenery/../Include/types.h ../Math/mat3.h \ + ../Math/polar.h ../Math/../Include/types.h ../Time/fg_timer.h \ ../Math/fg_random.h ../Weather/weather.h diff --git a/Cockpit/hud.c b/Cockpit/hud.c index 37bf6d4a0..ce189c1d3 100644 --- a/Cockpit/hud.c +++ b/Cockpit/hud.c @@ -31,7 +31,7 @@ #endif /* not WIN32 */ #include "hud.h" -#include "../constants.h" +#include "../Include/constants.h" #include "../Aircraft/aircraft.h" #include "../Scenery/mesh.h" @@ -807,10 +807,14 @@ void fgUpdateHUD( Hptr hud ) /* $Log$ -/* Revision 1.5 1997/12/10 22:37:39 curt -/* Prepended "fg" on the name of all global structures that didn't have it yet. -/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}" +/* Revision 1.6 1997/12/15 23:54:34 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.5 1997/12/10 22:37:39 curt + * Prepended "fg" on the name of all global structures that didn't have it yet. + * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" + * * Revision 1.4 1997/09/23 00:29:32 curt * Tweaks to get things to compile with gcc-win32. * diff --git a/Controls/controls.h b/Controls/controls.h index cf4b8a6a6..6a03028eb 100644 --- a/Controls/controls.h +++ b/Controls/controls.h @@ -28,7 +28,7 @@ #define CONTROLS_H -#include "../limits.h" +#include "../Include/limits.h" /* Define a structure containing the control parameters */ @@ -81,10 +81,14 @@ void fgThrottleSet(int engine, double pos); /* $Log$ -/* Revision 1.6 1997/12/10 22:37:41 curt -/* Prepended "fg" on the name of all global structures that didn't have it yet. -/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}" +/* Revision 1.7 1997/12/15 23:54:36 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.6 1997/12/10 22:37:41 curt + * Prepended "fg" on the name of all global structures that didn't have it yet. + * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" + * * Revision 1.5 1997/08/27 03:30:02 curt * Changed naming scheme of basic shared structures. * diff --git a/Controls/depend b/Controls/depend index b3cba7d64..2500b06dc 100644 --- a/Controls/depend +++ b/Controls/depend @@ -1,5 +1,6 @@ -controls.o: controls.c controls.h ../limits.h ../Aircraft/aircraft.h \ - ../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \ +controls.o: controls.c controls.h ../Include/limits.h \ + ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \ + ../Aircraft/../Flight/Slew/slew.h \ ../Aircraft/../Flight/LaRCsim/ls_interface.h \ ../Aircraft/../Flight/LaRCsim/../flight.h \ ../Aircraft/../Controls/controls.h diff --git a/LaRCsim/depend b/LaRCsim/depend index 6a3fc39dc..b38be84dd 100644 --- a/LaRCsim/depend +++ b/LaRCsim/depend @@ -12,7 +12,7 @@ ls_interface.o: ls_interface.c ls_types.h ls_constants.h ls_generic.h \ ../Slew/slew.h ../LaRCsim/ls_interface.h ../../Aircraft/aircraft.h \ ../../Aircraft/../Flight/flight.h \ ../../Aircraft/../Controls/controls.h \ - ../../Aircraft/../Controls/../limits.h + ../../Aircraft/../Controls/../Include/limits.h ls_model.o: ls_model.c ls_types.h ls_step.o: ls_step.c ls_types.h ls_constants.h ls_generic.h ls_sync.o: ls_sync.c ls_types.h ls_sim_control.h diff --git a/Main/GLUTkey.c b/Main/GLUTkey.c index 22442cb86..66f139b75 100644 --- a/Main/GLUTkey.c +++ b/Main/GLUTkey.c @@ -29,12 +29,13 @@ #endif #include +#include "../XGL/xgl.h" #include #include "GLUTkey.h" #include "views.h" -#include "../constants.h" +#include "../Include/constants.h" #include "../Aircraft/aircraft.h" #include "../Weather/weather.h" @@ -87,7 +88,7 @@ void GLUTkey(unsigned char k, int x, int y) { return; case 90: /* Z key */ w->visibility /= 1.10; - glFogf(GL_FOG_END, w->visibility); + xglFogf(GL_FOG_END, w->visibility); printf("Fog density = %.4f\n", w->visibility); return; } @@ -131,7 +132,7 @@ void GLUTkey(unsigned char k, int x, int y) { return; case 122: /* z key */ w->visibility *= 1.10; - glFogf(GL_FOG_END, w->visibility); + xglFogf(GL_FOG_END, w->visibility); printf("Fog density = %.4f\n", w->visibility); return; case 27: /* ESC */ @@ -224,10 +225,14 @@ void GLUTspecialkey(int k, int x, int y) { /* $Log$ -/* Revision 1.22 1997/12/10 22:37:45 curt -/* Prepended "fg" on the name of all global structures that didn't have it yet. -/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}" +/* Revision 1.23 1997/12/15 23:54:44 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.22 1997/12/10 22:37:45 curt + * Prepended "fg" on the name of all global structures that didn't have it yet. + * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" + * * Revision 1.21 1997/08/27 21:32:23 curt * Restructured view calculation code. Added stars. * diff --git a/Main/GLUTmain.c b/Main/GLUTmain.c index 7f74979f6..da730f6d4 100644 --- a/Main/GLUTmain.c +++ b/Main/GLUTmain.c @@ -29,14 +29,15 @@ #endif #include +#include "../XGL/xgl.h" #include #include "GLUTkey.h" #include "fg_init.h" #include "views.h" -#include "../constants.h" -#include "../general.h" +#include "../Include/constants.h" +#include "../Include/general.h" #include "../Aircraft/aircraft.h" #include "../Cockpit/cockpit.h" @@ -87,32 +88,32 @@ static void fgInitVisuals() { t = &cur_time_params; w = ¤t_weather; - glEnable( GL_DEPTH_TEST ); - /* glFrontFace(GL_CW); */ - glEnable( GL_CULL_FACE ); + xglEnable( GL_DEPTH_TEST ); + /* xglFrontFace(GL_CW); */ + xglEnable( GL_CULL_FACE ); - /* glDisable( GL_DITHER ); */ + /* xglDisable( GL_DITHER ); */ /* If enabled, normal vectors specified with glNormal are scaled to unit length after transformation. See glNormal. */ - glEnable( GL_NORMALIZE ); + xglEnable( GL_NORMALIZE ); - glEnable( GL_LIGHTING ); - glEnable( GL_LIGHT0 ); - glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec ); + xglEnable( GL_LIGHTING ); + xglEnable( GL_LIGHT0 ); + xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec ); - glShadeModel( GL_FLAT ); /* glShadeModel( GL_SMOOTH ); */ + xglShadeModel( GL_FLAT ); /* xglShadeModel( GL_SMOOTH ); */ - glEnable( GL_FOG ); - glFogi (GL_FOG_MODE, GL_LINEAR); - /* glFogf (GL_FOG_START, 1.0); */ - glFogf (GL_FOG_END, w->visibility); - glFogfv (GL_FOG_COLOR, fgFogColor); - /* glFogf (GL_FOG_DENSITY, w->visibility); */ - /* glHint (GL_FOG_HINT, GL_FASTEST); */ + xglEnable( GL_FOG ); + xglFogi (GL_FOG_MODE, GL_LINEAR); + /* xglFogf (GL_FOG_START, 1.0); */ + xglFogf (GL_FOG_END, w->visibility); + xglFogfv (GL_FOG_COLOR, fgFogColor); + /* xglFogf (GL_FOG_DENSITY, w->visibility); */ + /* xglHint (GL_FOG_HINT, GL_FASTEST); */ /* initial screen color */ - glClearColor(0.0, 0.0, 0.0, 1.0); + xglClearColor(0.0, 0.0, 0.0, 1.0); } @@ -141,22 +142,22 @@ static void fgUpdateViewParams() { fgViewUpdate(f, v); /* Tell GL we are about to modify the projection parameters */ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); + xglMatrixMode(GL_PROJECTION); + xglLoadIdentity(); gluPerspective(55.0, 1.0/win_ratio, 1.0, 200000.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + xglMatrixMode(GL_MODELVIEW); + xglLoadIdentity(); /* set up our view volume */ 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]); + 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]); /* set the sun position */ - glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec ); + xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec ); /* calculate lighting parameters based on sun's relative angle to * local up */ @@ -190,15 +191,15 @@ static void fgUpdateViewParams() { l->scene_diffuse[2] = white[2] * diffuse; /* set lighting parameters */ - glLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient ); - glLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse ); + xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient ); + xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse ); /* set fog color */ l->scene_fog[0] = fgFogColor[0] * (ambient + diffuse); l->scene_fog[1] = fgFogColor[1] * (ambient + diffuse); l->scene_fog[2] = fgFogColor[2] * (ambient + diffuse); l->scene_fog[3] = fgFogColor[3]; - glFogfv (GL_FOG_COLOR, l->scene_fog); + xglFogfv (GL_FOG_COLOR, l->scene_fog); /* set sky color */ l->scene_clear[0] = sky_color[0] * sky_brightness; @@ -206,8 +207,8 @@ static void fgUpdateViewParams() { l->scene_clear[2] = sky_color[2] * sky_brightness; l->scene_clear[3] = sky_color[3]; - glClearColor(l->scene_clear[0], l->scene_clear[1], - l->scene_clear[2], l->scene_clear[3]); + xglClearColor(l->scene_clear[0], l->scene_clear[1], + l->scene_clear[2], l->scene_clear[3]); } @@ -219,11 +220,11 @@ static void fgUpdateVisuals( void ) { /* update view volume parameters */ fgUpdateViewParams(); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + xglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); /* Tell GL we are switching to model view parameters */ - glMatrixMode(GL_MODELVIEW); - /* glLoadIdentity(); */ + xglMatrixMode(GL_MODELVIEW); + /* xglLoadIdentity(); */ /* draw scenery */ fgSceneryRender(); @@ -236,7 +237,7 @@ static void fgUpdateVisuals( void ) { fgCockpitUpdate(); #ifdef GLUT - glutSwapBuffers(); + xglutSwapBuffers(); #endif } @@ -335,38 +336,38 @@ void fgInitTimeDepCalcs() { int num_lines = 16; float line_len, line_width_2, cur_pos; - runway = glGenLists(1); - glNewList(runway, GL_COMPILE); + runway = xglGenLists(1); + xglNewList(runway, GL_COMPILE); */ /* draw concrete */ -/* glBegin(GL_POLYGON); - glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, concrete ); - glNormal3f(0.0, 0.0, 1.0); - - glVertex3d( 0.0, -width/2.0, 0.0); - glVertex3d( 0.0, width/2.0, 0.0); - glVertex3d(length, width/2.0, 0.0); - glVertex3d(length, -width/2.0, 0.0); - glEnd(); +/* xglBegin(GL_POLYGON); + xglMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, concrete ); + xglNormal3f(0.0, 0.0, 1.0); + + xglVertex3d( 0.0, -width/2.0, 0.0); + xglVertex3d( 0.0, width/2.0, 0.0); + xglVertex3d(length, width/2.0, 0.0); + xglVertex3d(length, -width/2.0, 0.0); + xglEnd(); */ /* draw center line */ -/* glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, line ); +/* xglMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, line ); line_len = length / ( 2 * num_lines + 1); printf("line_len = %.3f\n", line_len); line_width_2 = 0.02; cur_pos = line_len; for ( i = 0; i < num_lines; i++ ) { - glBegin(GL_POLYGON); - glVertex3d( cur_pos, -line_width_2, 0.005); - glVertex3d( cur_pos, line_width_2, 0.005); + xglBegin(GL_POLYGON); + xglVertex3d( cur_pos, -line_width_2, 0.005); + xglVertex3d( cur_pos, line_width_2, 0.005); cur_pos += line_len; - glVertex3d( cur_pos, line_width_2, 0.005); - glVertex3d( cur_pos, -line_width_2, 0.005); + xglVertex3d( cur_pos, line_width_2, 0.005); + xglVertex3d( cur_pos, -line_width_2, 0.005); cur_pos += line_len; - glEnd(); + xglEnd(); } - glEndList(); + xglEndList(); return(runway); } @@ -376,17 +377,17 @@ void fgInitTimeDepCalcs() { /*static void fgSceneryDraw_OLD() { static float z = 32.35; - glPushMatrix(); + xglPushMatrix(); - glCallList(scenery); + xglCallList(scenery); printf("*** Drawing runway at %.2f\n", z); - glTranslatef( -398391.28, 120070.41, 32.35); - glRotatef(170.0, 0.0, 0.0, 1.0); - glCallList(runway); + xglTranslatef( -398391.28, 120070.41, 32.35); + xglRotatef(170.0, 0.0, 0.0, 1.0); + xglCallList(runway); - glPopMatrix(); + xglPopMatrix(); } */ @@ -475,11 +476,11 @@ static void fgReshape( int width, int height ) { } /* Inform gl of our view window size */ - glViewport(0, 0, (GLint)width, (GLint)height); + xglViewport(0, 0, (GLint)width, (GLint)height); fgUpdateViewParams(); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + xglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); } @@ -500,16 +501,16 @@ int main( int argc, char *argv[] ) { #ifdef GLUT /* initialize GLUT */ - glutInit(&argc, argv); + xglutInit(&argc, argv); /* Define Display Parameters */ - glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); + xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); /* Define initial window size */ - glutInitWindowSize(640, 480); + xglutInitWindowSize(640, 480); /* Initialize windows */ - glutCreateWindow("Flight Gear"); + xglutCreateWindow("Flight Gear"); #endif /* This is the general house keeping init routine */ @@ -536,17 +537,17 @@ int main( int argc, char *argv[] ) { #ifdef GLUT /* call fgReshape() on window resizes */ - glutReshapeFunc( fgReshape ); + xglutReshapeFunc( fgReshape ); /* call key() on keyboard event */ - glutKeyboardFunc( GLUTkey ); + xglutKeyboardFunc( GLUTkey ); glutSpecialFunc( GLUTspecialkey ); /* call fgMainLoop() whenever there is nothing else to do */ - glutIdleFunc( fgMainLoop ); + xglutIdleFunc( fgMainLoop ); /* draw the scene */ - glutDisplayFunc( fgUpdateVisuals ); + xglutDisplayFunc( fgUpdateVisuals ); /* pass control off to the GLUT event handler */ glutMainLoop(); @@ -564,9 +565,13 @@ int main( int argc, char *argv[] ) { /* $Log$ -/* Revision 1.32 1997/12/15 20:59:08 curt -/* Misc. tweaks. +/* Revision 1.33 1997/12/15 23:54:45 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.32 1997/12/15 20:59:08 curt + * Misc. tweaks. + * * Revision 1.31 1997/12/12 21:41:25 curt * More light/material property tweaking ... still a ways off. * diff --git a/Main/Makefile b/Main/Makefile index 2a0d40dae..d1a06e158 100644 --- a/Main/Makefile +++ b/Main/Makefile @@ -30,14 +30,14 @@ AFILES = ../Aircraft/libAircraft.a ../Cockpit/libCockpit.a \ ../Controls/libControls.a ../Flight/libFlight.a \ ../Joystick/libJoystick.a ../Flight/LaRCsim/libLaRCsim.a \ ../Flight/Slew/libSlew.a ../Scenery/libScenery.a \ - ../Time/libTime.a ../Weather/libWeather.a ../Math/libMath.a + ../Time/libTime.a ../Weather/libWeather.a ../Math/libMath.a \ include ../make.inc CFLAGS = $(FG_CFLAGS) $(INTERFACE_FLAGS) -LIBS = $(INTERFACE_LIBS) $(GRAPHICS_LIBS) -lm -lfl +LIBS = $(FG_DEBUG_LIBS) $(INTERFACE_LIBS) $(GRAPHICS_LIBS) -lm -lfl TARGET=fg-$(FG_VERSION) @@ -83,6 +83,10 @@ views.o: #--------------------------------------------------------------------------- # $Log$ +# Revision 1.38 1997/12/15 23:54:47 curt +# Add xgl wrappers for debugging. +# Generate terrain normals on the fly. +# # Revision 1.37 1997/12/12 21:41:26 curt # More light/material property tweaking ... still a ways off. # diff --git a/Main/depend b/Main/depend index 448926188..0fac299af 100644 --- a/Main/depend +++ b/Main/depend @@ -1,36 +1,39 @@ -GLUTkey.o: GLUTkey.c GLUTkey.h views.h ../types.h ../Flight/flight.h \ - ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ - ../Flight/LaRCsim/../flight.h ../Math/mat3.h ../constants.h \ - ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \ - ../Aircraft/../Controls/controls.h \ - ../Aircraft/../Controls/../limits.h ../Weather/weather.h -GLUTmain.o: GLUTmain.c GLUTkey.h fg_init.h views.h ../types.h \ +GLUTkey.o: GLUTkey.c GLUTkey.h views.h ../Include/types.h \ ../Flight/flight.h ../Flight/Slew/slew.h \ ../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \ - ../Math/mat3.h ../constants.h ../general.h ../Aircraft/aircraft.h \ + ../Math/mat3.h ../Include/constants.h ../Aircraft/aircraft.h \ ../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \ - ../Aircraft/../Controls/../limits.h ../Cockpit/cockpit.h \ + ../Aircraft/../Controls/../Include/limits.h ../Weather/weather.h +GLUTmain.o: GLUTmain.c GLUTkey.h fg_init.h views.h ../Include/types.h \ + ../Flight/flight.h ../Flight/Slew/slew.h \ + ../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \ + ../Math/mat3.h ../Include/constants.h ../Include/general.h \ + ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \ + ../Aircraft/../Controls/controls.h \ + ../Aircraft/../Controls/../Include/limits.h ../Cockpit/cockpit.h \ ../Cockpit/hud.h ../Cockpit/../Aircraft/aircraft.h \ ../Cockpit/../Flight/flight.h ../Cockpit/../Controls/controls.h \ ../Joystick/joystick.h ../Math/fg_geodesy.h ../Math/polar.h \ - ../Math/../types.h ../Scenery/mesh.h ../Scenery/scenery.h \ - ../Scenery/../types.h ../Time/fg_time.h ../Time/../types.h \ - ../Time/../Flight/flight.h ../Time/fg_timer.h ../Time/sunpos.h \ - ../Weather/weather.h -fg_init.o: fg_init.c fg_init.h views.h ../types.h ../Flight/flight.h \ - ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ - ../Flight/LaRCsim/../flight.h ../Math/mat3.h ../constants.h \ - ../general.h ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \ + ../Math/../Include/types.h ../Scenery/mesh.h ../Scenery/scenery.h \ + ../Scenery/../Include/types.h ../Time/fg_time.h \ + ../Time/../Include/types.h ../Time/../Flight/flight.h \ + ../Time/fg_timer.h ../Time/sunpos.h ../Weather/weather.h +fg_init.o: fg_init.c fg_init.h views.h ../Include/types.h \ + ../Flight/flight.h ../Flight/Slew/slew.h \ + ../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \ + ../Math/mat3.h ../Include/constants.h ../Include/general.h \ + ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \ ../Aircraft/../Controls/controls.h \ - ../Aircraft/../Controls/../limits.h ../Cockpit/cockpit.h \ + ../Aircraft/../Controls/../Include/limits.h ../Cockpit/cockpit.h \ ../Cockpit/hud.h ../Cockpit/../Aircraft/aircraft.h \ ../Cockpit/../Flight/flight.h ../Cockpit/../Controls/controls.h \ ../Joystick/joystick.h ../Math/fg_random.h ../Scenery/mesh.h \ ../Scenery/astro.h ../Scenery/stars.h ../Scenery/scenery.h \ - ../Scenery/../types.h ../Time/fg_time.h ../Time/../types.h \ - ../Time/../Flight/flight.h ../Time/sunpos.h ../Weather/weather.h -views.o: views.c views.h ../types.h ../Flight/flight.h \ + ../Scenery/../Include/types.h ../Time/fg_time.h \ + ../Time/../Include/types.h ../Time/../Flight/flight.h \ + ../Time/sunpos.h ../Weather/weather.h +views.o: views.c views.h ../Include/types.h ../Flight/flight.h \ ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ - ../Flight/LaRCsim/../flight.h ../Math/mat3.h ../constants.h \ - ../Math/polar.h ../Math/../types.h ../Scenery/scenery.h \ - ../Scenery/../types.h + ../Flight/LaRCsim/../flight.h ../Math/mat3.h ../Include/constants.h \ + ../Math/polar.h ../Math/../Include/types.h ../Scenery/scenery.h \ + ../Scenery/../Include/types.h diff --git a/Main/fg_init.c b/Main/fg_init.c index afbc2fb87..7edcb27ce 100644 --- a/Main/fg_init.c +++ b/Main/fg_init.c @@ -30,8 +30,8 @@ #include "fg_init.h" #include "views.h" -#include "../constants.h" -#include "../general.h" +#include "../Include/constants.h" +#include "../Include/general.h" #include "../Aircraft/aircraft.h" #include "../Cockpit/cockpit.h" @@ -218,9 +218,13 @@ void fgInitSubsystems( void ) { /* $Log$ -/* Revision 1.17 1997/12/15 20:59:09 curt -/* Misc. tweaks. +/* Revision 1.18 1997/12/15 23:54:49 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.17 1997/12/15 20:59:09 curt + * Misc. tweaks. + * * Revision 1.16 1997/12/12 19:52:48 curt * Working on lightling and material properties. * diff --git a/Main/views.c b/Main/views.c index 91ec51685..96cdc71bf 100644 --- a/Main/views.c +++ b/Main/views.c @@ -26,7 +26,7 @@ #include "views.h" -#include "../constants.h" +#include "../Include/constants.h" #include "../Flight/flight.h" #include "../Math/mat3.h" @@ -133,10 +133,14 @@ void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v) { /* $Log$ -/* Revision 1.2 1997/12/10 22:37:48 curt -/* Prepended "fg" on the name of all global structures that didn't have it yet. -/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}" +/* Revision 1.3 1997/12/15 23:54:50 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.2 1997/12/10 22:37:48 curt + * Prepended "fg" on the name of all global structures that didn't have it yet. + * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" + * * Revision 1.1 1997/08/27 21:31:17 curt * Initial revision. * diff --git a/Main/views.h b/Main/views.h index 6df74ec5f..9dc0bfff4 100644 --- a/Main/views.h +++ b/Main/views.h @@ -28,7 +28,7 @@ #define VIEWS_H -#include "../types.h" +#include "../Include/types.h" #include "../Flight/flight.h" #include "../Math/mat3.h" @@ -55,10 +55,14 @@ void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v); /* $Log$ -/* Revision 1.2 1997/12/10 22:37:48 curt -/* Prepended "fg" on the name of all global structures that didn't have it yet. -/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}" +/* Revision 1.3 1997/12/15 23:54:51 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.2 1997/12/10 22:37:48 curt + * Prepended "fg" on the name of all global structures that didn't have it yet. + * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" + * * Revision 1.1 1997/08/27 21:31:18 curt * Initial revision. * diff --git a/Scenery/astro.c b/Scenery/astro.c index 6bd4e0d2c..411fd6b14 100644 --- a/Scenery/astro.c +++ b/Scenery/astro.c @@ -29,6 +29,7 @@ #include #include +#include "../XGL/xgl.h" #include "astro.h" #include "moon.h" @@ -37,8 +38,8 @@ #include "stars.h" #include "sun.h" -#include "../constants.h" -#include "../general.h" +#include "../Include/constants.h" +#include "../Include/general.h" #include "../Main/views.h" #include "../Aircraft/aircraft.h" @@ -87,22 +88,22 @@ void fgAstroRender() { } /* Disable fog effects */ - glDisable( GL_FOG ); + xglDisable( GL_FOG ); /* set the sun position */ - glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec_inv ); + xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec_inv ); - glPushMatrix(); + xglPushMatrix(); /* Translate to view position */ - glTranslatef( 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 (side real time) */ angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/ #ifdef DEBUG printf("Rotating astro objects by %.2f degrees\n",angle); #endif - glRotatef( angle, 0.0, 0.0, -1.0 ); + xglRotatef( angle, 0.0, 0.0, -1.0 ); /* render the moon */ fgMoonRender(); @@ -113,17 +114,21 @@ void fgAstroRender() { /* render the sun */ fgSunRender(); - glPopMatrix(); + xglPopMatrix(); /* reenable fog effects */ - glEnable( GL_FOG ); + xglEnable( GL_FOG ); } /* $Log$ -/* Revision 1.7 1997/12/15 20:59:09 curt -/* Misc. tweaks. +/* Revision 1.8 1997/12/15 23:54:57 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.7 1997/12/15 20:59:09 curt + * Misc. tweaks. + * * Revision 1.6 1997/12/12 21:41:27 curt * More light/material property tweaking ... still a ways off. * diff --git a/Scenery/depend b/Scenery/depend index 38498f397..86a023475 100644 --- a/Scenery/depend +++ b/Scenery/depend @@ -1,46 +1,48 @@ astro.o: astro.c astro.h stars.h moon.h orbits.h ../Time/fg_time.h \ - ../Time/../types.h ../Time/../Flight/flight.h \ + ../Time/../Include/types.h ../Time/../Flight/flight.h \ ../Time/../Flight/Slew/slew.h \ ../Time/../Flight/LaRCsim/ls_interface.h \ - ../Time/../Flight/LaRCsim/../flight.h planets.h sun.h ../constants.h \ - ../general.h ../Main/views.h ../Main/../types.h \ - ../Main/../Flight/flight.h ../Main/../Math/mat3.h \ - ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \ - ../Aircraft/../Controls/controls.h \ - ../Aircraft/../Controls/../limits.h + ../Time/../Flight/LaRCsim/../flight.h planets.h sun.h \ + ../Include/constants.h ../Include/general.h ../Main/views.h \ + ../Main/../Include/types.h ../Main/../Flight/flight.h \ + ../Main/../Math/mat3.h ../Aircraft/aircraft.h \ + ../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \ + ../Aircraft/../Controls/../Include/limits.h common.o: common.c common.h geometry.o: geometry.c geometry.h mesh.h -mesh.o: mesh.c ../constants.h ../types.h ../Math/fg_geodesy.h \ - ../Math/fg_random.h ../Math/mat3.h ../Math/polar.h ../Math/../types.h \ - mesh.h common.h scenery.h -moon.o: moon.c orbits.h ../Time/fg_time.h ../Time/../types.h \ +mesh.o: mesh.c ../Include/constants.h ../Include/types.h \ + ../Math/fg_geodesy.h ../Math/fg_random.h ../Math/mat3.h \ + ../Math/polar.h ../Math/../Include/types.h mesh.h common.h scenery.h +moon.o: moon.c orbits.h ../Time/fg_time.h ../Time/../Include/types.h \ ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ ../Time/../Flight/LaRCsim/ls_interface.h \ - ../Time/../Flight/LaRCsim/../flight.h moon.h ../general.h \ - ../Main/views.h ../Main/../types.h ../Main/../Flight/flight.h \ + ../Time/../Flight/LaRCsim/../flight.h moon.h ../Include/general.h \ + ../Main/views.h ../Main/../Include/types.h ../Main/../Flight/flight.h \ ../Main/../Math/mat3.h -obj.o: obj.c obj.h scenery.h ../types.h ../Math/mat3.h -orbits.o: orbits.c orbits.h ../Time/fg_time.h ../Time/../types.h \ - ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ +obj.o: obj.c obj.h scenery.h ../Include/types.h ../Math/mat3.h +orbits.o: orbits.c orbits.h ../Time/fg_time.h \ + ../Time/../Include/types.h ../Time/../Flight/flight.h \ + ../Time/../Flight/Slew/slew.h \ ../Time/../Flight/LaRCsim/ls_interface.h \ - ../Time/../Flight/LaRCsim/../flight.h ../general.h -planets.o: planets.c ../Time/fg_time.h ../Time/../types.h \ + ../Time/../Flight/LaRCsim/../flight.h ../Include/general.h +planets.o: planets.c ../Time/fg_time.h ../Time/../Include/types.h \ ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ ../Time/../Flight/LaRCsim/ls_interface.h \ ../Time/../Flight/LaRCsim/../flight.h orbits.h planets.h sun.h -scenery.o: scenery.c ../general.h astro.h stars.h obj.h scenery.h \ - ../types.h -stars.o: stars.c orbits.h ../Time/fg_time.h ../Time/../types.h \ +scenery.o: scenery.c ../Include/general.h astro.h stars.h obj.h \ + scenery.h ../Include/types.h +stars.o: stars.c orbits.h ../Time/fg_time.h ../Time/../Include/types.h \ ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ ../Time/../Flight/LaRCsim/ls_interface.h \ ../Time/../Flight/LaRCsim/../flight.h planets.h stars.h \ - ../constants.h ../general.h ../Aircraft/aircraft.h \ + ../Include/constants.h ../Include/general.h ../Aircraft/aircraft.h \ ../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \ - ../Aircraft/../Controls/../limits.h ../Main/views.h \ - ../Main/../types.h ../Main/../Flight/flight.h ../Main/../Math/mat3.h -sun.o: sun.c ../Time/fg_time.h ../Time/../types.h \ + ../Aircraft/../Controls/../Include/limits.h ../Main/views.h \ + ../Main/../Include/types.h ../Main/../Flight/flight.h \ + ../Main/../Math/mat3.h +sun.o: sun.c ../Time/fg_time.h ../Time/../Include/types.h \ ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ ../Time/../Flight/LaRCsim/ls_interface.h \ ../Time/../Flight/LaRCsim/../flight.h ../Main/views.h \ - ../Main/../types.h ../Main/../Flight/flight.h ../Main/../Math/mat3.h \ - orbits.h sun.h + ../Main/../Include/types.h ../Main/../Flight/flight.h \ + ../Main/../Math/mat3.h orbits.h sun.h diff --git a/Scenery/mesh.c b/Scenery/mesh.c index 595c23287..c2535a32e 100644 --- a/Scenery/mesh.c +++ b/Scenery/mesh.c @@ -38,8 +38,8 @@ #include -#include "../constants.h" -#include "../types.h" +#include "../Include/constants.h" +#include "../Include/types.h" #include "../Math/fg_geodesy.h" #include "../Math/fg_random.h" #include "../Math/mat3.h" @@ -396,9 +396,13 @@ GLint mesh_to_OpenGL(struct MESH *m) { /* $Log$ -/* Revision 1.23 1997/10/30 12:38:44 curt -/* Working on new scenery subsystem. +/* Revision 1.24 1997/12/15 23:54:59 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.23 1997/10/30 12:38:44 curt + * Working on new scenery subsystem. + * * Revision 1.22 1997/10/28 21:00:21 curt * Changing to new terrain format. * diff --git a/Scenery/moon.c b/Scenery/moon.c index e72404f9e..ac97aa94e 100644 --- a/Scenery/moon.c +++ b/Scenery/moon.c @@ -23,11 +23,12 @@ #include #include +#include "../XGL/xgl.h" #include "orbits.h" #include "moon.h" -#include "../general.h" +#include "../Include/general.h" #include "../Main/views.h" #include "../Time/fg_time.h" @@ -72,15 +73,15 @@ void NormalizeVector(float v[3]) void drawTriangle(float *v1, float *v2, float *v3) { - glBegin(GL_POLYGON); - //glBegin(GL_POINTS); - glNormal3fv(v1); - glVertex3fv(v1); - glNormal3fv(v2); - glVertex3fv(v2); - glNormal3fv(v3); - glVertex3fv(v3); - glEnd(); + xglBegin(GL_POLYGON); + //xglBegin(GL_POINTS); + xglNormal3fv(v1); + xglVertex3fv(v1); + xglNormal3fv(v2); + xglVertex3fv(v2); + xglNormal3fv(v3); + xglVertex3fv(v3); + xglEnd(); } void subdivide(float *v1, float *v2, float *v3, long depth) @@ -112,17 +113,17 @@ void subdivide(float *v1, float *v2, float *v3, long depth) void display(void) { int i; - glClear(GL_COLOR_BUFFER_BIT); - glPushMatrix(); - glRotatef(spin, 0.0, 0.0, 0.0); - glColor3f(1.0, 1.0, 0.0); -// glBegin(GL_LINE_LOOP); + xglClear(GL_COLOR_BUFFER_BIT); + xglPushMatrix(); + xglRotatef(spin, 0.0, 0.0, 0.0); + xglColor3f(1.0, 1.0, 0.0); +// xglBegin(GL_LINE_LOOP); for (i = 0; i < 20; i++) { - //glVertex3fv(&vdata[tindices[i][0]][0]); - //glVertex3fv(&vdata[tindices[i][1]][0]); - //glVertex3fv(&vdata[tindices[i][2]][0]); + //xglVertex3fv(&vdata[tindices[i][0]][0]); + //xglVertex3fv(&vdata[tindices[i][1]][0]); + //xglVertex3fv(&vdata[tindices[i][2]][0]); subdivide(&vdata[tindices[i][0]][0], &vdata[tindices[i][1]][0], @@ -130,9 +131,9 @@ void display(void) } -// glEnd(); - // glFlush(); - glPopMatrix(); +// xglEnd(); + // xglFlush(); + xglPopMatrix(); glutSwapBuffers(); } */ @@ -230,11 +231,11 @@ void fgMoonInit() { l = &cur_light_params; - moon = glGenLists(1); - glNewList(moon, GL_COMPILE ); + moon = xglGenLists(1); + xglNewList(moon, GL_COMPILE ); - /* glMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear); - glMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); */ + /* xglMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear); + xglMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); */ fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params); moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0], @@ -254,7 +255,7 @@ void fgMoonInit() { glutSolidSphere(1.0, 15, 15); - glEndList(); + xglEndList(); } @@ -267,21 +268,21 @@ void fgMoonRender() { l = &cur_light_params; /* set lighting parameters */ - glLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_clear ); - glLightfv(GL_LIGHT0, GL_DIFFUSE, moon_color ); + xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_clear ); + xglLightfv(GL_LIGHT0, GL_DIFFUSE, moon_color ); - glMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear ); - glMaterialfv(GL_FRONT, GL_AMBIENT, moon_color ); - glMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); + xglMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear ); + xglMaterialfv(GL_FRONT, GL_AMBIENT, moon_color ); + xglMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); - glPushMatrix(); - glTranslatef(xMoon, yMoon, zMoon); - glScalef(1400, 1400, 1400); + xglPushMatrix(); + xglTranslatef(xMoon, yMoon, zMoon); + xglScalef(1400, 1400, 1400); - glColor3fv(moon_color); + xglColor3fv(moon_color); /* glutSolidSphere(1.0, 25, 25); */ - glCallList(moon); + xglCallList(moon); - glPopMatrix(); + xglPopMatrix(); } diff --git a/Scenery/obj.c b/Scenery/obj.c index 11b12155e..0a3e53ec0 100644 --- a/Scenery/obj.c +++ b/Scenery/obj.c @@ -31,6 +31,7 @@ #include #include #include +#include "../XGL/xgl.h" #include "obj.h" #include "scenery.h" @@ -45,23 +46,40 @@ float nodes[MAXNODES][3]; float normals[MAXNODES][3]; +/* given three points defining a triangle, calculate the normal */ +void calc_normal(float p1[3], float p2[3], float p3[3], double normal[3]) +{ + double v1[3], v2[3]; + float temp; + + v1[0] = p2[0] - p1[0]; v1[1] = p2[1] - p1[1]; v1[2] = p2[2] - p1[2]; + v2[0] = p3[0] - p1[0]; v2[1] = p3[1] - p1[1]; v2[2] = p3[2] - p1[2]; + + MAT3cross_product(normal, v1, v2); + MAT3_NORMALIZE_VEC(normal,temp); + + printf(" Normal = %.2f %.2f %.2f\n", normal[0], normal[1], normal[2]); +} + + /* Load a .obj file and generate the GL call list */ GLint fgObjLoad(char *path) { - char line[256], winding[256]; + char line[256], winding_str[256]; double v1[3], v2[3], approx_normal[3], dot_prod, temp; struct fgCartesianPoint ref; GLint area; FILE *f; int first, ncount, vncount, n1, n2, n3, n4; - int i; + int i, winding; + int last1, last2, odd; if ( (f = fopen(path, "r")) == NULL ) { printf("Cannot open file: %s\n", path); exit(-1); } - area = glGenLists(1); - glNewList(area, GL_COMPILE); + area = xglGenLists(1); + xglNewList(area, GL_COMPILE); first = 1; ncount = 1; @@ -101,17 +119,19 @@ GLint fgObjLoad(char *path) { exit(-1); } } else if ( strncmp(line, "winding ", 8) == 0 ) { - sscanf(line+8, "%s", winding); - printf("WINDING = %s\n", winding); + sscanf(line+8, "%s", winding_str); + printf("WINDING = %s\n", winding_str); - /* can't call glFrontFace() between glBegin() & glEnd() */ - glEnd(); + /* can't call xglFrontFace() between xglBegin() & xglEnd() */ + xglEnd(); first = 1; - if ( strcmp(winding, "cw") == 0 ) { - glFrontFace( GL_CW ); + if ( strcmp(winding_str, "cw") == 0 ) { + xglFrontFace( GL_CW ); + winding = 0; } else { - glFrontFace ( GL_CCW ); + xglFrontFace ( GL_CCW ); + winding = 1; } } else if ( line[0] == 't' ) { /* start a new triangle strip */ @@ -120,12 +140,12 @@ GLint fgObjLoad(char *path) { if ( !first ) { /* close out the previous structure and start the next */ - glEnd(); + xglEnd(); } else { first = 0; } - /* printf("new tri strip = %s", line); */ + printf("new tri strip = %s", line); sscanf(line, "t %d %d %d %d\n", &n1, &n2, &n3, &n4); /* printf("(t) = "); */ @@ -133,7 +153,7 @@ GLint fgObjLoad(char *path) { /* try to get the proper rotation by calculating an * approximate normal and seeing if it is close to the * precalculated normal */ - /*v1[0] = nodes[n2][0] - nodes[n1][0]; + /* v1[0] = nodes[n2][0] - nodes[n1][0]; v1[1] = nodes[n2][1] - nodes[n1][1]; v1[2] = nodes[n2][2] - nodes[n1][2]; v2[0] = nodes[n3][0] - nodes[n1][0]; @@ -149,56 +169,87 @@ GLint fgObjLoad(char *path) { /* printf("Normal ANGLE = %.3f rads.\n", angle); */ /* if ( dot_prod < -0.5 ) { - glFrontFace( GL_CW ); + xglFrontFace( GL_CW ); } else { - glFrontFace( GL_CCW ); + xglFrontFace( GL_CCW ); } */ - glBegin(GL_TRIANGLE_STRIP); + xglBegin(GL_TRIANGLE_STRIP); + + if ( winding ) { + odd = 1; + } else { + odd = 0; + } + + if ( odd ) { + calc_normal(nodes[n1], nodes[n2], nodes[n3], approx_normal); + } else { + calc_normal(nodes[n2], nodes[n1], nodes[n3], approx_normal); + } + xglNormal3dv(approx_normal); - glNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]); - glVertex3d(nodes[n1][0] - ref.x, nodes[n1][1] - ref.y, - nodes[n1][2] - ref.z); + /* xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]); */ + xglVertex3d(nodes[n1][0] - ref.x, nodes[n1][1] - ref.y, + nodes[n1][2] - ref.z); - glNormal3d(normals[n2][0], normals[n2][1], normals[n2][2]); - glVertex3d(nodes[n2][0] - ref.x, nodes[n2][1] - ref.y, - nodes[n2][2] - ref.z); + /* xglNormal3d(normals[n2][0], normals[n2][1], normals[n2][2]); */ + xglVertex3d(nodes[n2][0] - ref.x, nodes[n2][1] - ref.y, + nodes[n2][2] - ref.z); - glNormal3d(normals[n3][0], normals[n3][1], normals[n3][2]); - glVertex3d(nodes[n3][0] - ref.x, nodes[n3][1] - ref.y, - nodes[n3][2] - ref.z); + /* xglNormal3d(normals[n3][0], normals[n3][1], normals[n3][2]); */ + xglVertex3d(nodes[n3][0] - ref.x, nodes[n3][1] - ref.y, + nodes[n3][2] - ref.z); + + odd = 1 - odd; + last1 = n2; + last2 = n3; if ( n4 > 0 ) { - glNormal3d(normals[n4][0], normals[n4][1], normals[n4][2]); - glVertex3d(nodes[n4][0] - ref.x, nodes[n4][1] - ref.y, - nodes[n4][2] - ref.z); + if ( odd ) { + calc_normal(nodes[last1], nodes[last2], nodes[n4], + approx_normal); + } else { + calc_normal(nodes[last2], nodes[last1], nodes[n4], + approx_normal); + } + calc_normal(nodes[n3], nodes[n2], nodes[n4], approx_normal); + xglNormal3dv(approx_normal); + + /*xglNormal3d(normals[n4][0], normals[n4][1], normals[n4][2]);*/ + xglVertex3d(nodes[n4][0] - ref.x, nodes[n4][1] - ref.y, + nodes[n4][2] - ref.z); + + odd = 1 - odd; + last1 = n3; + last2 = n4; } } else if ( line[0] == 'f' ) { /* unoptimized face */ if ( !first ) { /* close out the previous structure and start the next */ - glEnd(); + xglEnd(); } else { first = 0; } - glBegin(GL_TRIANGLES); + xglBegin(GL_TRIANGLES); /* printf("new triangle = %s", line);*/ sscanf(line, "f %d %d %d\n", &n1, &n2, &n3); - glNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]); - glVertex3d(nodes[n1][0] - ref.x, nodes[n1][1] - ref.y, - nodes[n1][2] - ref.z); + xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]); + xglVertex3d(nodes[n1][0] - ref.x, nodes[n1][1] - ref.y, + nodes[n1][2] - ref.z); - glNormal3d(normals[n2][0], normals[n2][1], normals[n2][2]); - glVertex3d(nodes[n2][0] - ref.x, nodes[n2][1] - ref.y, - nodes[n2][2] - ref.z); + xglNormal3d(normals[n2][0], normals[n2][1], normals[n2][2]); + xglVertex3d(nodes[n2][0] - ref.x, nodes[n2][1] - ref.y, + nodes[n2][2] - ref.z); - glNormal3d(normals[n3][0], normals[n3][1], normals[n3][2]); - glVertex3d(nodes[n3][0] - ref.x, nodes[n3][1] - ref.y, - nodes[n3][2] - ref.z); + xglNormal3d(normals[n3][0], normals[n3][1], normals[n3][2]); + xglVertex3d(nodes[n3][0] - ref.x, nodes[n3][1] - ref.y, + nodes[n3][2] - ref.z); } else if ( line[0] == 'q' ) { /* continue a triangle strip */ n1 = n2 = 0; @@ -207,39 +258,65 @@ GLint fgObjLoad(char *path) { sscanf(line, "q %d %d\n", &n1, &n2); /* printf("read %d %d\n", n1, n2); */ - glNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]); - glVertex3d(nodes[n1][0] - ref.x, nodes[n1][1] - ref.y, - nodes[n1][2] - ref.z); + if ( odd ) { + calc_normal(nodes[last1], nodes[last2], nodes[n1], + approx_normal); + } else { + calc_normal(nodes[last2], nodes[last1], nodes[n1], + approx_normal); + } + xglNormal3dv(approx_normal); + + /* xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]); */ + xglVertex3d(nodes[n1][0] - ref.x, nodes[n1][1] - ref.y, + nodes[n1][2] - ref.z); + + odd = 1 - odd; + last1 = last2; + last2 = n1; if ( n2 > 0 ) { /* printf(" (cont)\n"); */ - glNormal3d(normals[n2][0], normals[n2][1], normals[n2][2]); - glVertex3d(nodes[n2][0] - ref.x, nodes[n2][1] - ref.y, - nodes[n2][2] - ref.z); + if ( odd ) { + calc_normal(nodes[last1], nodes[last2], nodes[n2], + approx_normal); + } else { + calc_normal(nodes[last2], nodes[last1], nodes[n2], + approx_normal); + } + xglNormal3dv(approx_normal); + + /*xglNormal3d(normals[n2][0], normals[n2][1], normals[n2][2]);*/ + xglVertex3d(nodes[n2][0] - ref.x, nodes[n2][1] - ref.y, + nodes[n2][2] - ref.z); + + odd = 1 -odd; + last1 = last2; + last2 = n2; } } else { printf("Unknown line in %s = %s\n", path, line); } } - glEnd(); + xglEnd(); /* Draw normal vectors (for visually verifying normals)*/ /* - glBegin(GL_LINES); - glColor3f(0.0, 0.0, 0.0); + xglBegin(GL_LINES); + xglColor3f(0.0, 0.0, 0.0); for ( i = 0; i < ncount; i++ ) { - glVertex3d(nodes[i][0] - ref.x, - nodes[i][1] - ref.y, - nodes[i][2] - ref.z); - glVertex3d(nodes[i][0] - ref.x + 500*normals[i][0], - nodes[i][1] - ref.y + 500*normals[i][1], - nodes[i][2] - ref.z + 500*normals[i][2]); + xglVertex3d(nodes[i][0] - ref.x, + nodes[i][1] - ref.y, + nodes[i][2] - ref.z); + xglVertex3d(nodes[i][0] - ref.x + 500*normals[i][0], + nodes[i][1] - ref.y + 500*normals[i][1], + nodes[i][2] - ref.z + 500*normals[i][2]); } - glEnd(); + xglEnd(); */ - glEndList(); + xglEndList(); fclose(f); @@ -248,9 +325,13 @@ GLint fgObjLoad(char *path) { /* $Log$ -/* Revision 1.10 1997/12/12 21:41:28 curt -/* More light/material property tweaking ... still a ways off. +/* Revision 1.11 1997/12/15 23:55:01 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.10 1997/12/12 21:41:28 curt + * More light/material property tweaking ... still a ways off. + * * Revision 1.9 1997/12/12 19:52:57 curt * Working on lightling and material properties. * diff --git a/Scenery/orbits.c b/Scenery/orbits.c index 4e10843ab..8ff0f182c 100644 --- a/Scenery/orbits.c +++ b/Scenery/orbits.c @@ -27,7 +27,7 @@ #include "orbits.h" -#include "../general.h" +#include "../Include/general.h" #include "../Time/fg_time.h" @@ -170,10 +170,14 @@ void fgSolarSystemUpdate(struct OrbElements *planet, struct fgTIME t) /* $Log$ -/* Revision 1.4 1997/12/10 22:37:51 curt -/* Prepended "fg" on the name of all global structures that didn't have it yet. -/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}" +/* Revision 1.5 1997/12/15 23:55:02 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.4 1997/12/10 22:37:51 curt + * Prepended "fg" on the name of all global structures that didn't have it yet. + * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" + * * Revision 1.3 1997/11/25 23:20:44 curt * Changed planets.dat Planets.dat * diff --git a/Scenery/scenery.c b/Scenery/scenery.c index 003920123..43913ba26 100644 --- a/Scenery/scenery.c +++ b/Scenery/scenery.c @@ -29,10 +29,12 @@ #endif #include +#include "../XGL/xgl.h" + #include #include -#include "../general.h" +#include "../Include/general.h" #include "astro.h" #include "obj.h" @@ -80,27 +82,31 @@ void fgSceneryUpdate(double lon, double lat, double elev) { /* Render out the current scene */ void fgSceneryRender() { - static GLfloat terrain_color[4] = { 0.4, 0.8, 0.3, 1.0 }; + static GLfloat terrain_color[4] = { 0.6, 0.8, 0.4, 1.0 }; static GLfloat terrain_ambient[4]; static GLfloat terrain_diffuse[4]; int i; for ( i = 0; i < 4; i++ ) { - terrain_ambient[i] = terrain_color[i]; + terrain_ambient[i] = terrain_color[i] * 0.5; terrain_diffuse[i] = terrain_color[i]; } - glMaterialfv(GL_FRONT, GL_AMBIENT, terrain_ambient); - glMaterialfv(GL_FRONT, GL_DIFFUSE, terrain_diffuse); + xglMaterialfv(GL_FRONT, GL_AMBIENT, terrain_ambient); + xglMaterialfv(GL_FRONT, GL_DIFFUSE, terrain_diffuse); - glCallList(area_terrain); + xglCallList(area_terrain); } /* $Log$ -/* Revision 1.27 1997/12/12 21:41:30 curt -/* More light/material property tweaking ... still a ways off. +/* Revision 1.28 1997/12/15 23:55:02 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.27 1997/12/12 21:41:30 curt + * More light/material property tweaking ... still a ways off. + * * Revision 1.26 1997/12/12 19:52:58 curt * Working on lightling and material properties. * diff --git a/Scenery/scenery.h b/Scenery/scenery.h index f9f619c34..869d893e8 100644 --- a/Scenery/scenery.h +++ b/Scenery/scenery.h @@ -28,7 +28,7 @@ #define SCENERY_H -#include "../types.h" +#include "../Include/types.h" /* Define a structure containing global scenery parameters */ @@ -63,10 +63,14 @@ void fgSceneryRender(); /* $Log$ -/* Revision 1.11 1997/12/10 22:37:52 curt -/* Prepended "fg" on the name of all global structures that didn't have it yet. -/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}" +/* Revision 1.12 1997/12/15 23:55:03 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.11 1997/12/10 22:37:52 curt + * Prepended "fg" on the name of all global structures that didn't have it yet. + * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" + * * Revision 1.10 1997/09/04 02:17:37 curt * Shufflin' stuff. * diff --git a/Scenery/stars.c b/Scenery/stars.c index 692ceaba1..d3c671055 100644 --- a/Scenery/stars.c +++ b/Scenery/stars.c @@ -34,13 +34,14 @@ #include #include +#include "../XGL/xgl.h" #include "orbits.h" #include "planets.h" #include "stars.h" -#include "../constants.h" -#include "../general.h" +#include "../Include/constants.h" +#include "../Include/general.h" #include "../Aircraft/aircraft.h" #include "../Main/views.h" #include "../Time/fg_time.h" @@ -85,9 +86,9 @@ void fgStarsInit() { return; } - stars[i] = glGenLists(1); - glNewList( stars[i], GL_COMPILE ); - glBegin( GL_POINTS ); + stars[i] = xglGenLists(1); + xglNewList( stars[i], GL_COMPILE ); + xglBegin( GL_POINTS ); /* read in each line of the file */ count = 0; @@ -150,11 +151,11 @@ void fgStarsInit() { /* printf("Found star: %d %s, %.3f %.3f %.3f\n", count, name, right_ascension, declination, magnitude); */ - glColor3f( magnitude, magnitude, magnitude ); - /*glColor3f(0,0,0);*/ - glVertex3f( 190000.0 * cos(right_ascension) * cos(declination), - 190000.0 * sin(right_ascension) * cos(declination), - 190000.0 * sin(declination) ); + xglColor3f( magnitude, magnitude, magnitude ); + /*xglColor3f(0,0,0);*/ + xglVertex3f( 190000.0 * cos(right_ascension) * cos(declination), + 190000.0 * sin(right_ascension) * cos(declination), + 190000.0 * sin(declination) ); count++; } /* if valid line */ @@ -170,52 +171,52 @@ void fgStarsInit() { printf("Planet found at %f (ra), %f (dec)\n", pltPos.RightAscension, pltPos.Declination); /* give the planets a temporary color, for testing purposes */ - glColor3f( 1.0, 0.0, 0.0); - glVertex3f( 190000.0 * cos(pltPos.RightAscension) * - cos(pltPos.Declination), - 190000.0 * sin(pltPos.RightAscension) * - cos(pltPos.Declination), - 190000.0 * sin(pltPos.Declination) ); + xglColor3f( 1.0, 0.0, 0.0); + xglVertex3f( 190000.0 * cos(pltPos.RightAscension) * + cos(pltPos.Declination), + 190000.0 * sin(pltPos.RightAscension) * + cos(pltPos.Declination), + 190000.0 * sin(pltPos.Declination) ); } - glEnd(); + xglEnd(); /* - glBegin(GL_LINE_LOOP); - glColor3f(1.0, 0.0, 0.0); - glVertex3f( 190000.0 * cos(ra_save-0.2) * cos(decl_save-0.2), + xglBegin(GL_LINE_LOOP); + xglColor3f(1.0, 0.0, 0.0); + xglVertex3f( 190000.0 * cos(ra_save-0.2) * cos(decl_save-0.2), 190000.0 * sin(ra_save-0.2) * cos(decl_save-0.2), 190000.0 * sin(decl_save-0.2) ); - glVertex3f( 190000.0 * cos(ra_save+0.2) * cos(decl_save-0.2), + xglVertex3f( 190000.0 * cos(ra_save+0.2) * cos(decl_save-0.2), 190000.0 * sin(ra_save+0.2) * cos(decl_save-0.2), 190000.0 * sin(decl_save-0.2) ); - glVertex3f( 190000.0 * cos(ra_save+0.2) * cos(decl_save+0.2), + xglVertex3f( 190000.0 * cos(ra_save+0.2) * cos(decl_save+0.2), 190000.0 * sin(ra_save+0.2) * cos(decl_save+0.2), 190000.0 * sin(decl_save+0.2) ); - glVertex3f( 190000.0 * cos(ra_save-0.2) * cos(decl_save+0.2), + xglVertex3f( 190000.0 * cos(ra_save-0.2) * cos(decl_save+0.2), 190000.0 * sin(ra_save-0.2) * cos(decl_save+0.2), 190000.0 * sin(decl_save+0.2) ); - glEnd(); + xglEnd(); */ /* - glBegin(GL_LINE_LOOP); - glColor3f(0.0, 1.0, 0.0); - glVertex3f( 190000.0 * cos(ra_save1-0.2) * cos(decl_save1-0.2), + xglBegin(GL_LINE_LOOP); + xglColor3f(0.0, 1.0, 0.0); + xglVertex3f( 190000.0 * cos(ra_save1-0.2) * cos(decl_save1-0.2), 190000.0 * sin(ra_save1-0.2) * cos(decl_save1-0.2), 190000.0 * sin(decl_save1-0.2) ); - glVertex3f( 190000.0 * cos(ra_save1+0.2) * cos(decl_save1-0.2), + xglVertex3f( 190000.0 * cos(ra_save1+0.2) * cos(decl_save1-0.2), 190000.0 * sin(ra_save1+0.2) * cos(decl_save1-0.2), 190000.0 * sin(decl_save1-0.2) ); - glVertex3f( 190000.0 * cos(ra_save1+0.2) * cos(decl_save1+0.2), + xglVertex3f( 190000.0 * cos(ra_save1+0.2) * cos(decl_save1+0.2), 190000.0 * sin(ra_save1+0.2) * cos(decl_save1+0.2), 190000.0 * sin(decl_save1+0.2) ); - glVertex3f( 190000.0 * cos(ra_save1-0.2) * cos(decl_save1+0.2), + xglVertex3f( 190000.0 * cos(ra_save1-0.2) * cos(decl_save1+0.2), 190000.0 * sin(ra_save1-0.2) * cos(decl_save1+0.2), 190000.0 * sin(decl_save1+0.2) ); - glEnd(); + xglEnd(); */ - glEndList(); + xglEndList(); max_stars /= 2; } @@ -254,9 +255,9 @@ void fgStarsRender() { printf("RENDERING STARS = %d (night)\n", i); - glDisable( GL_LIGHTING ); - glCallList(stars[i]); - glEnable( GL_LIGHTING ); + xglDisable( GL_LIGHTING ); + xglCallList(stars[i]); + xglEnable( GL_LIGHTING ); } else { printf("not RENDERING STARS (day)\n"); } @@ -264,9 +265,13 @@ void fgStarsRender() { /* $Log$ -/* Revision 1.19 1997/12/12 19:53:00 curt -/* Working on lightling and material properties. +/* Revision 1.20 1997/12/15 23:55:03 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.19 1997/12/12 19:53:00 curt + * Working on lightling and material properties. + * * Revision 1.18 1997/12/10 22:37:52 curt * Prepended "fg" on the name of all global structures that didn't have it yet. * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" diff --git a/Scenery/sun.c b/Scenery/sun.c index 2b97740cf..e53dfbb53 100644 --- a/Scenery/sun.c +++ b/Scenery/sun.c @@ -23,6 +23,8 @@ **************************************************************************/ #include +#include "../XGL/xgl.h" + #include "../Time/fg_time.h" #include "../Main/views.h" #include "orbits.h" @@ -95,10 +97,10 @@ void fgSunInit() { // int i; - sun_obj = glGenLists(1); - glNewList(sun_obj, GL_COMPILE ); + sun_obj = xglGenLists(1); + xglNewList(sun_obj, GL_COMPILE ); -// glBegin( GL_POINTS ); +// xglBegin( GL_POINTS ); fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params); sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params); @@ -108,13 +110,13 @@ void fgSunInit() #endif /* give the moon a temporary color, for testing purposes */ -// glColor3f( 0.0, 1.0, 0.0); -// glVertex3f( 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination), +// xglColor3f( 0.0, 1.0, 0.0); +// xglVertex3f( 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination), // 190000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination), // 190000.0 * sin(moonPos.Declination) ); - //glVertex3f(0.0, 0.0, 0.0); -// glEnd(); -// glColor3f(1.0, 1.0, 1.0); + //xglVertex3f(0.0, 0.0, 0.0); +// xglEnd(); +// xglColor3f(1.0, 1.0, 1.0); //xMoon = 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination); //yMoon = 190000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination); //zMoon = 190000.0 * sin(moonPos.Declination); @@ -123,22 +125,22 @@ void fgSunInit() ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination); zSun = 60000.0 * sin(sunPos.Declination); -// glPushMatrix(); -// glTranslatef(x, y, z); -// glScalef(16622.8, 16622.8, 16622.8); -// glBegin(GL_TRIANGLES); +// xglPushMatrix(); +// xglTranslatef(x, y, z); +// xglScalef(16622.8, 16622.8, 16622.8); +// xglBegin(GL_TRIANGLES); // for (i = 0; i < 20; i++) // subdivide(&vdata[tindices[i][0]][0], // &vdata[tindices[i][1]][0], // &vdata[tindices[i][2]][0], 3); // glutSolidSphere(1.0, 25, 25); -// glEnd(); - //glPopMatrix(); +// xglEnd(); + //xglPopMatrix(); glutSolidSphere(1.0, 10, 10); - glEndList(); + xglEndList(); } @@ -178,33 +180,37 @@ void fgSunRender() { diff[3] = 0.0; */ /* set lighting parameters */ - /* glLightfv(GL_LIGHT0, GL_AMBIENT, color ); - glLightfv(GL_LIGHT0, GL_DIFFUSE, color ); - glMaterialfv(GL_FRONT, GL_AMBIENT, amb); - glMaterialfv(GL_FRONT, GL_DIFFUSE, diff); */ + /* xglLightfv(GL_LIGHT0, GL_AMBIENT, color ); + xglLightfv(GL_LIGHT0, GL_DIFFUSE, color ); + xglMaterialfv(GL_FRONT, GL_AMBIENT, amb); + xglMaterialfv(GL_FRONT, GL_DIFFUSE, diff); */ - glDisable( GL_LIGHTING ); + xglDisable( GL_LIGHTING ); - glPushMatrix(); - glTranslatef(xSun, ySun, zSun); - glScalef(1400, 1400, 1400); + xglPushMatrix(); + xglTranslatef(xSun, ySun, zSun); + xglScalef(1400, 1400, 1400); - glColor3f(0.85, 0.65, 0.05); + xglColor3f(0.85, 0.65, 0.05); - /* glColor3fv( color ); */ - /* glutSolidSphere(1.0, 25, 25); */ - glCallList(sun_obj); + /* xglColor3fv( color ); */ + /* xglutSolidSphere(1.0, 25, 25); */ + xglCallList(sun_obj); - glPopMatrix(); + xglPopMatrix(); - glEnable( GL_LIGHTING ); + xglEnable( GL_LIGHTING ); } /* $Log$ -/* Revision 1.5 1997/12/12 21:41:31 curt -/* More light/material property tweaking ... still a ways off. +/* Revision 1.6 1997/12/15 23:55:04 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.5 1997/12/12 21:41:31 curt + * More light/material property tweaking ... still a ways off. + * * Revision 1.4 1997/12/10 22:37:53 curt * Prepended "fg" on the name of all global structures that didn't have it yet. * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" diff --git a/Simulator/Makefile b/Simulator/Makefile index 412a54ba7..f07b102e3 100644 --- a/Simulator/Makefile +++ b/Simulator/Makefile @@ -28,7 +28,8 @@ include make.inc SUBSUBDIRS = Flight/LaRCsim Flight/Slew -SUBDIRS = Aircraft Cockpit Controls Flight Joystick Math Scenery Time Weather +SUBDIRS = Aircraft Cockpit Controls Flight Joystick Math Scenery Time Weather \ + XGL MAIN = Main @@ -95,6 +96,10 @@ bin-zip: #--------------------------------------------------------------------------- # $Log$ +# Revision 1.32 1997/12/15 23:54:25 curt +# Add xgl wrappers for debugging. +# Generate terrain normals on the fly. +# # Revision 1.31 1997/12/15 20:59:08 curt # Misc. tweaks. # diff --git a/Simulator/make.inc b/Simulator/make.inc index 171e04129..78c22c80b 100644 --- a/Simulator/make.inc +++ b/Simulator/make.inc @@ -30,7 +30,7 @@ #--------------------------------------------------------------------------- FG_VERSION_MAJOR = 0 -FG_VERSION_MINOR = 17 +FG_VERSION_MINOR = 18 FG_VERSION = $(FG_VERSION_MAJOR).$(FG_VERSION_MINOR) @@ -60,6 +60,8 @@ LN = ln -sf # # -O3 -fomit-frame-pointer -funroll-all-loops -ffast-math # - Other potential compiler optimization flags +# +# - #--------------------------------------------------------------------------- GLOBAL_CFLAGS = -g -Wall -DVERSION=\"$(FG_VERSION)\" @@ -86,6 +88,17 @@ GLOBAL_CFLAGS = -g -Wall -DVERSION=\"$(FG_VERSION)\" #--------------------------------------------------------------------------- +#--------------------------------------------------------------------------- +# Debugging options. +# +# Uncomment the following two lines to enable OpenGL function call tracing. +# This mechanism is provided courtesy of Steve Baker +#--------------------------------------------------------------------------- + +# FG_DEBUG_FLAGS = -DXGL_TRACE +# FG_DEBUG_LIBS = ../XGL/libXGL.a + + #--------------------------------------------------------------------------- # Uncomment one of the following sections depending on your system # @@ -102,7 +115,7 @@ INTERFACE_FILES = GLUTmain.c GLUTkey.c MESA_LIBS = -L/usr/lib/mesa -lMesatk -lMesaaux -lMesaGLU -lMesaGL X11_LIBS = -L/usr/X11R6/lib -lXext -lXmu -lXi -lX11 GRAPHICS_LIBS = $(MESA_LIBS) $(X11_LIBS) -FG_CFLAGS = $(GLOBAL_CFLAGS) +FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS) #--------------------------------------------------------------------------- #--------------------------------------------------------------------------- @@ -114,7 +127,7 @@ FG_CFLAGS = $(GLOBAL_CFLAGS) # INTERFACE_LIBS = -lglut # INTERFACE_FILES = GLUTmain.c GLUTkey.c # GRAPHICS_LIBS = -lGLU -lGL -lXmu -lX11 -# FG_CFLAGS = $(GLOBAL_CFLAGS) +# FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS) #--------------------------------------------------------------------------- #--------------------------------------------------------------------------- @@ -125,7 +138,7 @@ FG_CFLAGS = $(GLOBAL_CFLAGS) # INTERFACE_LIBS = -lglut # INTERFACE_FILES = GLUTmain.c GLUTkey.c # GRAPHICS_LIBS = -lGLU -lGL -lXext -lXmu -lXi -lX11 -# FG_CFLAGS = $(GLOBAL_CFLAGS) +# FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS) #--------------------------------------------------------------------------- #--------------------------------------------------------------------------- @@ -135,13 +148,17 @@ FG_CFLAGS = $(GLOBAL_CFLAGS) # INTERFACE_LIBS = ../Win32/libglut.a # INTERFACE_FILES = GLUTmain.c GLUTkey.c # GRAPHICS_LIBS = -lglu32 -lopengl32 -luser32 -lgdi32 -# FG_CFLAGS = $(GLOBAL_CFLAGS) -DWIN32 -DUSE_RAND +# FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS) -DWIN32 -DUSE_RAND # LN = copy #--------------------------------------------------------------------------- #--------------------------------------------------------------------------- # $Log$ +# Revision 1.25 1997/12/15 23:54:26 curt +# Add xgl wrappers for debugging. +# Generate terrain normals on the fly. +# # Revision 1.24 1997/12/12 21:41:24 curt # More light/material property tweaking ... still a ways off. # diff --git a/Slew/depend b/Slew/depend index 77fd35e4e..bec72d53a 100644 --- a/Slew/depend +++ b/Slew/depend @@ -2,5 +2,5 @@ slew.o: slew.c slew.h ../flight.h ../Slew/slew.h \ ../LaRCsim/ls_interface.h ../LaRCsim/../flight.h \ ../../Aircraft/aircraft.h ../../Aircraft/../Flight/flight.h \ ../../Aircraft/../Controls/controls.h \ - ../../Aircraft/../Controls/../limits.h ../../Controls/controls.h \ - ../../constants.h + ../../Aircraft/../Controls/../Include/limits.h \ + ../../Controls/controls.h ../../Include/constants.h diff --git a/Slew/slew.c b/Slew/slew.c index 3f81dfb17..12702e04d 100644 --- a/Slew/slew.c +++ b/Slew/slew.c @@ -30,7 +30,7 @@ #include "../flight.h" #include "../../Aircraft/aircraft.h" #include "../../Controls/controls.h" -#include "../../constants.h" +#include "../../Include/constants.h" #ifndef M_PI @@ -91,9 +91,13 @@ void fgSlewUpdate() { /* $Log$ -/* Revision 1.6 1997/08/27 03:30:11 curt -/* Changed naming scheme of basic shared structures. +/* Revision 1.7 1997/12/15 23:54:42 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.6 1997/08/27 03:30:11 curt + * Changed naming scheme of basic shared structures. + * * Revision 1.5 1997/07/19 22:35:06 curt * Moved fiddled with PI to avoid compiler warnings. * diff --git a/Time/depend b/Time/depend index b6739f0e6..8eb45bb22 100644 --- a/Time/depend +++ b/Time/depend @@ -1,12 +1,14 @@ -fg_time.o: fg_time.c fg_time.h ../types.h ../Flight/flight.h \ +fg_time.o: fg_time.c fg_time.h ../Include/types.h ../Flight/flight.h \ ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ - ../Flight/LaRCsim/../flight.h ../constants.h ../Time/fg_time.h + ../Flight/LaRCsim/../flight.h ../Include/constants.h \ + ../Time/fg_time.h fg_timer.o: fg_timer.c fg_timer.h -sidereal.o: sidereal.c ../constants.h -sunpos.o: sunpos.c sunpos.h ../types.h fg_time.h ../Flight/flight.h \ - ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ - ../Flight/LaRCsim/../flight.h ../constants.h ../Main/views.h \ - ../Main/../types.h ../Main/../Flight/flight.h ../Main/../Math/mat3.h \ +sidereal.o: sidereal.c ../Include/constants.h +sunpos.o: sunpos.c sunpos.h ../Include/types.h fg_time.h \ + ../Flight/flight.h ../Flight/Slew/slew.h \ + ../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \ + ../Include/constants.h ../Main/views.h ../Main/../Include/types.h \ + ../Main/../Flight/flight.h ../Main/../Math/mat3.h \ ../Math/fg_geodesy.h ../Math/mat3.h ../Math/polar.h \ - ../Math/../types.h + ../Math/../Include/types.h ttest.o: ttest.c diff --git a/Time/fg_time.c b/Time/fg_time.c index 513b5c181..07acaa3d8 100644 --- a/Time/fg_time.c +++ b/Time/fg_time.c @@ -35,7 +35,7 @@ #endif #include "fg_time.h" -#include "../constants.h" +#include "../Include/constants.h" #include "../Flight/flight.h" #include "../Time/fg_time.h" @@ -285,9 +285,13 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) { /* $Log$ -/* Revision 1.19 1997/12/15 20:59:10 curt -/* Misc. tweaks. +/* Revision 1.20 1997/12/15 23:55:06 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.19 1997/12/15 20:59:10 curt + * Misc. tweaks. + * * Revision 1.18 1997/12/12 21:41:31 curt * More light/material property tweaking ... still a ways off. * diff --git a/Time/fg_time.h b/Time/fg_time.h index 30a9e2440..155335fe4 100644 --- a/Time/fg_time.h +++ b/Time/fg_time.h @@ -35,7 +35,7 @@ #include #include -#include "../types.h" +#include "../Include/types.h" #include "../Flight/flight.h" @@ -92,10 +92,14 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t); /* $Log$ -/* Revision 1.9 1997/12/10 22:37:55 curt -/* Prepended "fg" on the name of all global structures that didn't have it yet. -/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}" +/* Revision 1.10 1997/12/15 23:55:07 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.9 1997/12/10 22:37:55 curt + * Prepended "fg" on the name of all global structures that didn't have it yet. + * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" + * * Revision 1.8 1997/12/09 04:25:38 curt * Working on adding a global lighting params structure. * diff --git a/Time/sunpos.c b/Time/sunpos.c index 5d4c31db2..e1b0e16a6 100644 --- a/Time/sunpos.c +++ b/Time/sunpos.c @@ -45,7 +45,7 @@ #include "sunpos.h" #include "fg_time.h" -#include "../constants.h" +#include "../Include/constants.h" #include "../Main/views.h" #include "../Math/fg_geodesy.h" #include "../Math/mat3.h" @@ -316,10 +316,14 @@ void fgUpdateSunPos(struct fgCartesianPoint scenery_center) { /* $Log$ -/* Revision 1.16 1997/12/11 04:43:57 curt -/* Fixed sun vector and lighting problems. I thing the moon is now lit -/* correctly. +/* Revision 1.17 1997/12/15 23:55:08 curt +/* Add xgl wrappers for debugging. +/* Generate terrain normals on the fly. /* + * Revision 1.16 1997/12/11 04:43:57 curt + * Fixed sun vector and lighting problems. I thing the moon is now lit + * correctly. + * * Revision 1.15 1997/12/10 22:37:55 curt * Prepended "fg" on the name of all global structures that didn't have it yet. * i.e. "struct WEATHER {}" became "struct fgWEATHER {}" diff --git a/Time/sunpos.h b/Time/sunpos.h index 96f582a33..c4e754867 100644 --- a/Time/sunpos.h +++ b/Time/sunpos.h @@ -42,7 +42,7 @@ #include -#include "../types.h" +#include "../Include/types.h" /* update the cur_time_params structure with the current sun position */ void fgUpdateSunPos(struct fgCartesianPoint scenery_center); diff --git a/Weather/depend b/Weather/depend index d94f0760f..1bfe93835 100644 --- a/Weather/depend +++ b/Weather/depend @@ -3,4 +3,4 @@ weather.o: weather.c weather.h ../Aircraft/aircraft.h \ ../Aircraft/../Flight/LaRCsim/ls_interface.h \ ../Aircraft/../Flight/LaRCsim/../flight.h \ ../Aircraft/../Controls/controls.h \ - ../Aircraft/../Controls/../limits.h ../Math/fg_random.h + ../Aircraft/../Controls/../Include/limits.h ../Math/fg_random.h -- 2.39.2