Add xgl wrappers for debugging.

Generate terrain normals on the fly.
This commit is contained in:
curt
1997-12-15 23:54:25 +00:00
parent 8f7a446ec8
commit b54a4d1f92
4 changed files with 99 additions and 83 deletions
+16 -11
View File
@@ -29,6 +29,7 @@
#include <time.h> #include <time.h>
#include <GL/glut.h> #include <GL/glut.h>
#include "../XGL/xgl.h"
#include "astro.h" #include "astro.h"
#include "moon.h" #include "moon.h"
@@ -37,8 +38,8 @@
#include "stars.h" #include "stars.h"
#include "sun.h" #include "sun.h"
#include "../constants.h" #include "../Include/constants.h"
#include "../general.h" #include "../Include/general.h"
#include "../Main/views.h" #include "../Main/views.h"
#include "../Aircraft/aircraft.h" #include "../Aircraft/aircraft.h"
@@ -87,22 +88,22 @@ void fgAstroRender() {
} }
/* Disable fog effects */ /* Disable fog effects */
glDisable( GL_FOG ); xglDisable( GL_FOG );
/* set the sun position */ /* 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 */ /* 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) */ /* Rotate based on gst (side real time) */
angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/ angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/
#ifdef DEBUG #ifdef DEBUG
printf("Rotating astro objects by %.2f degrees\n",angle); printf("Rotating astro objects by %.2f degrees\n",angle);
#endif #endif
glRotatef( angle, 0.0, 0.0, -1.0 ); xglRotatef( angle, 0.0, 0.0, -1.0 );
/* render the moon */ /* render the moon */
fgMoonRender(); fgMoonRender();
@@ -113,17 +114,21 @@ void fgAstroRender() {
/* render the sun */ /* render the sun */
fgSunRender(); fgSunRender();
glPopMatrix(); xglPopMatrix();
/* reenable fog effects */ /* reenable fog effects */
glEnable( GL_FOG ); xglEnable( GL_FOG );
} }
/* $Log$ /* $Log$
/* Revision 1.7 1997/12/15 20:59:09 curt /* Revision 1.8 1997/12/15 23:54:57 curt
/* Misc. tweaks. /* 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 * Revision 1.6 1997/12/12 21:41:27 curt
* More light/material property tweaking ... still a ways off. * More light/material property tweaking ... still a ways off.
* *
+38 -37
View File
@@ -23,11 +23,12 @@
#include <math.h> #include <math.h>
#include <GL/glut.h> #include <GL/glut.h>
#include "../XGL/xgl.h"
#include "orbits.h" #include "orbits.h"
#include "moon.h" #include "moon.h"
#include "../general.h" #include "../Include/general.h"
#include "../Main/views.h" #include "../Main/views.h"
#include "../Time/fg_time.h" #include "../Time/fg_time.h"
@@ -72,15 +73,15 @@ void NormalizeVector(float v[3])
void drawTriangle(float *v1, float *v2, float *v3) void drawTriangle(float *v1, float *v2, float *v3)
{ {
glBegin(GL_POLYGON); xglBegin(GL_POLYGON);
//glBegin(GL_POINTS); //xglBegin(GL_POINTS);
glNormal3fv(v1); xglNormal3fv(v1);
glVertex3fv(v1); xglVertex3fv(v1);
glNormal3fv(v2); xglNormal3fv(v2);
glVertex3fv(v2); xglVertex3fv(v2);
glNormal3fv(v3); xglNormal3fv(v3);
glVertex3fv(v3); xglVertex3fv(v3);
glEnd(); xglEnd();
} }
void subdivide(float *v1, float *v2, float *v3, long depth) 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) void display(void)
{ {
int i; int i;
glClear(GL_COLOR_BUFFER_BIT); xglClear(GL_COLOR_BUFFER_BIT);
glPushMatrix(); xglPushMatrix();
glRotatef(spin, 0.0, 0.0, 0.0); xglRotatef(spin, 0.0, 0.0, 0.0);
glColor3f(1.0, 1.0, 0.0); xglColor3f(1.0, 1.0, 0.0);
// glBegin(GL_LINE_LOOP); // xglBegin(GL_LINE_LOOP);
for (i = 0; i < 20; i++) for (i = 0; i < 20; i++)
{ {
//glVertex3fv(&vdata[tindices[i][0]][0]); //xglVertex3fv(&vdata[tindices[i][0]][0]);
//glVertex3fv(&vdata[tindices[i][1]][0]); //xglVertex3fv(&vdata[tindices[i][1]][0]);
//glVertex3fv(&vdata[tindices[i][2]][0]); //xglVertex3fv(&vdata[tindices[i][2]][0]);
subdivide(&vdata[tindices[i][0]][0], subdivide(&vdata[tindices[i][0]][0],
&vdata[tindices[i][1]][0], &vdata[tindices[i][1]][0],
@@ -130,9 +131,9 @@ void display(void)
} }
// glEnd(); // xglEnd();
// glFlush(); // xglFlush();
glPopMatrix(); xglPopMatrix();
glutSwapBuffers(); glutSwapBuffers();
} */ } */
@@ -230,11 +231,11 @@ void fgMoonInit() {
l = &cur_light_params; l = &cur_light_params;
moon = glGenLists(1); moon = xglGenLists(1);
glNewList(moon, GL_COMPILE ); xglNewList(moon, GL_COMPILE );
/* glMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear); /* xglMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear);
glMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); */ xglMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); */
fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params); fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params);
moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0], moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0],
@@ -254,7 +255,7 @@ void fgMoonInit() {
glutSolidSphere(1.0, 15, 15); glutSolidSphere(1.0, 15, 15);
glEndList(); xglEndList();
} }
@@ -267,21 +268,21 @@ void fgMoonRender() {
l = &cur_light_params; l = &cur_light_params;
/* set lighting parameters */ /* set lighting parameters */
glLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_clear ); xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_clear );
glLightfv(GL_LIGHT0, GL_DIFFUSE, moon_color ); xglLightfv(GL_LIGHT0, GL_DIFFUSE, moon_color );
glMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear ); xglMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear );
glMaterialfv(GL_FRONT, GL_AMBIENT, moon_color ); xglMaterialfv(GL_FRONT, GL_AMBIENT, moon_color );
glMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); xglMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color);
glPushMatrix(); xglPushMatrix();
glTranslatef(xMoon, yMoon, zMoon); xglTranslatef(xMoon, yMoon, zMoon);
glScalef(1400, 1400, 1400); xglScalef(1400, 1400, 1400);
glColor3fv(moon_color); xglColor3fv(moon_color);
/* glutSolidSphere(1.0, 25, 25); */ /* glutSolidSphere(1.0, 25, 25); */
glCallList(moon); xglCallList(moon);
glPopMatrix(); xglPopMatrix();
} }
+8 -4
View File
@@ -27,7 +27,7 @@
#include "orbits.h" #include "orbits.h"
#include "../general.h" #include "../Include/general.h"
#include "../Time/fg_time.h" #include "../Time/fg_time.h"
@@ -170,10 +170,14 @@ void fgSolarSystemUpdate(struct OrbElements *planet, struct fgTIME t)
/* $Log$ /* $Log$
/* Revision 1.4 1997/12/10 22:37:51 curt /* Revision 1.5 1997/12/15 23:55:02 curt
/* Prepended "fg" on the name of all global structures that didn't have it yet. /* Add xgl wrappers for debugging.
/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}" /* 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 * Revision 1.3 1997/11/25 23:20:44 curt
* Changed planets.dat Planets.dat * Changed planets.dat Planets.dat
* *
+37 -31
View File
@@ -23,6 +23,8 @@
**************************************************************************/ **************************************************************************/
#include <GL/glut.h> #include <GL/glut.h>
#include "../XGL/xgl.h"
#include "../Time/fg_time.h" #include "../Time/fg_time.h"
#include "../Main/views.h" #include "../Main/views.h"
#include "orbits.h" #include "orbits.h"
@@ -95,10 +97,10 @@ void fgSunInit()
{ {
// int i; // int i;
sun_obj = glGenLists(1); sun_obj = xglGenLists(1);
glNewList(sun_obj, GL_COMPILE ); xglNewList(sun_obj, GL_COMPILE );
// glBegin( GL_POINTS ); // xglBegin( GL_POINTS );
fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params); fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params);
sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params); sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params);
@@ -108,13 +110,13 @@ void fgSunInit()
#endif #endif
/* give the moon a temporary color, for testing purposes */ /* give the moon a temporary color, for testing purposes */
// glColor3f( 0.0, 1.0, 0.0); // xglColor3f( 0.0, 1.0, 0.0);
// glVertex3f( 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination), // xglVertex3f( 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination),
// 190000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination), // 190000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination),
// 190000.0 * sin(moonPos.Declination) ); // 190000.0 * sin(moonPos.Declination) );
//glVertex3f(0.0, 0.0, 0.0); //xglVertex3f(0.0, 0.0, 0.0);
// glEnd(); // xglEnd();
// glColor3f(1.0, 1.0, 1.0); // xglColor3f(1.0, 1.0, 1.0);
//xMoon = 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination); //xMoon = 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
//yMoon = 190000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination); //yMoon = 190000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
//zMoon = 190000.0 * sin(moonPos.Declination); //zMoon = 190000.0 * sin(moonPos.Declination);
@@ -123,22 +125,22 @@ void fgSunInit()
ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination); ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination);
zSun = 60000.0 * sin(sunPos.Declination); zSun = 60000.0 * sin(sunPos.Declination);
// glPushMatrix(); // xglPushMatrix();
// glTranslatef(x, y, z); // xglTranslatef(x, y, z);
// glScalef(16622.8, 16622.8, 16622.8); // xglScalef(16622.8, 16622.8, 16622.8);
// glBegin(GL_TRIANGLES); // xglBegin(GL_TRIANGLES);
// for (i = 0; i < 20; i++) // for (i = 0; i < 20; i++)
// subdivide(&vdata[tindices[i][0]][0], // subdivide(&vdata[tindices[i][0]][0],
// &vdata[tindices[i][1]][0], // &vdata[tindices[i][1]][0],
// &vdata[tindices[i][2]][0], 3); // &vdata[tindices[i][2]][0], 3);
// glutSolidSphere(1.0, 25, 25); // glutSolidSphere(1.0, 25, 25);
// glEnd(); // xglEnd();
//glPopMatrix(); //xglPopMatrix();
glutSolidSphere(1.0, 10, 10); glutSolidSphere(1.0, 10, 10);
glEndList(); xglEndList();
} }
@@ -178,33 +180,37 @@ void fgSunRender() {
diff[3] = 0.0; */ diff[3] = 0.0; */
/* set lighting parameters */ /* set lighting parameters */
/* glLightfv(GL_LIGHT0, GL_AMBIENT, color ); /* xglLightfv(GL_LIGHT0, GL_AMBIENT, color );
glLightfv(GL_LIGHT0, GL_DIFFUSE, color ); xglLightfv(GL_LIGHT0, GL_DIFFUSE, color );
glMaterialfv(GL_FRONT, GL_AMBIENT, amb); xglMaterialfv(GL_FRONT, GL_AMBIENT, amb);
glMaterialfv(GL_FRONT, GL_DIFFUSE, diff); */ xglMaterialfv(GL_FRONT, GL_DIFFUSE, diff); */
glDisable( GL_LIGHTING ); xglDisable( GL_LIGHTING );
glPushMatrix(); xglPushMatrix();
glTranslatef(xSun, ySun, zSun); xglTranslatef(xSun, ySun, zSun);
glScalef(1400, 1400, 1400); xglScalef(1400, 1400, 1400);
glColor3f(0.85, 0.65, 0.05); xglColor3f(0.85, 0.65, 0.05);
/* glColor3fv( color ); */ /* xglColor3fv( color ); */
/* glutSolidSphere(1.0, 25, 25); */ /* xglutSolidSphere(1.0, 25, 25); */
glCallList(sun_obj); xglCallList(sun_obj);
glPopMatrix(); xglPopMatrix();
glEnable( GL_LIGHTING ); xglEnable( GL_LIGHTING );
} }
/* $Log$ /* $Log$
/* Revision 1.5 1997/12/12 21:41:31 curt /* Revision 1.6 1997/12/15 23:55:04 curt
/* More light/material property tweaking ... still a ways off. /* 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 * 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. * Prepended "fg" on the name of all global structures that didn't have it yet.
* i.e. "struct WEATHER {}" became "struct fgWEATHER {}" * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"