Add xgl wrappers for debugging.
Generate terrain normals on the fly.
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#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.
|
||||
*
|
||||
|
||||
@@ -23,11 +23,12 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <GL/glut.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include <GL/glut.h>
|
||||
#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 {}"
|
||||
|
||||
Reference in New Issue
Block a user