Mesa (master): mesa: Add the basics for the NV_fog_distance extension

Marek Olšák mareko at kemper.freedesktop.org
Tue Nov 1 10:40:27 UTC 2011


Module: Mesa
Branch: master
Commit: 740467dd62962b4effdaf51e38edc032e2a39487
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=740467dd62962b4effdaf51e38edc032e2a39487

Author: Nicholas Miell <nmiell at gmail.com>
Date:   Mon Sep 19 23:16:59 2011 -0700

mesa: Add the basics for the NV_fog_distance extension

No driver implements it yet.

---

 src/mesa/main/extensions.c |    1 +
 src/mesa/main/fog.c        |   14 ++++++++++++++
 src/mesa/main/get.c        |    5 +++++
 src/mesa/main/mtypes.h     |    2 ++
 4 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index b0fe4c3..7a9fce8 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -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 },
diff --git a/src/mesa/main/fog.c b/src/mesa/main/fog.c
index 88aa31a..d65add9 100644
--- a/src/mesa/main/fog.c
+++ b/src/mesa/main/fog.c
@@ -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;
 }
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 3c388e5..8925b75 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -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),
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 652bad5..3f3bc4e 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -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;




More information about the mesa-commit mailing list