summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaura Ekstrand <laura@jlekstrand.net>2014-10-10 16:06:02 -0700
committerLaura Ekstrand <laura@jlekstrand.net>2014-10-10 16:06:02 -0700
commit59ab4304d889d4d30d8ed2f63eca7b26d40569e3 (patch)
treeeae39454c9f4b448c999d28e459b6f7ee826c6d1 /tests
parent08c9a4fadeb82de84d617828fe9ebd97106644aa (diff)
OrthoPosHLines completed.
Diffstat (limited to 'tests')
-rw-r--r--tests/spec/laura_orthpos/orthpos.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/spec/laura_orthpos/orthpos.c b/tests/spec/laura_orthpos/orthpos.c
index d558d6df7..68a517e92 100644
--- a/tests/spec/laura_orthpos/orthpos.c
+++ b/tests/spec/laura_orthpos/orthpos.c
@@ -420,6 +420,67 @@ orthoPosVLines() {
return verifyOrthPos(img, imgBytes/windowSize, "Immediate-mode vertical lines");
} /* orthoPosVLines */
+/**
+ * This test checks the positioning of unit-width horizontal lines
+ * under orthographic projection. (This is important for apps
+ * that want to use OpenGL for precise 2D drawing.) It fills in
+ * an entire rectangle with a stack of horizontal lines, drawing
+ * adjacent lines with different colors and with blending enabled.
+ * If there are gaps (pixels that are the background color, and
+ * thus haven't been filled), overlaps (pixels that show a blend
+ * of more than one color), or improper edges (pixels around the
+ * edge of the rectangle that haven't been filled, or pixels just
+ * outside the edge that have), then the test fails.
+ *
+ * This test generally fails for one of several reasons. First,
+ * the coordinate transformation process may have an incorrect bias;
+ * this usually will cause a bad edge. Second, the coordinate
+ * transformation process may round pixel coordinates incorrectly;
+ * this will usually cause gaps and/or overlaps. Third, the
+ * line rasterization process may not be filling the correct
+ * pixels; this can cause gaps, overlaps, or bad edges. Fourth,
+ * the OpenGL implementation may not handle the diamond-exit rule
+ * (section 3.4.1 in version 1.2.1 of the OpenGL spec) correctly;
+ * this should cause a bad border or bad right edge.
+ *
+ * It can be argued that this test is more strict that the OpenGL
+ * specification requires. However, it is necessary to be this
+ * strict in order for the results to be useful to app developers
+ * using OpenGL for 2D drawing.
+ */
+bool
+orthoPosHLines() {
+ /*
+ * Immediate-mode horizontal lines
+ * See the comments in the vertical line case above.
+ */
+ int y;
+
+ /* Draw the image */
+ glClear(GL_COLOR_BUFFER_BIT);
+ glBegin(GL_LINES);
+ for (y = 1; y <= drawingSize; ++y) {
+ if (y & 1)
+ glColor4f(0.0, 1.0, 0.0, 0.5);
+ else
+ glColor4f(1.0, 0.0, 0.0, 0.5);
+ glVertex2i(1, y);
+ glVertex2i(drawingSize + 1, y);
+ }
+ glEnd();
+
+ /* Read the image */
+ glReadPixels(0, 0, windowSize, windowSize, GL_RGB, GL_UNSIGNED_BYTE, img);
+
+ /* Show the image */
+ if (!piglit_automatic) {
+ piglit_present_results();
+ }
+
+ /* Check the results */
+ return verifyOrthPos(img, imgBytes/windowSize, "Immediate-mode horizontal lines");
+} /* orthoPosHLines */
+
enum piglit_result
piglit_display(void)
{
@@ -427,6 +488,7 @@ piglit_display(void)
pass &= orthoPosPoints();
pass &= orthoPosVLines();
+ pass &= orthoPosHLines();
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}