summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2012-07-27 12:37:05 -0700
committerIan Romanick <[email protected]>2012-08-29 15:09:35 -0700
commit10e7db1ccf4d3b2023f04663f7a6c079eb6afc57 (patch)
treeab2f9703af2482ebfcdffc5945c8fadb11730147 /src
parentb7c7e5e45a14ed78eda104ebca25072172730645 (diff)
mesa/es: Validate glFog pname in Mesa code rather than the ES wrapper
Signed-off-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/APIspec.xml23
-rw-r--r--src/mesa/main/es1_conversion.c28
-rw-r--r--src/mesa/main/fog.c15
3 files changed, 12 insertions, 54 deletions
diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
index 1bc7e2a77d3..b37470d94ae 100644
--- a/src/mesa/main/APIspec.xml
+++ b/src/mesa/main/APIspec.xml
@@ -58,29 +58,6 @@
<param name="param" type="GLtype"/>
</vector>
</proto>
-
- <desc name="pname">
- <value name="GL_FOG_MODE"/>
- <desc name="param">
- <value name="GL_EXP"/>
- <value name="GL_EXP2"/>
- <value name="GL_LINEAR"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_FOG_COLOR"/>
-
- <desc name="params" vector_size="4"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_FOG_DENSITY"/>
- <value name="GL_FOG_START"/>
- <value name="GL_FOG_END"/>
-
- <desc name="params" vector_size="1"/>
- </desc>
</template>
<template name="FrontFace">
diff --git a/src/mesa/main/es1_conversion.c b/src/mesa/main/es1_conversion.c
index 75cdfc88711..c1d7b83306c 100644
--- a/src/mesa/main/es1_conversion.c
+++ b/src/mesa/main/es1_conversion.c
@@ -134,28 +134,7 @@ _es_DrawTexxvOES(const GLfixed *coords)
void GL_APIENTRY
_es_Fogx(GLenum pname, GLfixed param)
{
- bool convert_param_value = true;
-
- switch(pname) {
- case GL_FOG_MODE:
- if (param != GL_EXP && param != GL_EXP2 && param != GL_LINEAR) {
- _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
- "glFogx(pname=0x%x)", pname);
- return;
- }
- convert_param_value = false;
- break;
- case GL_FOG_DENSITY:
- case GL_FOG_START:
- case GL_FOG_END:
- break;
- default:
- _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
- "glFogx(pname=0x%x)", pname);
- return;
- }
-
- if (convert_param_value) {
+ if (pname != GL_FOG_MODE) {
_mesa_Fogf(pname, (GLfloat) (param / 65536.0f));
} else {
_mesa_Fogf(pname, (GLfloat) param);
@@ -173,11 +152,6 @@ _es_Fogxv(GLenum pname, const GLfixed *params)
switch(pname) {
case GL_FOG_MODE:
- if (params[0] != GL_EXP && params[0] != GL_EXP2 && params[0] != GL_LINEAR) {
- _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
- "glFogxv(pname=0x%x)", pname);
- return;
- }
convert_params_value = false;
n_params = 1;
break;
diff --git a/src/mesa/main/fog.c b/src/mesa/main/fog.c
index d65add9302d..07405fb4b42 100644
--- a/src/mesa/main/fog.c
+++ b/src/mesa/main/fog.c
@@ -141,6 +141,8 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
update_fog_scale(ctx);
break;
case GL_FOG_INDEX:
+ if (ctx->API != API_OPENGL)
+ goto invalid_pname;
if (ctx->Fog.Index == *params)
return;
FLUSH_VERTICES(ctx, _NEW_FOG);
@@ -161,7 +163,7 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
break;
case GL_FOG_COORDINATE_SOURCE_EXT: {
GLenum p = (GLenum) (GLint) *params;
- if (!ctx->Extensions.EXT_fog_coord ||
+ if (ctx->API != API_OPENGL || !ctx->Extensions.EXT_fog_coord ||
(p != GL_FOG_COORDINATE_EXT && p != GL_FRAGMENT_DEPTH_EXT)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glFog");
return;
@@ -174,7 +176,7 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
}
case GL_FOG_DISTANCE_MODE_NV: {
GLenum p = (GLenum) (GLint) *params;
- if (!ctx->Extensions.NV_fog_distance ||
+ if (ctx->API != API_OPENGL || !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;
@@ -186,13 +188,18 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
break;
}
default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glFog" );
- return;
+ goto invalid_pname;
}
if (ctx->Driver.Fogfv) {
(*ctx->Driver.Fogfv)( ctx, pname, params );
}
+
+ return;
+
+invalid_pname:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glFog" );
+ return;
}