1
0
Fork 0

Fixed so moon and sun display lists aren't recreate periodically.

This commit is contained in:
curt 1997-12-17 23:12:14 +00:00
parent d19c5f0b6f
commit e292d8e660
2 changed files with 42 additions and 56 deletions

View file

@ -34,8 +34,8 @@
struct CelestialCoord moonPos;
float xMoon, yMoon, zMoon;
GLint moon;
static float xMoon, yMoon, zMoon;
static GLint moon;
/*
static GLfloat vdata[12][3] =
@ -227,16 +227,11 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
void fgMoonInit() {
struct fgLIGHT *l;
// int i;
static int dl_exists = 0;
l = &cur_light_params;
moon = xglGenLists(1);
xglNewList(moon, GL_COMPILE );
/* xglMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear);
xglMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); */
/* position the moon */
fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params);
moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0],
cur_time_params);
@ -245,24 +240,34 @@ void fgMoonInit() {
moonPos.Declination);
#endif
/* xMoon = 90000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
yMoon = 90000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
zMoon = 90000.0 * sin(moonPos.Declination); */
if ( !dl_exists ) {
dl_exists = 1;
xMoon = 60000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
/* printf("First time through, creating moon display list\n"); */
moon = xglGenLists(1);
xglNewList(moon, GL_COMPILE );
/* xglMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear);
xglMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); */
xMoon = 60000.0 * cos(moonPos.RightAscension) *
cos(moonPos.Declination);
yMoon = 60000.0 * sin(moonPos.RightAscension) *
cos(moonPos.Declination);
zMoon = 60000.0 * sin(moonPos.Declination);
glutSolidSphere(1.0, 15, 15);
xglEndList();
}
}
/* Draw the moon */
void fgMoonRender() {
struct fgLIGHT *l;
GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat moon_color[4] = { 1.0, 1.0, 1.0, 1.0 };
l = &cur_light_params;

View file

@ -93,14 +93,8 @@ struct CelestialCoord fgCalculateSun(struct OrbElements params, struct fgTIME t)
/* Initialize the Sun */
void fgSunInit()
{
// int i;
sun_obj = xglGenLists(1);
xglNewList(sun_obj, GL_COMPILE );
// xglBegin( GL_POINTS );
void fgSunInit() {
static int dl_exists = 0;
fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params);
sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params);
@ -109,39 +103,23 @@ void fgSunInit()
sunPos.Declination);
#endif
/* give the moon a temporary color, for testing purposes */
// 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) );
//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);
if ( !dl_exists ) {
dl_exists = 1;
/* printf("First time through, creating sun display list\n"); */
sun_obj = xglGenLists(1);
xglNewList(sun_obj, GL_COMPILE );
xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination);
ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination);
zSun = 60000.0 * sin(sunPos.Declination);
// 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);
// xglEnd();
//xglPopMatrix();
glutSolidSphere(1.0, 10, 10);
xglEndList();
}
}
/* Draw the Sun */
@ -204,10 +182,13 @@ void fgSunRender() {
/* $Log$
/* Revision 1.6 1997/12/15 23:55:04 curt
/* Add xgl wrappers for debugging.
/* Generate terrain normals on the fly.
/* Revision 1.7 1997/12/17 23:12:16 curt
/* Fixed so moon and sun display lists aren't recreate periodically.
/*
* 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.
*