1
0
Fork 0

Distance attenuation patch from Erik Hofman:

It adds a command line options to enable/disbale distance attenuation
using a property rather than using a #define inside the code. It also
adds a small change for systems that don't support the OpenGL extension,
so that the lights *do* fade away as they get furher away but they don't
get smaller in size.
This commit is contained in:
david 2002-12-30 21:49:56 +00:00
parent e57e85c563
commit e80c093681
2 changed files with 26 additions and 23 deletions

View file

@ -137,8 +137,6 @@ SG_USING_STD(endl);
#include "fg_commands.hxx" #include "fg_commands.hxx"
// #define FG_EXPERIMENTAL_LIGHTING
#ifdef FG_EXPERIMENTAL_LIGHTING
#ifdef WIN32 #ifdef WIN32
typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC)(GLenum pname, typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC)(GLenum pname,
GLfloat param); GLfloat param);
@ -156,7 +154,6 @@ SG_USING_STD(endl);
OpenGLFuncExt glPointParameterfEXT = 0; OpenGLFuncExt glPointParameterfEXT = 0;
OpenGLFuncExtv glPointParameterfvEXT = 0; OpenGLFuncExtv glPointParameterfvEXT = 0;
#endif #endif
#endif
float default_attenuation[3] = {1.0, 0.0, 0.0}; float default_attenuation[3] = {1.0, 0.0, 0.0};
//Required for using GL_extensions //Required for using GL_extensions
@ -741,11 +738,12 @@ void fgRenderFrame() {
glFogf (GL_FOG_DENSITY, rwy_exp2_punch_through); glFogf (GL_FOG_DENSITY, rwy_exp2_punch_through);
ssgSetNearFar( scene_nearplane, scene_farplane ); ssgSetNearFar( scene_nearplane, scene_farplane );
#ifdef FG_EXPERIMENTAL_LIGHTING
// Enable states for drawing points with GL_extension // Enable states for drawing points with GL_extension
glEnable(GL_POINT_SMOOTH); glEnable(GL_POINT_SMOOTH);
if (glutExtensionSupported("GL_EXT_point_parameters")) { if ( fgGetBool("/sim/rendering/distance-attenuation")
&& glutExtensionSupported("GL_EXT_point_parameters") )
{
float quadratic[3] = {1.0, 0.001, 0.0000001}; float quadratic[3] = {1.0, 0.001, 0.0000001};
// makes the points fade as they move away // makes the points fade as they move away
glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, quadratic); glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, quadratic);
@ -755,7 +753,6 @@ void fgRenderFrame() {
// blending function for runway lights // blending function for runway lights
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ; glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
#endif
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
@ -788,15 +785,15 @@ void fgRenderFrame() {
//_frame_count++; //_frame_count++;
#ifdef FG_EXPERIMENTAL_LIGHTING if ( fgGetBool("/sim/rendering/distance-attenuation")
if (glutExtensionSupported("GL_EXT_point_parameters")) { && glutExtensionSupported("GL_EXT_point_parameters") )
{
glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT,
default_attenuation); default_attenuation);
} }
glPointSize(1.0); glPointSize(1.0);
glDisable(GL_POINT_SMOOTH); glDisable(GL_POINT_SMOOTH);
#endif
// draw ground lighting // draw ground lighting
glFogf (GL_FOG_DENSITY, ground_exp2_punch_through); glFogf (GL_FOG_DENSITY, ground_exp2_punch_through);
@ -1595,8 +1592,9 @@ static bool fgMainInit( int argc, char **argv ) {
glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, -0.5 ) ; glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, -0.5 ) ;
#endif #endif
#ifdef FG_EXPERIMENTAL_LIGHTING
// get the address of our OpenGL extensions // get the address of our OpenGL extensions
if ( fgGetBool("/sim/rendering/distance-attenuation") )
{
#ifdef WIN32 #ifdef WIN32
glPointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC) glPointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC)
wglGetProcAddress("glPointParameterfEXT"); wglGetProcAddress("glPointParameterfEXT");
@ -1608,7 +1606,7 @@ static bool fgMainInit( int argc, char **argv ) {
glPointParameterfvEXT = (OpenGLFuncExtv) glPointParameterfvEXT = (OpenGLFuncExtv)
glXGetProcAddressARB((GLubyte *)"glPointParameterfvEXT"); glXGetProcAddressARB((GLubyte *)"glPointParameterfvEXT");
#endif #endif
#endif }
// based on the requested presets, calculate the true starting // based on the requested presets, calculate the true starting
// lon, lat // lon, lat

View file

@ -197,6 +197,7 @@ fgSetDefaults ()
fgSetBool("/sim/rendering/skyblend", true); fgSetBool("/sim/rendering/skyblend", true);
fgSetBool("/sim/rendering/textures", true); fgSetBool("/sim/rendering/textures", true);
fgSetBool("/sim/rendering/wireframe", false); fgSetBool("/sim/rendering/wireframe", false);
fgSetBool("/sim/rendering/distance-attenuation", false);
fgSetInt("/sim/startup/xsize", 800); fgSetInt("/sim/startup/xsize", 800);
fgSetInt("/sim/startup/ysize", 600); fgSetInt("/sim/startup/ysize", 600);
fgSetInt("/sim/rendering/bits-per-pixel", 16); fgSetInt("/sim/rendering/bits-per-pixel", 16);
@ -797,6 +798,10 @@ parse_option (const string& arg)
fgSetString("/sim/rendering/fog", "fastest"); fgSetString("/sim/rendering/fog", "fastest");
} else if ( arg == "--fog-nicest" ) { } else if ( arg == "--fog-nicest" ) {
fgSetString("/sim/fog", "nicest"); fgSetString("/sim/fog", "nicest");
} else if ( arg == "--disable-distance-attenuation" ) {
fgSetBool("/environment/distance-attenuation", false);
} else if ( arg == "--enable-distance-attenuation" ) {
fgSetBool("/environment/distance-attenuation", true);
} else if ( arg == "--disable-clouds" ) { } else if ( arg == "--disable-clouds" ) {
fgSetBool("/environment/clouds/status", false); fgSetBool("/environment/clouds/status", false);
} else if ( arg == "--enable-clouds" ) { } else if ( arg == "--enable-clouds" ) {