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:
parent
e57e85c563
commit
e80c093681
2 changed files with 26 additions and 23 deletions
|
@ -137,8 +137,6 @@ SG_USING_STD(endl);
|
|||
|
||||
#include "fg_commands.hxx"
|
||||
|
||||
// #define FG_EXPERIMENTAL_LIGHTING
|
||||
#ifdef FG_EXPERIMENTAL_LIGHTING
|
||||
#ifdef WIN32
|
||||
typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC)(GLenum pname,
|
||||
GLfloat param);
|
||||
|
@ -156,7 +154,6 @@ SG_USING_STD(endl);
|
|||
OpenGLFuncExt glPointParameterfEXT = 0;
|
||||
OpenGLFuncExtv glPointParameterfvEXT = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float default_attenuation[3] = {1.0, 0.0, 0.0};
|
||||
//Required for using GL_extensions
|
||||
|
@ -741,11 +738,12 @@ void fgRenderFrame() {
|
|||
glFogf (GL_FOG_DENSITY, rwy_exp2_punch_through);
|
||||
ssgSetNearFar( scene_nearplane, scene_farplane );
|
||||
|
||||
#ifdef FG_EXPERIMENTAL_LIGHTING
|
||||
// Enable states for drawing points with GL_extension
|
||||
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};
|
||||
// makes the points fade as they move away
|
||||
glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, quadratic);
|
||||
|
@ -755,7 +753,6 @@ void fgRenderFrame() {
|
|||
|
||||
// blending function for runway lights
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
|
||||
#endif
|
||||
|
||||
glTexGeni(GL_S, 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++;
|
||||
|
||||
|
||||
#ifdef FG_EXPERIMENTAL_LIGHTING
|
||||
if (glutExtensionSupported("GL_EXT_point_parameters")) {
|
||||
if ( fgGetBool("/sim/rendering/distance-attenuation")
|
||||
&& glutExtensionSupported("GL_EXT_point_parameters") )
|
||||
{
|
||||
glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT,
|
||||
default_attenuation);
|
||||
}
|
||||
|
||||
glPointSize(1.0);
|
||||
glDisable(GL_POINT_SMOOTH);
|
||||
#endif
|
||||
|
||||
// draw ground lighting
|
||||
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 ) ;
|
||||
#endif
|
||||
|
||||
#ifdef FG_EXPERIMENTAL_LIGHTING
|
||||
// get the address of our OpenGL extensions
|
||||
if ( fgGetBool("/sim/rendering/distance-attenuation") )
|
||||
{
|
||||
#ifdef WIN32
|
||||
glPointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC)
|
||||
wglGetProcAddress("glPointParameterfEXT");
|
||||
|
@ -1608,7 +1606,7 @@ static bool fgMainInit( int argc, char **argv ) {
|
|||
glPointParameterfvEXT = (OpenGLFuncExtv)
|
||||
glXGetProcAddressARB((GLubyte *)"glPointParameterfvEXT");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
// based on the requested presets, calculate the true starting
|
||||
// lon, lat
|
||||
|
|
|
@ -197,6 +197,7 @@ fgSetDefaults ()
|
|||
fgSetBool("/sim/rendering/skyblend", true);
|
||||
fgSetBool("/sim/rendering/textures", true);
|
||||
fgSetBool("/sim/rendering/wireframe", false);
|
||||
fgSetBool("/sim/rendering/distance-attenuation", false);
|
||||
fgSetInt("/sim/startup/xsize", 800);
|
||||
fgSetInt("/sim/startup/ysize", 600);
|
||||
fgSetInt("/sim/rendering/bits-per-pixel", 16);
|
||||
|
@ -797,6 +798,10 @@ parse_option (const string& arg)
|
|||
fgSetString("/sim/rendering/fog", "fastest");
|
||||
} else if ( arg == "--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" ) {
|
||||
fgSetBool("/environment/clouds/status", false);
|
||||
} else if ( arg == "--enable-clouds" ) {
|
||||
|
|
Loading…
Reference in a new issue