2 * (C) Copyright IBM Corporation 2004
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * Simple test of GL_EXT_blend_minmax functionality. Four squares are drawn
29 * with different blending modes, but all should be rendered with the same
32 * \author Ian Romanick <idr@us.ibm.com>
35 #include "piglit-util-gl.h"
37 PIGLIT_GL_TEST_CONFIG_BEGIN
39 config
.supports_gl_compat_version
= 10;
41 config
.window_width
= 400;
42 config
.window_height
= 200;
43 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
45 PIGLIT_GL_TEST_CONFIG_END
50 GLboolean pass
= GL_TRUE
;
51 int w
= (piglit_width
- 50) / 4;
52 int h
= piglit_height
- 20;
55 float expected
[4] = {0.5, 0.5, 0.5, 0.5};
57 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);
59 glClearColor(0.2, 0.2, 0.8, 0);
60 glClear(GL_COLOR_BUFFER_BIT
);
62 /* This is the "reference" square.
65 glBlendEquation(GL_FUNC_ADD
);
66 glBlendFunc(GL_ONE
, GL_ZERO
);
67 glColor3f(0.5, 0.5, 0.5);
68 piglit_draw_rect(start_x
+ next_x
* 0, 10, w
, h
);
70 /* GL_MIN and GL_MAX are supposed to ignore the blend function
71 * setting. To test that, we set the blend function to
72 * GL_ZERO for both color and alpha each time GL_MIN or GL_MAX
75 * Apple ships an extension called
76 * GL_ATI_blend_weighted_minmax (supported on Mac OS X 10.2
77 * and later). I believe the difference with that extension
78 * is that it uses the blend function. However, I have no
79 * idea what the enums are for it. The extension is listed at
80 * Apple's developer site, but there is no documentation.
82 * http://developer.apple.com/opengl/extensions.html
85 glBlendEquation(GL_FUNC_ADD
);
86 glBlendFunc(GL_ONE
, GL_ZERO
);
87 glColor3f(0.5, 0.5, 0.5);
88 piglit_draw_rect(start_x
+ next_x
* 1, 10, w
, h
);
90 glBlendEquation(GL_MAX
);
91 glBlendFunc(GL_ZERO
, GL_ZERO
);
92 glColor3f(0.2, 0.2, 0.2);
93 piglit_draw_rect(start_x
+ next_x
* 1, 10, w
, h
);
95 glBlendEquation(GL_FUNC_ADD
);
96 glBlendFunc(GL_ONE
, GL_ZERO
);
97 glColor3f(0.5, 0.5, 0.5);
98 piglit_draw_rect(start_x
+ next_x
* 2, 10, w
, h
);
100 glBlendEquation(GL_MIN
);
101 glBlendFunc(GL_ZERO
, GL_ZERO
);
102 glColor3f(0.8, 0.8, 0.8);
103 piglit_draw_rect(start_x
+ next_x
* 2, 10, w
, h
);
105 glBlendEquation(GL_FUNC_ADD
);
106 glBlendFunc(GL_ONE
, GL_ZERO
);
107 glColor3f(0.8, 0.8, 0.8);
108 piglit_draw_rect(start_x
+ next_x
* 3, 10, w
, h
);
110 glBlendEquation(GL_MIN
);
111 glBlendFunc(GL_ZERO
, GL_ZERO
);
112 glColor3f(0.5, 0.5, 0.5);
113 piglit_draw_rect(start_x
+ next_x
* 3, 10, w
, h
);
115 pass
= piglit_probe_pixel_rgb(15 + next_x
* 0, piglit_height
/ 2,
117 pass
= piglit_probe_pixel_rgb(15 + next_x
* 1, piglit_height
/ 2,
119 pass
= piglit_probe_pixel_rgb(15 + next_x
* 2, piglit_height
/ 2,
121 pass
= piglit_probe_pixel_rgb(15 + next_x
* 3, piglit_height
/ 2,
124 piglit_present_results();
126 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
130 piglit_init(int argc
, char **argv
)
132 if (!piglit_is_extension_supported("GL_ARB_imaging") && !piglit_is_extension_supported("GL_EXT_blend_minmax")) {
133 printf("Sorry, this program requires either GL_ARB_imaging or "
134 "GL_EXT_blend_minmax.\n");
135 piglit_report_result(PIGLIT_SKIP
);
138 piglit_require_gl_version(14);
140 printf("\nAll 4 quads should be the same color.\n");