From 7a6d916d40dea9c5b86e49e570e15ce7ac0f5d5f Mon Sep 17 00:00:00 2001 From: Owen W. Taylor Date: Sat, 20 Nov 2010 09:31:52 -0500 Subject: [PATCH] Improve user-clip test Testing only one pixel of one triangle against one clip plane meant that many types of incorrect clipping would be missed. Add more clip clip plane and more probed pixels to check clipping that is incorrectly set up. https://bugs.freedesktop.org/show_bug.cgi?id=31787 --- tests/general/user-clip.c | 61 ++++++++++++++++++++++++++++++++++++-------- 1 files changed, 50 insertions(+), 11 deletions(-) diff --git a/tests/general/user-clip.c b/tests/general/user-clip.c index 7cd32d6..d045e30 100644 --- a/tests/general/user-clip.c +++ b/tests/general/user-clip.c @@ -51,21 +51,50 @@ piglit_display(void) static const GLfloat green[4] = { 0.0, 1.0, 0.0, 1.0 }; static const GLfloat red[4] = { 1.0, 0.0, 0.0, 1.0 }; enum piglit_result result = PIGLIT_SUCCESS; + int x1, x2, y1, y2; glClear(GL_COLOR_BUFFER_BIT); - glBegin(GL_TRIANGLES); + /* Clipped except for the upper-right */ + glBegin(GL_QUADS); glColor4fv(green); - glVertex3f(-1.0, 1.0, 0.0); - glColor4fv(red); - glVertex3f( 2.0, 0.0, 1.0); + glVertex3f(-1.0, -1.0, 0.501); + glColor4fv(green); + glVertex3f( 1.0, -1.0, 0.501); + glColor4fv(green); + glVertex3f( 1.0, 1.0, 0.501); glColor4fv(green); - glVertex3f(-1.0, -1.0, 0.0); + glVertex3f(-1.0, 1.0, 0.501); + glEnd(); + + /* Should be entirely clipped */ + glBegin(GL_QUADS); + glColor4fv(red); + glVertex3f(-1.0, -1.0, 0.499); + glColor4fv(red); + glVertex3f( 1.0, -1.0, 0.499); + glColor4fv(red); + glVertex3f( 1.0, 1.0, 0.499); + glColor4fv(red); + glVertex3f(-1.0, 1.0, 0.499); glEnd(); - if (!piglit_probe_pixel_rgb(piglit_width - 2, - piglit_height / 2, - clear_color)) { + /* symmetric probe points about the origin */ + x1 = piglit_width / 2 - 1; + x2 = (piglit_width + 1) / 2; + y1 = piglit_height / 2 - 1; + y2 = (piglit_height + 1) / 2; + + if (!piglit_probe_pixel_rgb(x1, y1, clear_color)) { + result = PIGLIT_FAILURE; + } + if (!piglit_probe_pixel_rgb(x2, y1, clear_color)) { + result = PIGLIT_FAILURE; + } + if (!piglit_probe_pixel_rgb(x2, y2, green)) { + result = PIGLIT_FAILURE; + } + if (!piglit_probe_pixel_rgb(x1, y2, clear_color)) { result = PIGLIT_FAILURE; } @@ -77,8 +106,14 @@ piglit_display(void) void piglit_init(int argc, char **argv) { - GLdouble clip_plane[4] = { - 0.0, 0.0, -1.0, 0.5 + GLdouble clip_plane0[4] = { + 1.0, 0.0, 0.0, 0.0 /* clip out x < 0 */ + }; + GLdouble clip_plane1[4] = { + 0.0, 1.0, 0.0, 0.0 /* clip out y < 0 */ + }; + GLdouble clip_plane2[4] = { + 0.0, 0.0, 1.0, -0.5 /* clip out z < 0.5 */ }; (void) argc; @@ -89,6 +124,10 @@ piglit_init(int argc, char **argv) clear_color[2], clear_color[3]); - glClipPlane(GL_CLIP_PLANE0, clip_plane); + glClipPlane(GL_CLIP_PLANE0, clip_plane0); glEnable(GL_CLIP_PLANE0); + glClipPlane(GL_CLIP_PLANE1, clip_plane1); + glEnable(GL_CLIP_PLANE1); + glClipPlane(GL_CLIP_PLANE2, clip_plane2); + glEnable(GL_CLIP_PLANE2); } -- 1.7.3.2