Fixed so moon and sun display lists aren't recreate periodically.
This commit is contained in:
parent
d19c5f0b6f
commit
e292d8e660
2 changed files with 42 additions and 56 deletions
|
@ -34,8 +34,8 @@
|
||||||
|
|
||||||
struct CelestialCoord moonPos;
|
struct CelestialCoord moonPos;
|
||||||
|
|
||||||
float xMoon, yMoon, zMoon;
|
static float xMoon, yMoon, zMoon;
|
||||||
GLint moon;
|
static GLint moon;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
static GLfloat vdata[12][3] =
|
static GLfloat vdata[12][3] =
|
||||||
|
@ -227,16 +227,11 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
|
||||||
|
|
||||||
void fgMoonInit() {
|
void fgMoonInit() {
|
||||||
struct fgLIGHT *l;
|
struct fgLIGHT *l;
|
||||||
// int i;
|
static int dl_exists = 0;
|
||||||
|
|
||||||
l = &cur_light_params;
|
l = &cur_light_params;
|
||||||
|
|
||||||
moon = xglGenLists(1);
|
/* position the moon */
|
||||||
xglNewList(moon, GL_COMPILE );
|
|
||||||
|
|
||||||
/* xglMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear);
|
|
||||||
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],
|
||||||
cur_time_params);
|
cur_time_params);
|
||||||
|
@ -245,24 +240,34 @@ void fgMoonInit() {
|
||||||
moonPos.Declination);
|
moonPos.Declination);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* xMoon = 90000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
|
if ( !dl_exists ) {
|
||||||
yMoon = 90000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
|
dl_exists = 1;
|
||||||
zMoon = 90000.0 * sin(moonPos.Declination); */
|
|
||||||
|
|
||||||
xMoon = 60000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
|
/* printf("First time through, creating moon display list\n"); */
|
||||||
yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
|
|
||||||
zMoon = 60000.0 * sin(moonPos.Declination);
|
|
||||||
|
|
||||||
glutSolidSphere(1.0, 15, 15);
|
moon = xglGenLists(1);
|
||||||
|
xglNewList(moon, GL_COMPILE );
|
||||||
|
|
||||||
xglEndList();
|
/* 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 */
|
/* Draw the moon */
|
||||||
void fgMoonRender() {
|
void fgMoonRender() {
|
||||||
struct fgLIGHT *l;
|
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 };
|
GLfloat moon_color[4] = { 1.0, 1.0, 1.0, 1.0 };
|
||||||
|
|
||||||
l = &cur_light_params;
|
l = &cur_light_params;
|
||||||
|
|
|
@ -93,14 +93,8 @@ struct CelestialCoord fgCalculateSun(struct OrbElements params, struct fgTIME t)
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the Sun */
|
/* Initialize the Sun */
|
||||||
void fgSunInit()
|
void fgSunInit() {
|
||||||
{
|
static int dl_exists = 0;
|
||||||
// int i;
|
|
||||||
|
|
||||||
sun_obj = xglGenLists(1);
|
|
||||||
xglNewList(sun_obj, GL_COMPILE );
|
|
||||||
|
|
||||||
// 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);
|
||||||
|
@ -109,38 +103,22 @@ void fgSunInit()
|
||||||
sunPos.Declination);
|
sunPos.Declination);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* give the moon a temporary color, for testing purposes */
|
if ( !dl_exists ) {
|
||||||
// xglColor3f( 0.0, 1.0, 0.0);
|
dl_exists = 1;
|
||||||
// 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);
|
|
||||||
|
|
||||||
xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination);
|
/* printf("First time through, creating sun display list\n"); */
|
||||||
ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination);
|
|
||||||
zSun = 60000.0 * sin(sunPos.Declination);
|
|
||||||
|
|
||||||
// xglPushMatrix();
|
sun_obj = xglGenLists(1);
|
||||||
// xglTranslatef(x, y, z);
|
xglNewList(sun_obj, GL_COMPILE );
|
||||||
// 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();
|
xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination);
|
||||||
//xglPopMatrix();
|
ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination);
|
||||||
|
zSun = 60000.0 * sin(sunPos.Declination);
|
||||||
|
|
||||||
glutSolidSphere(1.0, 10, 10);
|
glutSolidSphere(1.0, 10, 10);
|
||||||
|
|
||||||
xglEndList();
|
xglEndList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -204,10 +182,13 @@ void fgSunRender() {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.6 1997/12/15 23:55:04 curt
|
/* Revision 1.7 1997/12/17 23:12:16 curt
|
||||||
/* Add xgl wrappers for debugging.
|
/* Fixed so moon and sun display lists aren't recreate periodically.
|
||||||
/* Generate terrain normals on the fly.
|
|
||||||
/*
|
/*
|
||||||
|
* 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
|
* Revision 1.5 1997/12/12 21:41:31 curt
|
||||||
* More light/material property tweaking ... still a ways off.
|
* More light/material property tweaking ... still a ways off.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue