From 24ebf10de386ec871a0afe99cd77cb796360d05c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 18 Mar 2013 17:49:43 -0600 Subject: texunits: clean-up GL error checking code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use piglit_check_gl_error(). Reviewed-by: José Fonseca --- tests/general/texunits.c | 46 ++++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/tests/general/texunits.c b/tests/general/texunits.c index e419bded..6eca7b58 100644 --- a/tests/general/texunits.c +++ b/tests/general/texunits.c @@ -106,7 +106,6 @@ clear_errors() static GLboolean test_rasterpos(void) { - GLenum err; int i; clear_errors(); @@ -143,9 +142,8 @@ test_rasterpos(void) } /* there should be no errors at this point */ - err = glGetError(); - if (err != GL_NO_ERROR) { - printf("Unexpected GL error in %s(): 0x%x\n", __FUNCTION__, err); + if (!piglit_check_gl_error(GL_NO_ERROR)) { + return GL_FALSE; } /* this should generate an error */ @@ -154,17 +152,14 @@ test_rasterpos(void) glActiveTexture(GL_TEXTURE0 + MaxTextureCoordUnits); if (MaxTextureCoordUnits == MaxTextureCombinedUnits) { /* INVALID_ENUM is expected */ - err = glGetError(); - if (err != GL_INVALID_ENUM) { - printf("GL failed to raise GL_INVALID_ENUM setting texture unit\n"); + if (!piglit_check_gl_error(GL_INVALID_ENUM)) { return GL_FALSE; } } else { /* INVALID_OPERATION is expected */ glGetFloatv(GL_CURRENT_RASTER_TEXTURE_COORDS, v); - if (glGetError() != GL_INVALID_OPERATION) { - printf("GL failed to raise GL_INVALID_OPERATION quering invalid raster tex coords\n"); + if (!piglit_check_gl_error(GL_INVALID_OPERATION)) { return GL_FALSE; } } @@ -177,7 +172,6 @@ test_rasterpos(void) static GLboolean test_texture_matrix(void) { - GLenum err; int i; clear_errors(); @@ -201,9 +195,8 @@ test_texture_matrix(void) } /* there should be no errors at this point */ - err = glGetError(); - if (err != GL_NO_ERROR) { - printf("Unexpected GL error in %s(): 0x%x\n", __FUNCTION__, err); + if (!piglit_check_gl_error(GL_NO_ERROR)) { + return GL_FALSE; } /* this should generate an error */ @@ -212,17 +205,14 @@ test_texture_matrix(void) glActiveTexture(GL_TEXTURE0 + MaxTextureCoordUnits); if (MaxTextureCoordUnits == MaxTextureCombinedUnits) { /* INVALID_ENUM is expected */ - err = glGetError(); - if (err != GL_INVALID_ENUM) { - printf("GL failed to raise GL_INVALID_ENUM setting texture unit\n"); + if (!piglit_check_gl_error(GL_INVALID_ENUM)) { return GL_FALSE; } } else { /* INVALID_OPERATION is expected */ glGetFloatv(GL_TEXTURE_MATRIX, m); - if (glGetError() != GL_INVALID_OPERATION) { - printf("GL failed to raise GL_INVALID_OPERATION querying invalid texture matrix\n"); + if (!piglit_check_gl_error(GL_INVALID_OPERATION)) { return GL_FALSE; } } @@ -236,7 +226,6 @@ static GLboolean test_texture_params(void) { GLuint tex[MAX_UNITS]; - GLenum err; int i; int maxUnit; @@ -266,9 +255,8 @@ test_texture_params(void) } /* there should be no errors at this point */ - err = glGetError(); - if (err != GL_NO_ERROR) { - printf("Unexpected GL error in %s(): 0x%x\n", __FUNCTION__, err); + if (!piglit_check_gl_error(GL_NO_ERROR)) { + return GL_FALSE; } maxUnit = MAX2(MaxTextureCombinedUnits, MaxTextureCoordUnits); @@ -276,9 +264,7 @@ test_texture_params(void) /* this should generate an error */ glActiveTexture(GL_TEXTURE0 + maxUnit); /* INVALID_ENUM is expected */ - err = glGetError(); - if (err != GL_INVALID_ENUM) { - printf("GL failed to raise GL_INVALID_ENUM setting texture unit\n"); + if (!piglit_check_gl_error(GL_INVALID_ENUM)) { return GL_FALSE; } @@ -290,7 +276,6 @@ static GLboolean test_texture_env(void) { /* Texture Environment state is fixed-function; not used by shaders */ - GLenum err; int i; clear_errors(); @@ -299,9 +284,7 @@ test_texture_env(void) for (i = 0; i < MaxTextureCombinedUnits; i++) { glActiveTexture(GL_TEXTURE0 + i); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, Random[i]); - err = glGetError(); - if (err) { - fprintf(stderr, "unit %d glTexEnvfv error: 0x%x\n", i, err); + if (!piglit_check_gl_error(GL_NO_ERROR)) { return GL_FALSE; } } @@ -319,9 +302,8 @@ test_texture_env(void) } /* there should be no errors at this point */ - err = glGetError(); - if (err != GL_NO_ERROR) { - printf("Unexpected GL error in %s(): 0x%x\n", __FUNCTION__, err); + if (!piglit_check_gl_error(GL_NO_ERROR)) { + return GL_FALSE; } return GL_TRUE; -- cgit v1.2.3