arb_framebuffer_object: add missing MSAA alpha-to-coverage and alpha-to-one tests
[piglit.git] / tests / general / stencil-drawpixels.c
blob1fdc47f5e750957c27e9f625d981c0e3a6bdce42
1 /*
2 * Copyright © 2009 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
28 /** @file stencil-drawpixels.c
30 * Tests that glDrawPixels(GL_STENCIL) minimally works.
33 #include "piglit-util-gl.h"
35 PIGLIT_GL_TEST_CONFIG_BEGIN
37 config.supports_gl_compat_version = 10;
39 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DEPTH | PIGLIT_GL_VISUAL_STENCIL;
41 PIGLIT_GL_TEST_CONFIG_END
43 enum piglit_result
44 piglit_display(void)
46 GLboolean pass = GL_TRUE;
47 int i;
48 static float red[] = {1.0, 0.0, 0.0, 0.0};
49 static float green[] = {0.0, 1.0, 0.0, 0.0};
50 static float blue[] = {0.0, 0.0, 1.0, 0.0};
51 static float square[100];
53 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
55 /* whole window gray -- none should be visible */
56 glClearColor(0.5, 0.5, 0.5, 0.0);
57 glClear(GL_COLOR_BUFFER_BIT);
59 /* Clear stencil to 0, which will be drawn red */
60 glClearStencil(0);
61 glClear(GL_STENCIL_BUFFER_BIT);
63 /* quad at 10, 10 that will be drawn green. */
64 for (i = 0; i < 100; i++)
65 square[i] = 1.0;
66 glRasterPos2i(10, 10);
67 glDrawPixels(10, 10, GL_STENCIL_INDEX, GL_FLOAT, square);
69 /* quad at 30, 10 that will be drawn blue. */
70 for (i = 0; i < 100; i++)
71 square[i] = 2.0;
72 glRasterPos2i(30, 10);
73 glDrawPixels(10, 10, GL_STENCIL_INDEX, GL_FLOAT, square);
75 glDisable(GL_SCISSOR_TEST);
76 glEnable(GL_STENCIL_TEST);
77 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
79 /* First quad -- stencil == 0 gets red */
80 glStencilFunc(GL_EQUAL, 0, ~0);
81 glColor4fv(red);
82 piglit_draw_rect(0, 0, piglit_width, piglit_height);
84 /* Second quad -- stencil == 1 gets green */
85 glStencilFunc(GL_EQUAL, 1, ~0);
86 glColor4fv(green);
87 piglit_draw_rect(0, 0, piglit_width, piglit_height);
89 /* Last quad -- stencil == 2 gets blue */
90 glStencilFunc(GL_EQUAL, 2, ~0);
91 glColor4fv(blue);
92 piglit_draw_rect(0, 0, piglit_width, piglit_height);
94 if (!piglit_check_gl_error(GL_NO_ERROR))
95 piglit_report_result(PIGLIT_FAIL);
97 pass &= piglit_probe_rect_rgb(0, 0, piglit_width, 10, red);
99 pass &= piglit_probe_rect_rgb(0, 10, 10, 10, red);
100 pass &= piglit_probe_rect_rgb(10, 10, 10, 10, green);
101 pass &= piglit_probe_rect_rgb(20, 10, 10, 10, red);
102 pass &= piglit_probe_rect_rgb(30, 10, 10, 10, blue);
103 pass &= piglit_probe_rect_rgb(40, 10, piglit_width-40, 10, red);
105 pass &= piglit_probe_rect_rgb(0, 20, piglit_width, piglit_height - 20,
106 red);
108 piglit_present_results();
110 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
114 void
115 piglit_init(int argc, char **argv)