[Mesa-dev] [PATCH 1/8] mesa: fix error handling for glBegin

Yuanhan Liu yuanhan.liu at linux.intel.com
Mon Sep 19 19:39:47 PDT 2011


On Mon, Sep 19, 2011 at 08:09:09AM -0600, Brian Paul wrote:
> On 09/19/2011 01:02 AM, Yuanhan Liu wrote:
> >According to opengl spec, trigger GL_INVALID_ENUM error if mode is not
> >one of those valid primitive mode while calling glBegin.
> >
> >Signed-off-by: Yuanhan Liu<yuanhan.liu at linux.intel.com>
> >---
> >  src/mesa/vbo/vbo_exec_api.c |   24 ++++++++++++++++++++++++
> >  1 files changed, 24 insertions(+), 0 deletions(-)
> >
> >diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
> >index cad7c46..72f9661 100644
> >--- a/src/mesa/vbo/vbo_exec_api.c
> >+++ b/src/mesa/vbo/vbo_exec_api.c
> >@@ -552,6 +552,25 @@ static void GLAPIENTRY vbo_exec_EvalPoint2( GLint i, GLint j )
> >  #endif /* FEATURE_evaluators */
> >
> >
> >+static GLboolean _mesa_valid_prim_mode(GLenum mode)
> >+{
> >+   switch(mode) {
> >+      case GL_POINTS:
> >+      case GL_LINES:
> >+      case GL_LINE_LOOP:
> >+      case GL_LINE_STRIP:
> >+      case GL_TRIANGLES:
> >+      case GL_TRIANGLE_STRIP:
> >+      case GL_TRIANGLE_FAN:
> >+      case GL_QUADS:
> >+      case GL_QUAD_STRIP:
> >+      case GL_POLYGON:
> >+         return GL_TRUE;
> >+      default:
> >+         return GL_FALSE;
> >+   }
> >+}
> >+
> >  /**
> >   * Called via glBegin.
> >   */
> >@@ -570,6 +589,11 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode )
> >  	 return;
> >        }
> >
> >+      if (!_mesa_valid_prim_mode(mode)) {
> >+         _mesa_error(ctx, GL_INVALID_ENUM, "glBegin");
> >+         return;
> >+      }
> >+
> >        if (!_mesa_valid_to_render(ctx, "glBegin")) {
> >           return;
> >        }
> 
> I think we're actually validating the prim mode elsewhere, but it
> looks like we're not generating GL_INVALID_ENUM as we should.  Could
> you investigate this a bit further?



More information about the mesa-dev mailing list