]> git.mxchange.org Git - flightgear.git/commitdiff
Distance attenuation patch from Erik Hofman:
authordavid <david>
Mon, 30 Dec 2002 21:49:56 +0000 (21:49 +0000)
committerdavid <david>
Mon, 30 Dec 2002 21:49:56 +0000 (21:49 +0000)
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.

src/Main/main.cxx
src/Main/options.cxx

index b265e886da4e70c587bddfdd1d4b0563f8d0fab3..9c6a6ac11633b6abf96ed9d7f5906641255a8b8f 100644 (file)
@@ -137,9 +137,7 @@ SG_USING_STD(endl);
 
 #include "fg_commands.hxx"
 
-// #define FG_EXPERIMENTAL_LIGHTING
-#ifdef FG_EXPERIMENTAL_LIGHTING
-#  ifdef WIN32
+#ifdef WIN32
   typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC)(GLenum pname,
                                                         GLfloat param);
   typedef void (APIENTRY * PFNGLPOINTPARAMETERFVEXTPROC)(GLenum pname,
@@ -147,7 +145,7 @@ SG_USING_STD(endl);
 
   PFNGLPOINTPARAMETERFEXTPROC glPointParameterfEXT = 0;
   PFNGLPOINTPARAMETERFVEXTPROC glPointParameterfvEXT = 0;
-#  elif linux
+#elif linux
   #include <GL/glx.h>
 
   typedef void (* OpenGLFuncExt)(GLenum pname, GLfloat param);
@@ -155,7 +153,6 @@ SG_USING_STD(endl);
 
   OpenGLFuncExt glPointParameterfEXT = 0;
   OpenGLFuncExtv glPointParameterfvEXT = 0;
-#  endif
 #endif
 
 float default_attenuation[3] = {1.0, 0.0, 0.0};
@@ -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,20 +1592,21 @@ 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
-#  ifdef WIN32
-    glPointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC) 
-        wglGetProcAddress("glPointParameterfEXT");
-    glPointParameterfvEXT = (PFNGLPOINTPARAMETERFVEXTPROC) 
-        wglGetProcAddress("glPointParameterfvEXT");
-#  elif linux
-    glPointParameterfEXT = (OpenGLFuncExt) 
-        glXGetProcAddressARB((GLubyte *)"glPointParameterfEXT");
-    glPointParameterfvEXT = (OpenGLFuncExtv) 
-        glXGetProcAddressARB((GLubyte *)"glPointParameterfvEXT");
-#  endif
+    if ( fgGetBool("/sim/rendering/distance-attenuation") )
+    {
+#ifdef WIN32
+        glPointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC) 
+            wglGetProcAddress("glPointParameterfEXT");
+        glPointParameterfvEXT = (PFNGLPOINTPARAMETERFVEXTPROC) 
+            wglGetProcAddress("glPointParameterfvEXT");
+#elif linux
+        glPointParameterfEXT = (OpenGLFuncExt) 
+            glXGetProcAddressARB((GLubyte *)"glPointParameterfEXT");
+        glPointParameterfvEXT = (OpenGLFuncExtv) 
+            glXGetProcAddressARB((GLubyte *)"glPointParameterfvEXT");
 #endif
+   }
 
     // based on the requested presets, calculate the true starting
     // lon, lat
index 832410e1d5fb149521f1502694ccb16c036e7c04..ce2c40f2f6775978d676cd033f5ac1e371a2219c 100644 (file)
@@ -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" ) {