Use a more standard texture/blend mode combination for sun/moon halos to

avoid render path that's not supported by all cards/drivers.
This commit is contained in:
curt
1999-11-03 15:17:50 +00:00
parent ca07b64af0
commit 71abebe837
2 changed files with 21 additions and 29 deletions
+12 -16
View File
@@ -157,27 +157,22 @@ void Moon::setHalo()
for (i=0; i < texWidth; i++) { for (i=0; i < texWidth; i++) {
for (j=0; j < texWidth; j++) { for (j=0; j < texWidth; j++) {
double x, y, d; double x, y, d;
*p = 0xff;
*(p+1) = 0xff;
*(p+2) = 0xff;
x = fabs((double)(i - (texWidth / 2))); x = fabs((double)(i - (texWidth / 2)));
y = fabs((double)(j - (texWidth / 2))); y = fabs((double)(j - (texWidth / 2)));
d = sqrt((x * x) + (y * y)); 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 */ double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
// inverse square looks nice // inverse square looks nice
*p = (int)((double)0xff * (t * t)); *(p+3) = (int)((double) 0x20 * (t*t));
*(p+1) = (int)((double) 0xff * (t*t)); } else {
*(p+2) = (int)((double) 0xff * (t*t)); *(p+3) = 0x00;
*(p+3) = 0x11; }
}
else
{
*p = 0x00;
*(p+1) = 0x00;
*(p+2) = 0x00;
*(p+3) = 0x11;
}
p += 4; p += 4;
} }
} }
@@ -354,7 +349,8 @@ void Moon::newImage()
// Draw the halo... // Draw the halo...
if (current_options.get_textures()) 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 glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, moon_halotexid); glBindTexture(GL_TEXTURE_2D, moon_halotexid);
+9 -13
View File
@@ -116,26 +116,21 @@ void Star::setTexture()
for (j=0; j < texWidth; j++) { for (j=0; j < texWidth; j++) {
double x, y, d; double x, y, d;
*p = 0xff;
*(p+1) = 0xff;
*(p+2) = 0xff;
x = fabs((double)(i - (texWidth / 2))); x = fabs((double)(i - (texWidth / 2)));
y = fabs((double)(j - (texWidth / 2))); y = fabs((double)(j - (texWidth / 2)));
d = sqrt((x * x) + (y * y)); 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 */ double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
// inverse square looks nice // 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)); *(p+3) = (int)((double) 0xff * (t*t));
} } else {
else
{
*p = 0x00;
*(p+1) = 0x00;
*(p+2) = 0x00;
*(p+3) = 0x00; *(p+3) = 0x00;
} }
p += 4; p += 4;
} }
} }
@@ -238,7 +233,8 @@ void Star::newImage(void)
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
glEnable(GL_BLEND); // BLEND 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); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, sun_texid); glBindTexture(GL_TEXTURE_2D, sun_texid);