[Piglit] [PATCH 1/2] Add a simple edge flag test

Yuanhan Liu yuanhan.liu at linux.intel.com
Thu Sep 22 19:34:56 PDT 2011


v2: suggested by Ian, move all the init stuff into piglit_init function,
also to set the line width 'big enought' to 10 to make sure the pixel we
want to probe is rasterized.

Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
---
 tests/all.tests                 |    1 +
 tests/general/CMakeLists.gl.txt |    1 +
 tests/general/edge-flag.c       |   87 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100644 tests/general/edge-flag.c

diff --git a/tests/all.tests b/tests/all.tests
index 7c52ce5..2cce8cc 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -237,6 +237,7 @@ add_plain_test(general, 'draw-instanced-divisor')
 add_plain_test(general, 'draw-vertices')
 add_plain_test(general, 'draw-vertices-half-float')
 add_plain_test(general, 'early-z')
+add_plain_test(general, 'edge-flag')
 add_plain_test(general, 'fog-modes')
 add_plain_test(general, 'fragment-center')
 add_plain_test(general, 'framebuffer-srgb')
diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
index d6e73cf..5e3f97f 100644
--- a/tests/general/CMakeLists.gl.txt
+++ b/tests/general/CMakeLists.gl.txt
@@ -43,6 +43,7 @@ add_executable (draw-instanced-divisor draw-instanced-divisor.c)
 add_executable (draw-sync draw-sync.c)
 add_executable (draw-vertices draw-vertices.c)
 add_executable (draw-vertices-half-float draw-vertices-half-float.c)
+add_executable (edge-flag edge-flag.c)
 add_executable (fog-modes fog-modes.c)
 IF (UNIX)
 	target_link_libraries (fog-modes m)
diff --git a/tests/general/edge-flag.c b/tests/general/edge-flag.c
new file mode 100644
index 0000000..09a2f5c
--- /dev/null
+++ b/tests/general/edge-flag.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Yuanhan Liu <yuanhan.liu at linux.intel.com>
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+static GLfloat blue[3] = {0.0, 0.0, 1.0};
+static GLfloat black[3] = {0.0, 0.0, 0.0};
+
+struct edge_flag_test {
+	float x;
+	float y;
+	GLboolean edage_flag;
+};
+
+enum piglit_result
+piglit_display(void)
+{
+	GLboolean pass = PIGLIT_PASS;
+	struct edge_flag_test test[] = {
+		{20, 20, GL_FALSE},
+		{20, 60, GL_FALSE},
+		{60, 20, GL_TRUE},
+	};
+
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	glBegin(GL_TRIANGLES);
+	  glEdgeFlag(test[0].edage_flag);
+	  glVertex2f(test[0].x, test[0].y);
+
+	  glEdgeFlag(test[1].edage_flag);
+	  glVertex2f(test[1].x, test[1].y);
+
+	  glEdgeFlag(test[2].edage_flag);
+	  glVertex2f(test[2].x, test[2].y);
+	glEnd();
+
+	pass &= piglit_probe_pixel_rgb(40, 20, blue);
+	pass &= piglit_probe_pixel_rgb(20, 40, black);
+	pass &= piglit_probe_pixel_rgb(40, 40, black);
+
+	glutSwapBuffers();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	glClearColor(0.0, 0.0, 0.0, 1.0);
+	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+	/*
+	 * Here we set the line width 'big enough' to make sure the
+	 * pixel we want to probe is rasterized.
+	 */
+	glLineWidth(10);
+	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+	glColor3fv(blue);
+}
-- 
1.7.4.4



More information about the Piglit mailing list