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

Yuanhan Liu yuanhan.liu at linux.intel.com
Mon Sep 19 00:02:57 PDT 2011


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;
       }
-- 
1.7.4.4



More information about the mesa-dev mailing list