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,9 +137,7 @@ SG_USING_STD(endl);
|
||||||
|
|
||||||
#include "fg_commands.hxx"
|
#include "fg_commands.hxx"
|
||||||
|
|
||||||
// #define FG_EXPERIMENTAL_LIGHTING
|
#ifdef WIN32
|
||||||
#ifdef FG_EXPERIMENTAL_LIGHTING
|
|
||||||
# ifdef WIN32
|
|
||||||
typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC)(GLenum pname,
|
typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC)(GLenum pname,
|
||||||
GLfloat param);
|
GLfloat param);
|
||||||
typedef void (APIENTRY * PFNGLPOINTPARAMETERFVEXTPROC)(GLenum pname,
|
typedef void (APIENTRY * PFNGLPOINTPARAMETERFVEXTPROC)(GLenum pname,
|
||||||
|
@ -147,7 +145,7 @@ SG_USING_STD(endl);
|
||||||
|
|
||||||
PFNGLPOINTPARAMETERFEXTPROC glPointParameterfEXT = 0;
|
PFNGLPOINTPARAMETERFEXTPROC glPointParameterfEXT = 0;
|
||||||
PFNGLPOINTPARAMETERFVEXTPROC glPointParameterfvEXT = 0;
|
PFNGLPOINTPARAMETERFVEXTPROC glPointParameterfvEXT = 0;
|
||||||
# elif linux
|
#elif linux
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
|
|
||||||
typedef void (* OpenGLFuncExt)(GLenum pname, GLfloat param);
|
typedef void (* OpenGLFuncExt)(GLenum pname, GLfloat param);
|
||||||
|
@ -155,7 +153,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};
|
||||||
|
@ -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,20 +1592,21 @@ 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
|
||||||
# ifdef WIN32
|
if ( fgGetBool("/sim/rendering/distance-attenuation") )
|
||||||
glPointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC)
|
{
|
||||||
wglGetProcAddress("glPointParameterfEXT");
|
#ifdef WIN32
|
||||||
glPointParameterfvEXT = (PFNGLPOINTPARAMETERFVEXTPROC)
|
glPointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC)
|
||||||
wglGetProcAddress("glPointParameterfvEXT");
|
wglGetProcAddress("glPointParameterfEXT");
|
||||||
# elif linux
|
glPointParameterfvEXT = (PFNGLPOINTPARAMETERFVEXTPROC)
|
||||||
glPointParameterfEXT = (OpenGLFuncExt)
|
wglGetProcAddress("glPointParameterfvEXT");
|
||||||
glXGetProcAddressARB((GLubyte *)"glPointParameterfEXT");
|
#elif linux
|
||||||
glPointParameterfvEXT = (OpenGLFuncExtv)
|
glPointParameterfEXT = (OpenGLFuncExt)
|
||||||
glXGetProcAddressARB((GLubyte *)"glPointParameterfvEXT");
|
glXGetProcAddressARB((GLubyte *)"glPointParameterfEXT");
|
||||||
# endif
|
glPointParameterfvEXT = (OpenGLFuncExtv)
|
||||||
|
glXGetProcAddressARB((GLubyte *)"glPointParameterfvEXT");
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// based on the requested presets, calculate the true starting
|
// based on the requested presets, calculate the true starting
|
||||||
// lon, lat
|
// lon, lat
|
||||||
|
|
|
@ -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" ) {
|
||||||
|
|
Loading…
Reference in a new issue