diff options
author | Ian Romanick <[email protected]> | 2012-07-25 07:12:33 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2012-08-29 15:09:34 -0700 |
commit | 72e076cb17e47c608fa6534641653cdc6133fb27 (patch) | |
tree | 3bdab0f4e1ac63b6f8b2e5afeab8ff62580981c9 /src/mesa | |
parent | 01497a356048ce23e089ad8ab8ab0102aae97b3c (diff) |
mesa: Refactor _mesa_valid_prim_mode to use a switch-statement
This makes the next change a bit easier.
Signed-off-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/api_validate.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index b15dfba73a0..362cdf50e7e 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -22,6 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include <stdbool.h> #include "glheader.h" #include "api_validate.h" #include "bufferobj.h" @@ -209,12 +210,33 @@ check_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type, GLboolean _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) { - if (ctx->Extensions.ARB_geometry_shader4 && - mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(mode=%x)", name, mode); - return GL_FALSE; + bool valid_enum; + + 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: + valid_enum = true; + break; + case GL_LINES_ADJACENCY: + case GL_LINE_STRIP_ADJACENCY: + case GL_TRIANGLES_ADJACENCY: + case GL_TRIANGLE_STRIP_ADJACENCY: + valid_enum = (ctx->Extensions.ARB_geometry_shader4); + break; + default: + valid_enum = false; + break; } - else if (mode > GL_POLYGON) { + + if (!valid_enum) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(mode=%x)", name, mode); return GL_FALSE; } |