[Mesa-dev] [PATCH 1/3] Add the basics for the NV_fog_distance extension
Nicholas Miell
nmiell at gmail.com
Mon Sep 19 23:16:59 PDT 2011
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 81bbca2..1416234 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -286,6 +286,7 @@ static const struct extension extension_table[] = {
{ "GL_NV_blend_square", o(NV_blend_square), GL, 1999 },
{ "GL_NV_conditional_render", o(NV_conditional_render), GL, 2008 },
{ "GL_NV_depth_clamp", o(ARB_depth_clamp), GL, 2001 },
+ { "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 45b2777..2089a81 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -291,6 +291,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_lod_bias);
EXTRA_EXT(EXT_texture_filter_anisotropic);
EXTRA_EXT(IBM_rasterpos_clip);
@@ -949,6 +950,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 3b44ec6..7f019fc 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -905,6 +905,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 */
};
@@ -2901,6 +2902,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;
--
1.7.6.2
More information about the mesa-dev
mailing list