added missing error checks
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 17 Mar 2000 15:32:04 +0000 (15:32 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 17 Mar 2000 15:32:04 +0000 (15:32 +0000)
src/mesa/main/hint.c

index eeed3f8afa0dd5907c2cb8965a330a4ee4b1bea9..3ea2a86181fcf286c54d263f91de18f32c29b34e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: hint.c,v 1.1 2000/02/02 19:14:56 brianp Exp $ */
+/* $Id: hint.c,v 1.2 2000/03/17 15:32:04 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -53,78 +53,84 @@ _mesa_try_Hint( GLcontext *ctx, GLenum target, GLenum mode )
    if (MESA_VERBOSE & VERBOSE_API)
       fprintf(stderr, "glHint %s %d\n", gl_lookup_enum_by_nr(target), mode);
 
-   switch (target) {
-   case GL_FOG_HINT:
-      ctx->Hint.Fog = mode;
-      break;
-   case GL_LINE_SMOOTH_HINT:
-      ctx->Hint.LineSmooth = mode;
-      break;
-   case GL_PERSPECTIVE_CORRECTION_HINT:
-      ctx->Hint.PerspectiveCorrection = mode;
-      break;
-   case GL_POINT_SMOOTH_HINT:
-      ctx->Hint.PointSmooth = mode;
-      break;
-   case GL_POLYGON_SMOOTH_HINT:
-      ctx->Hint.PolygonSmooth = mode;
-      break;
-   case GL_PREFER_DOUBLEBUFFER_HINT_PGI:
-   case GL_STRICT_DEPTHFUNC_HINT_PGI:
-      break;
-   case GL_STRICT_LIGHTING_HINT_PGI:
-      ctx->Hint.StrictLighting = mode;
-      break;
-   case GL_STRICT_SCISSOR_HINT_PGI:
-   case GL_FULL_STIPPLE_HINT_PGI:
-   case GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI:
-   case GL_NATIVE_GRAPHICS_END_HINT_PGI:
-   case GL_CONSERVE_MEMORY_HINT_PGI:
-   case GL_RECLAIM_MEMORY_HINT_PGI:
-      break;
-   case GL_ALWAYS_FAST_HINT_PGI:
-      if (mode) {
-        ctx->Hint.AllowDrawWin = GL_TRUE;
-        ctx->Hint.AllowDrawSpn = GL_FALSE;
-        ctx->Hint.AllowDrawMem = GL_FALSE;
-      } else {
-        ctx->Hint.AllowDrawWin = GL_TRUE;
-        ctx->Hint.AllowDrawSpn = GL_TRUE;
-        ctx->Hint.AllowDrawMem = GL_TRUE;
-      } 
-      break;
-   case GL_ALWAYS_SOFT_HINT_PGI:
-      ctx->Hint.AllowDrawWin = GL_TRUE;
-      ctx->Hint.AllowDrawSpn = GL_TRUE;
-      ctx->Hint.AllowDrawMem = GL_TRUE;
-      break;
-   case GL_ALLOW_DRAW_OBJ_HINT_PGI:
-      break;
-   case GL_ALLOW_DRAW_WIN_HINT_PGI:
-      ctx->Hint.AllowDrawWin = mode;
-      break;
-   case GL_ALLOW_DRAW_SPN_HINT_PGI:
-      ctx->Hint.AllowDrawSpn = mode;
-      break;
-   case GL_ALLOW_DRAW_MEM_HINT_PGI:
-      ctx->Hint.AllowDrawMem = mode;
-      break;
-   case GL_CLIP_NEAR_HINT_PGI:
-   case GL_CLIP_FAR_HINT_PGI:
-   case GL_WIDE_LINE_HINT_PGI:
-   case GL_BACK_NORMALS_HINT_PGI:
-   case GL_NATIVE_GRAPHICS_HANDLE_PGI:
-      break;
-
-      /* GL_EXT_clip_volume_hint */
-   case GL_CLIP_VOLUME_CLIPPING_HINT_EXT:
-      ctx->Hint.ClipVolumeClipping = mode;
-      break;
-
-   default:
-      gl_error( ctx, GL_INVALID_ENUM, "glHint(target)" );
+   if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) {
+      gl_error(ctx, GL_INVALID_ENUM, "glHint(mode)");
       return GL_FALSE;
    }
+
+   switch (target) {
+      case GL_FOG_HINT:
+         ctx->Hint.Fog = mode;
+         break;
+      case GL_LINE_SMOOTH_HINT:
+         ctx->Hint.LineSmooth = mode;
+         break;
+      case GL_PERSPECTIVE_CORRECTION_HINT:
+         ctx->Hint.PerspectiveCorrection = mode;
+         break;
+      case GL_POINT_SMOOTH_HINT:
+         ctx->Hint.PointSmooth = mode;
+         break;
+      case GL_POLYGON_SMOOTH_HINT:
+         ctx->Hint.PolygonSmooth = mode;
+         break;
+      case GL_PREFER_DOUBLEBUFFER_HINT_PGI:
+      case GL_STRICT_DEPTHFUNC_HINT_PGI:
+         break;
+      case GL_STRICT_LIGHTING_HINT_PGI:
+         ctx->Hint.StrictLighting = mode;
+         break;
+      case GL_STRICT_SCISSOR_HINT_PGI:
+      case GL_FULL_STIPPLE_HINT_PGI:
+      case GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI:
+      case GL_NATIVE_GRAPHICS_END_HINT_PGI:
+      case GL_CONSERVE_MEMORY_HINT_PGI:
+      case GL_RECLAIM_MEMORY_HINT_PGI:
+         break;
+      case GL_ALWAYS_FAST_HINT_PGI:
+         if (mode) {
+            ctx->Hint.AllowDrawWin = GL_TRUE;
+            ctx->Hint.AllowDrawSpn = GL_FALSE;
+            ctx->Hint.AllowDrawMem = GL_FALSE;
+         } else {
+            ctx->Hint.AllowDrawWin = GL_TRUE;
+            ctx->Hint.AllowDrawSpn = GL_TRUE;
+            ctx->Hint.AllowDrawMem = GL_TRUE;
+         } 
+         break;
+      case GL_ALWAYS_SOFT_HINT_PGI:
+         ctx->Hint.AllowDrawWin = GL_TRUE;
+         ctx->Hint.AllowDrawSpn = GL_TRUE;
+         ctx->Hint.AllowDrawMem = GL_TRUE;
+         break;
+      case GL_ALLOW_DRAW_OBJ_HINT_PGI:
+         break;
+      case GL_ALLOW_DRAW_WIN_HINT_PGI:
+         ctx->Hint.AllowDrawWin = mode;
+         break;
+      case GL_ALLOW_DRAW_SPN_HINT_PGI:
+         ctx->Hint.AllowDrawSpn = mode;
+         break;
+      case GL_ALLOW_DRAW_MEM_HINT_PGI:
+         ctx->Hint.AllowDrawMem = mode;
+         break;
+      case GL_CLIP_NEAR_HINT_PGI:
+      case GL_CLIP_FAR_HINT_PGI:
+      case GL_WIDE_LINE_HINT_PGI:
+      case GL_BACK_NORMALS_HINT_PGI:
+      case GL_NATIVE_GRAPHICS_HANDLE_PGI:
+         break;
+
+         /* GL_EXT_clip_volume_hint */
+      case GL_CLIP_VOLUME_CLIPPING_HINT_EXT:
+         ctx->Hint.ClipVolumeClipping = mode;
+         break;
+
+      default:
+         gl_error( ctx, GL_INVALID_ENUM, "glHint(target)" );
+         return GL_FALSE;
+   }
+
    ctx->NewState |= NEW_ALL;   /* just to be safe */
 
    if (ctx->Driver.Hint) {
@@ -144,6 +150,11 @@ _mesa_HintPGI( GLenum target, GLint mode )
    if (MESA_VERBOSE & VERBOSE_API)
       fprintf(stderr, "glHintPGI %s %d\n", gl_lookup_enum_by_nr(target), mode);
 
+   if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) {
+      gl_error(ctx, GL_INVALID_ENUM, "glHintPGI(mode)");
+      return;
+   }
+
    switch (target) {
       case GL_PREFER_DOUBLEBUFFER_HINT_PGI:
       case GL_STRICT_DEPTHFUNC_HINT_PGI: