summaryrefslogtreecommitdiff
path: root/tests/spec/gl-1.1/drawpixels-fog.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/spec/gl-1.1/drawpixels-fog.c')
-rw-r--r--tests/spec/gl-1.1/drawpixels-fog.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/tests/spec/gl-1.1/drawpixels-fog.c b/tests/spec/gl-1.1/drawpixels-fog.c
new file mode 100644
index 000000000..a1dcc5eeb
--- /dev/null
+++ b/tests/spec/gl-1.1/drawpixels-fog.c
@@ -0,0 +1,108 @@
+/* Copyright © 2017 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.
+ */
+
+/** @file copypixels-texturing.c
+ * use glCopyPixels with texturing enabled
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 11;
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+
+static const float red[3] = {1.0, 0.0, 0.0};
+static const float green[3] = {0.0, 1.0, 0.0};
+static const float yellow[3] = {0.5, 0.5, 0.0};
+static const float magenta[3] = {0.5, 0.0, 0.5};
+
+enum piglit_result
+piglit_display(void)
+{
+ bool pass = true;
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1, 1, -1, 1, -1, 1);
+
+ glViewport(0, 0, piglit_width, piglit_height);
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* Draw a shape on the top half of the window. */
+ glDisable(GL_FOG);
+ glColor3fv(red);
+ glBegin(GL_TRIANGLE_FAN);
+ glVertex2f(-0.2, 1.0);
+ glVertex2f(-1.0, 0.7);
+ glVertex2f( 0.2, 0.0);
+ glVertex2f( 1.0, 0.3);
+ glEnd();
+
+ /* Enable texturing and copy the top half of the window to the bottom
+ * half.
+ */
+ glEnable(GL_FOG);
+ glWindowPos3f(0.0, 0.0, 0.5);
+
+ void *pixels = malloc(piglit_width * (piglit_height/2) * 4);
+ glReadPixels(0, (piglit_height+1)/2, piglit_width, piglit_height/2,
+ GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+ glDrawPixels(piglit_width, piglit_height/2, GL_RGBA, GL_UNSIGNED_BYTE,
+ pixels);
+ free(pixels);
+
+ /* Probe the corners of the bottom half. These should be 50% blue +
+ * 50% red = magenta.
+ */
+ pass = piglit_probe_pixel_rgb(0, 0, magenta) && pass;
+ pass = piglit_probe_pixel_rgb(0, piglit_height / 2 - 1, magenta) && pass;
+ pass = piglit_probe_pixel_rgb(piglit_width - 1, 0, magenta) && pass;
+ pass = piglit_probe_pixel_rgb(piglit_width - 1, piglit_height / 2 - 1, magenta) && pass;
+
+ /* Probe the middle of the bottom half. These should be 50% green +
+ * 50% red = yellow.
+ */
+ pass = piglit_probe_pixel_rgb(piglit_width / 2, piglit_height / 4, yellow) &&
+ pass;
+
+ piglit_present_results();
+
+ piglit_check_gl_error(GL_NO_ERROR);
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+ glClearColor(0.0, 0.0, 0.5, 1.0);
+ glFogi(GL_FOG_MODE, GL_LINEAR);
+ glFogf(GL_FOG_START, 0.0);
+ glFogf(GL_FOG_END, 1.0);
+ glFogfv(GL_FOG_COLOR, green);
+}