From aa688d1579776494640475f4a5b93f3d7fae4fcd Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 30 Jun 2009 12:13:50 +0100 Subject: [PATCH] mesa: add debug printer for primitive name Add a simple version of _mesa_lookup_enum_by_nr() which expects a primitive enum (GL_POINTS..GL_POLYGON). This avoids some annoying duplicates when looking up primitives, such as the GL_FALSE/GL_POINTS clash. --- src/mesa/main/enums.c | 22 ++++++++++++++++++++++ src/mesa/main/enums.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index cf893fdac51..417cee8fb2a 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -5059,6 +5059,28 @@ const char *_mesa_lookup_enum_by_nr( int nr ) } } +/* Get the name of an enum given that it is a primitive type. Avoids + * GL_FALSE/GL_POINTS ambiguity and others. + */ +const char *_mesa_lookup_prim_by_nr( int nr ) +{ + switch (nr) { + case GL_POINTS: return "GL_POINTS"; + case GL_LINES: return "GL_LINES"; + case GL_LINE_STRIP: return "GL_LINE_STRIP"; + case GL_LINE_LOOP: return "GL_LINE_LOOP"; + case GL_TRIANGLES: return "GL_TRIANGLES"; + case GL_TRIANGLE_STRIP: return "GL_TRIANGLE_STRIP"; + case GL_TRIANGLE_FAN: return "GL_TRIANGLE_FAN"; + case GL_QUADS: return "GL_QUADS"; + case GL_QUAD_STRIP: return "GL_QUAD_STRIP"; + case GL_POLYGON: return "GL_POLYGON"; + case GL_POLYGON+1: return "OUTSIDE_BEGIN_END"; + default: return ""; + } +} + + int _mesa_lookup_enum_by_name( const char *symbol ) { enum_elt * f = NULL; diff --git a/src/mesa/main/enums.h b/src/mesa/main/enums.h index 23a4767f350..b5f69001b84 100644 --- a/src/mesa/main/enums.h +++ b/src/mesa/main/enums.h @@ -40,6 +40,12 @@ #if defined(_HAVE_FULL_GL) && _HAVE_FULL_GL extern const char *_mesa_lookup_enum_by_nr( int nr ); + +/* Get the name of an enum given that it is a primitive type. Avoids + * GL_FALSE/GL_POINTS ambiguity and others. + */ +const char *_mesa_lookup_prim_by_nr( int nr ); + extern int _mesa_lookup_enum_by_name( const char *symbol ); #else -- 2.30.2