Commit 525a6ddf authored by Chris Forbes's avatar Chris Forbes

Use piglit_check_gl_error() instead of block with [f]printf.

Generated from the following semantic patch.

@@
expression RET, MSG;
@@

-	RET = glGetError();
-	if (RET != 0) {
+	if (!piglit_check_gl_error(GL_NO_ERROR))
(
-		printf(MSG,RET);
|
-		fprintf(stderr,MSG,RET);
)
		piglit_report_result(PIGLIT_FAIL);
-	}
Signed-off-by: Chris Forbes's avatarChris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
parent 1b82df13
......@@ -213,11 +213,8 @@ run_test(void)
x0, y1, x0 + SIZE, y1 + SIZE,
GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
err = glGetError();
if (err != GL_NO_ERROR) {
printf("Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
/* WIN(bottom) -> FBO(middle) */
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo);
......
......@@ -118,11 +118,8 @@ generate_and_display_drawbuffers(int count)
prog = piglit_link_simple_program(vs, fs);
glUseProgram(prog);
error = glGetError();
if (error) {
fprintf(stderr, "glUseProgram error: 0x%x\n", error);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
/* Now render to all the color buffers. */
piglit_draw_rect(-1, -1, 2, 2);
......
......@@ -100,11 +100,8 @@ piglit_init(int argc, char **argv)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, tex, 0);
err = glGetError();
if (err != 0) {
printf("Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
......
......@@ -76,11 +76,8 @@ piglit_init(int argc, char **argv)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, tex, 0);
err = glGetError();
if (err != 0) {
fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
......@@ -92,11 +89,8 @@ piglit_init(int argc, char **argv)
glClearColor(color[0], color[1], color[2], color[3]);
glClear(GL_COLOR_BUFFER_BIT);
err = glGetError();
if (err != 0) {
fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
if (!piglit_probe_texel_rect_rgba(GL_TEXTURE_2D, 0, 0, 0, 32, 32,
color)) {
......
......@@ -83,11 +83,8 @@ piglit_init(int argc, char **argv)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex, 0);
err = glGetError();
if (err != 0) {
fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
......@@ -99,11 +96,8 @@ piglit_init(int argc, char **argv)
glClearColor(color[0], color[1], color[2], color[3]);
glClear(GL_COLOR_BUFFER_BIT);
err = glGetError();
if (err != 0) {
fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
if (!piglit_probe_texel_rect_rgba(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0,
0, 0, 32, 32, color)) {
......
......@@ -84,11 +84,8 @@ piglit_init(int argc, char **argv)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex, 0);
err = glGetError();
if (err != 0) {
fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
......@@ -100,11 +97,8 @@ piglit_init(int argc, char **argv)
glClearColor(color[0], color[1], color[2], color[3]);
glClear(GL_COLOR_BUFFER_BIT);
err = glGetError();
if (err != 0) {
fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
if (!piglit_probe_texel_rect_rgba(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0,
0, 0, 32, 32, color)) {
......
......@@ -75,11 +75,8 @@ piglit_init(int argc, char **argv)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, tex, 2);
err = glGetError();
if (err != 0) {
fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
/* Since texture level 2 does not exist, the FBO should be incomplete.
*/
......@@ -101,11 +98,8 @@ piglit_init(int argc, char **argv)
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, 8, 8, 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
err = glGetError();
if (err != 0) {
printf("Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
......@@ -116,11 +110,8 @@ piglit_init(int argc, char **argv)
glClearColor(color[0], color[1], color[2], color[3]);
glClear(GL_COLOR_BUFFER_BIT);
err = glGetError();
if (err != 0) {
fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
if (!piglit_probe_texel_rect_rgba(GL_TEXTURE_2D, 2, 0, 0, 8, 8,
color)) {
......
......@@ -174,11 +174,8 @@ draw_and_test(const char *destination, int drawable_width, int drawable_height)
/* Clear to black */
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
error = glGetError();
if (error) {
fprintf(stderr, "glClear error: 0x%x\n", error);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
glColor4fv(red);
/* Center: full image */
......
......@@ -78,11 +78,8 @@ piglit_init(int argc, char **argv)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_TEXTURE_2D, tex, 0);
err = glGetError();
if (err != 0) {
fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
......@@ -106,11 +103,8 @@ piglit_init(int argc, char **argv)
pass = piglit_probe_rect_depth(0, 0, piglit_width, piglit_height, 0.5)
&& pass;
err = glGetError();
if (err != 0) {
fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment