Compare commits

...

8 Commits

Author SHA1 Message Date
curt
aa17d9ac9a Updated for plib-1.1.x 2000-02-04 21:50:04 +00:00
curt
ffe1d9485e Converted sky colors from floats to GLubytes to try to work around Linux
nVidia bug, with no success. :-(
1999-12-30 16:41:43 +00:00
curt
71abebe837 Use a more standard texture/blend mode combination for sun/moon halos to
avoid render path that's not supported by all cards/drivers.
1999-11-03 15:17:50 +00:00
curt
ca07b64af0 Moved where glBlendFunc() is reset to main.cxx 1999-10-22 15:15:43 +00:00
curt
2fde2ce581 Reset glBlendFunc() here to. 1999-10-22 12:58:39 +00:00
curt
cb0da2ca5e Set glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ; when done drawing
the Sun so that the cloud texture alpha blending will work correctly.
1999-10-22 12:34:06 +00:00
curt
c0422839b9 MSVC++ portability fix. 1999-10-11 21:09:21 +00:00
curt
862b884f02 Various SGI portability tweaks. 1999-10-07 21:08:50 +00:00
6 changed files with 86 additions and 82 deletions

View File

@@ -22,8 +22,6 @@
* $Id$
**************************************************************************/
#include "celestialBody.hxx"
#include "star.hxx"
#include <Debug/logstream.hxx>
#ifdef FG_MATH_EXCEPTION_CLASH
@@ -31,6 +29,10 @@
#endif
#include <math.h>
#include "celestialBody.hxx"
#include "star.hxx"
/**************************************************************************
* void CelestialBody::updatePosition(fgTIME *t, Star *ourSun)
*

View File

@@ -22,10 +22,8 @@
* $Id$
**************************************************************************/
#include <FDM/flight.hxx>
#include <string.h>
#include "moon.hxx"
#include <Debug/logstream.hxx>
#include <Main/options.hxx>
@@ -37,6 +35,9 @@
#endif
#include <math.h>
#include <FDM/flight.hxx>
#include "moon.hxx"
/*************************************************************************
* Moon::Moon(FGTime *t)
@@ -156,27 +157,22 @@ void Moon::setHalo()
for (i=0; i < texWidth; i++) {
for (j=0; j < texWidth; j++) {
double x, y, d;
*p = 0xff;
*(p+1) = 0xff;
*(p+2) = 0xff;
x = fabs((double)(i - (texWidth / 2)));
y = fabs((double)(j - (texWidth / 2)));
d = sqrt((x * x) + (y * y));
if (d < radius)
{
if (d < radius) {
double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
// inverse square looks nice
*p = (int)((double)0xff * (t * t));
*(p+1) = (int)((double) 0xff * (t*t));
*(p+2) = (int)((double) 0xff * (t*t));
*(p+3) = 0x11;
}
else
{
*p = 0x00;
*(p+1) = 0x00;
*(p+2) = 0x00;
*(p+3) = 0x11;
}
*(p+3) = (int)((double) 0x20 * (t*t));
} else {
*(p+3) = 0x00;
}
p += 4;
}
}
@@ -353,7 +349,8 @@ void Moon::newImage()
// Draw the halo...
if (current_options.get_textures())
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, moon_halotexid);

View File

@@ -72,9 +72,9 @@ static float middle_vertex[12][3];
static float outer_vertex[12][3];
static float bottom_vertex[12][3];
static float inner_color[12][4];
static float middle_color[12][4];
static float outer_color[12][4];
static GLubyte inner_color[12][4];
static GLubyte middle_color[12][4];
static GLubyte outer_color[12][4];
// Calculate the sky structure vertices
@@ -168,19 +168,21 @@ void fgSkyColorsInit( void ) {
// printf("sky = %.2f fog = %.2f diff = %.2f\n",
// l->sky_color[j], l->fog_color[j], diff);
inner_color[i][j] = l->sky_color[j] - diff * 0.3;
middle_color[i][j] = l->sky_color[j] - diff * 0.9 + middle_amt[j];
outer_color[i][j] = l->fog_color[j] + outer_amt[j];
inner_color[i][j] = (GLubyte)((l->sky_color[j] - diff * 0.3) * 255);
middle_color[i][j] = (GLubyte)((l->sky_color[j] - diff * 0.9
+ middle_amt[j]) * 255);
outer_color[i][j] = (GLubyte)((l->fog_color[j] + outer_amt[j])
* 255);
if ( inner_color[i][j] > 1.00 ) { inner_color[i][j] = 1.00; }
if ( inner_color[i][j] < 0.10 ) { inner_color[i][j] = 0.10; }
if ( middle_color[i][j] > 1.00 ) { middle_color[i][j] = 1.00; }
if ( middle_color[i][j] < 0.10 ) { middle_color[i][j] = 0.10; }
if ( outer_color[i][j] > 1.00 ) { outer_color[i][j] = 1.00; }
if ( outer_color[i][j] < 0.10 ) { outer_color[i][j] = 0.10; }
if ( inner_color[i][j] > 255 ) { inner_color[i][j] = 255; }
if ( inner_color[i][j] < 25 ) { inner_color[i][j] = 25; }
if ( middle_color[i][j] > 255 ) { middle_color[i][j] = 255; }
if ( middle_color[i][j] < 25 ) { middle_color[i][j] = 25; }
if ( outer_color[i][j] > 255 ) { outer_color[i][j] = 255; }
if ( outer_color[i][j] < 25 ) { outer_color[i][j] = 25; }
}
inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
l->sky_color[3];
(GLubyte)(l->sky_color[3] * 255);
for ( j = 0; j < 3; j++ ) {
outer_amt[j] -= outer_diff[j];
@@ -212,19 +214,21 @@ void fgSkyColorsInit( void ) {
// printf("sky = %.2f fog = %.2f diff = %.2f\n",
// l->sky_color[j], l->fog_color[j], diff);
inner_color[i][j] = l->sky_color[j] - diff * 0.3;
middle_color[i][j] = l->sky_color[j] - diff * 0.9 + middle_amt[j];
outer_color[i][j] = l->fog_color[j] + outer_amt[j];
inner_color[i][j] = (GLubyte)((l->sky_color[j] - diff * 0.3) * 255);
middle_color[i][j] = (GLubyte)((l->sky_color[j] - diff * 0.9
+ middle_amt[j]) * 255);
outer_color[i][j] = (GLubyte)((l->fog_color[j] + outer_amt[j])
* 255);
if ( inner_color[i][j] > 1.00 ) { inner_color[i][j] = 1.00; }
if ( inner_color[i][j] < 0.10 ) { inner_color[i][j] = 0.10; }
if ( middle_color[i][j] > 1.00 ) { middle_color[i][j] = 1.00; }
if ( middle_color[i][j] < 0.10 ) { middle_color[i][j] = 0.10; }
if ( outer_color[i][j] > 1.00 ) { outer_color[i][j] = 1.00; }
if ( outer_color[i][j] < 0.15 ) { outer_color[i][j] = 0.15; }
if ( inner_color[i][j] > 255 ) { inner_color[i][j] = 255; }
if ( inner_color[i][j] < 25 ) { inner_color[i][j] = 25; }
if ( middle_color[i][j] > 255 ) { middle_color[i][j] = 255; }
if ( middle_color[i][j] < 25 ) { middle_color[i][j] = 25; }
if ( outer_color[i][j] > 255 ) { outer_color[i][j] = 255; }
if ( outer_color[i][j] < 35 ) { outer_color[i][j] = 35; }
}
inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
l->sky_color[3];
(GLubyte)(l->sky_color[3] * 255);
for ( j = 0; j < 3; j++ ) {
outer_amt[j] += outer_diff[j];
@@ -261,9 +265,10 @@ void fgSkyInit( void ) {
void fgSkyRender( void ) {
FGInterface *f;
fgLIGHT *l;
float inner_color[4];
float middle_color[4];
float outer_color[4];
GLubyte sky_color[4];
GLubyte inner_color[4];
GLubyte middle_color[4];
GLubyte outer_color[4];
double diff;
int i;
@@ -279,11 +284,12 @@ void fgSkyRender( void ) {
// printf("sky = %.2f fog = %.2f diff = %.2f\n",
// l->sky_color[j], l->adj_fog_color[j], diff);
inner_color[i] = l->sky_color[i] - diff * 0.3;
middle_color[i] = l->sky_color[i] - diff * 0.9;
outer_color[i] = l->adj_fog_color[i];
inner_color[i] = (GLubyte)((l->sky_color[i] - diff * 0.3) * 255);
middle_color[i] = (GLubyte)((l->sky_color[i] - diff * 0.9) * 255);
outer_color[i] = (GLubyte)(l->adj_fog_color[i] * 255);
}
inner_color[3] = middle_color[3] = outer_color[3] = l->adj_fog_color[3];
inner_color[3] = middle_color[3] = outer_color[3] =
(GLubyte)(l->adj_fog_color[3] * 255);
xglPushMatrix();
@@ -302,36 +308,39 @@ void fgSkyRender( void ) {
// Draw inner/center section of sky*/
xglBegin( GL_TRIANGLE_FAN );
for ( i = 0; i < 4; i++ ) {
sky_color[i] = (GLubyte)(l->sky_color[i] * 255);
}
xglColor4fv(l->sky_color);
xglVertex3f(0.0, 0.0, CENTER_ELEV);
for ( i = 11; i >= 0; i-- ) {
xglColor4fv( inner_color );
xglColor4ubv( inner_color );
xglVertex3fv( inner_vertex[i] );
}
xglColor4fv( inner_color );
xglColor4ubv( inner_color );
xglVertex3fv( inner_vertex[11] );
xglEnd();
// Draw the middle ring
xglBegin( GL_TRIANGLE_STRIP );
for ( i = 0; i < 12; i++ ) {
xglColor4fv( middle_color );
xglColor4ubv( middle_color );
// printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
// middle_color[i][0], middle_color[i][1], middle_color[i][2],
// middle_color[i][3]);
// xglColor4f(1.0, 0.0, 0.0, 1.0);
xglVertex3fv( middle_vertex[i] );
xglColor4fv( inner_color );
xglColor4ubv( inner_color );
// printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i,
// inner_color[i][0], inner_color[i][1], inner_color[i][2],
// inner_color[i][3]);
// xglColor4f(0.0, 0.0, 1.0, 1.0);
xglVertex3fv( inner_vertex[i] );
}
xglColor4fv( middle_color );
xglColor4ubv( middle_color );
// xglColor4f(1.0, 0.0, 0.0, 1.0);
xglVertex3fv( middle_vertex[0] );
xglColor4fv( inner_color );
xglColor4ubv( inner_color );
// xglColor4f(0.0, 0.0, 1.0, 1.0);
xglVertex3fv( inner_vertex[0] );
xglEnd();
@@ -339,20 +348,20 @@ void fgSkyRender( void ) {
// Draw the outer ring
xglBegin( GL_TRIANGLE_STRIP );
for ( i = 0; i < 12; i++ ) {
xglColor4fv( outer_color );
xglColor4ubv( outer_color );
xglVertex3fv( outer_vertex[i] );
xglColor4fv( middle_color );
xglColor4ubv( middle_color );
xglVertex3fv( middle_vertex[i] );
}
xglColor4fv( outer_color );
xglColor4ubv( outer_color );
xglVertex3fv( outer_vertex[0] );
xglColor4fv( middle_color );
xglColor4ubv( middle_color );
xglVertex3fv( middle_vertex[0] );
xglEnd();
// Draw the bottom skirt
xglBegin( GL_TRIANGLE_STRIP );
xglColor4fv( outer_color );
xglColor4ubv( outer_color );
for ( i = 0; i < 12; i++ ) {
xglVertex3fv( bottom_vertex[i] );
xglVertex3fv( outer_vertex[i] );

View File

@@ -30,7 +30,7 @@
#endif
#include <ssg.h> // plib include
#include <plib/ssg.h> // plib include
class fgSky : ssgLeaf

View File

@@ -116,26 +116,21 @@ void Star::setTexture()
for (j=0; j < texWidth; j++) {
double x, y, d;
*p = 0xff;
*(p+1) = 0xff;
*(p+2) = 0xff;
x = fabs((double)(i - (texWidth / 2)));
y = fabs((double)(j - (texWidth / 2)));
d = sqrt((x * x) + (y * y));
if (d < radius)
{
if (d < radius) {
double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
// inverse square looks nice
*p = (int)((double)0xff * (t * t));
*(p+1) = (int)((double) 0xff * (t*t));
*(p+2) = (int)((double) 0xff * (t*t));
*(p+3) = (int)((double) 0xff * (t*t));
}
else
{
*p = 0x00;
*(p+1) = 0x00;
*(p+2) = 0x00;
} else {
*(p+3) = 0x00;
}
}
p += 4;
}
}
@@ -235,10 +230,11 @@ void Star::newImage(void)
xglTranslatef(0,60000,0);
if (current_options.get_textures())
{
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
glEnable(GL_BLEND); // BLEND ENABLED
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
glEnable(GL_BLEND); // BLEND ENABLED
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
// glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, sun_texid);
@@ -254,8 +250,8 @@ void Star::newImage(void)
}
glPopMatrix();
glDisable(GL_LIGHTING); //LIGHTING DISABLED
glDisable(GL_BLEND); //BLEND DISABLED
glDisable(GL_LIGHTING); // LIGHTING DISABLED
glDisable(GL_BLEND); // BLEND DISABLED
glPushMatrix();
{
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
@@ -265,7 +261,7 @@ void Star::newImage(void)
gluSphere( SunObject, sun_size, 10, 10 );
}
glPopMatrix();
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
glDisable(GL_BLEND); // BLEND DISABLED
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
glDisable(GL_BLEND); // BLEND DISABLED
}
}

View File

@@ -61,7 +61,7 @@
#include "stars.hxx"
FG_USING_STD(getline);
// FG_USING_STD(getline);
#define EpochStart (631065600)
#define DaysSinceEpoch(secs) (((secs)-EpochStart)*(1.0/(24*3600)))