mesa: Add the basics for the NV_fog_distance extension
authorNicholas Miell <nmiell@gmail.com>
Tue, 20 Sep 2011 06:16:59 +0000 (23:16 -0700)
committerMarek Olšák <maraeo@gmail.com>
Tue, 1 Nov 2011 10:37:10 +0000 (11:37 +0100)
No driver implements it yet.

src/mesa/main/extensions.c
src/mesa/main/fog.c
src/mesa/main/get.c
src/mesa/main/mtypes.h

index b0fe4c3..7a9fce8 100644 (file)
@@ -287,6 +287,7 @@ static const struct extension extension_table[] = {
    { "GL_NV_depth_clamp",                          o(ARB_depth_clamp),                         GL,             2001 },
    { "GL_NV_draw_buffers",                         o(dummy_true),                                         ES2, 2011 },
    { "GL_NV_fbo_color_attachments",                o(EXT_framebuffer_object),                             ES2, 2010 },
+   { "GL_NV_fog_distance",                         o(NV_fog_distance),                         GL,             2001 },
    { "GL_NV_fragment_program",                     o(NV_fragment_program),                     GL,             2001 },
    { "GL_NV_fragment_program_option",              o(NV_fragment_program_option),              GL,             2005 },
    { "GL_NV_light_max_exponent",                   o(NV_light_max_exponent),                   GL,             1999 },
index 88aa31a..d65add9 100644 (file)
@@ -172,6 +172,19 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
         ctx->Fog.FogCoordinateSource = p;
         break;
       }
+      case GL_FOG_DISTANCE_MODE_NV: {
+        GLenum p = (GLenum) (GLint) *params;
+         if (!ctx->Extensions.NV_fog_distance ||
+             (p != GL_EYE_RADIAL_NV && p != GL_EYE_PLANE && p != GL_EYE_PLANE_ABSOLUTE_NV)) {
+           _mesa_error(ctx, GL_INVALID_ENUM, "glFog");
+           return;
+        }
+        if (ctx->Fog.FogDistanceMode == p)
+           return;
+        FLUSH_VERTICES(ctx, _NEW_FOG);
+        ctx->Fog.FogDistanceMode = p;
+        break;
+      }
       default:
          _mesa_error( ctx, GL_INVALID_ENUM, "glFog" );
          return;
@@ -201,4 +214,5 @@ void _mesa_init_fog( struct gl_context * ctx )
    ctx->Fog.ColorSumEnabled = GL_FALSE;
    ctx->Fog.FogCoordinateSource = GL_FRAGMENT_DEPTH_EXT;
    ctx->Fog._Scale = 1.0f;
+   ctx->Fog.FogDistanceMode = GL_EYE_PLANE_ABSOLUTE_NV;
 }
index 3c388e5..8925b75 100644 (file)
@@ -295,6 +295,7 @@ EXTRA_EXT(MESA_texture_array);
 EXTRA_EXT2(EXT_secondary_color, ARB_vertex_program);
 EXTRA_EXT(EXT_secondary_color);
 EXTRA_EXT(EXT_fog_coord);
+EXTRA_EXT(NV_fog_distance);
 EXTRA_EXT(EXT_texture_filter_anisotropic);
 EXTRA_EXT(IBM_rasterpos_clip);
 EXTRA_EXT(NV_point_sprite);
@@ -972,6 +973,10 @@ static const struct value_desc values[] = {
    { GL_FOG_COORDINATE_SOURCE_EXT, CONTEXT_ENUM(Fog.FogCoordinateSource),
      extra_EXT_fog_coord },
 
+   /* GL_NV_fog_distance */
+   { GL_FOG_DISTANCE_MODE_NV, CONTEXT_ENUM(Fog.FogDistanceMode),
+     extra_NV_fog_distance },
+
    /* GL_IBM_rasterpos_clip */
    { GL_RASTER_POSITION_UNCLIPPED_IBM,
      CONTEXT_BOOL(Transform.RasterPositionUnclipped),
index 652bad5..3f3bc4e 100644 (file)
@@ -884,6 +884,7 @@ struct gl_fog_attrib
    GLboolean ColorSumEnabled;
    GLenum FogCoordinateSource;  /**< GL_EXT_fog_coord */
    GLfloat _Scale;             /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
+   GLenum FogDistanceMode;     /**< GL_NV_fog_distance */
 };
 
 
@@ -2902,6 +2903,7 @@ struct gl_extensions
    GLboolean MESA_texture_array;
    GLboolean NV_blend_square;
    GLboolean NV_conditional_render;
+   GLboolean NV_fog_distance;
    GLboolean NV_fragment_program;
    GLboolean NV_fragment_program_option;
    GLboolean NV_light_max_exponent;