fbo-mrt-alphatest: Actually require MRTs to be available.
[piglit.git] / tests / spec / arb_es2_compatibility / arb_es2_compatibility-depthrangef.c
blobf87ea3d47e8705ed15def3eb94e9f64fd9f9b0d1
1 /*
2 * Copyright © 2009-2010 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
21 * DEALINGS IN THE SOFTWARE.
24 /** @file arb_es2_compatibility-depthrangef.c
26 * Tests that ARB_ES2_compatibility adds glDepthRangef (as opposed to
27 * glDepthRange) and that it works. Based on general/depth-clamp-range.c.
30 #include "piglit-util-gl.h"
32 PIGLIT_GL_TEST_CONFIG_BEGIN
34 config.supports_gl_compat_version = 10;
36 config.window_width = 150;
37 config.window_height = 150;
38 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_DEPTH;
40 PIGLIT_GL_TEST_CONFIG_END
42 void
43 piglit_init(int argc, char **argv)
45 piglit_require_extension("GL_ARB_ES2_compatibility");
48 enum piglit_result
49 piglit_display(void)
51 GLboolean pass = GL_TRUE;
52 float red[4] = {1.0, 0.0, 0.0, 0.0};
53 float green[4] = {0.0, 1.0, 0.0, 0.0};
54 float blue[4] = {0.0, 0.0, 1.0, 0.0};
56 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
58 glClearColor(0.0, 0.0, 1.0, 0.0);
60 glClearDepthf(0.5);
61 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
62 glEnable(GL_DEPTH_TEST);
63 glDepthFunc(GL_LEQUAL);
65 /* Keep in mind that the ortho projection flips near and far's signs,
66 * so 1.0 to quad()'s z maps to glDepthRange's near, and -1.0 maps to
67 * glDepthRange's far.
70 glColor4fv(green);
71 glDepthRangef(0, 1);
72 piglit_draw_rect_z(0.5,
73 0, 0,
74 piglit_width / 2, piglit_height);
76 glColor4fv(red);
77 glDepthRangef(1, 0);
78 piglit_draw_rect_z(0.5,
79 piglit_width / 2, 0,
80 piglit_width, piglit_height);
82 pass = piglit_probe_pixel_rgb(piglit_width * 1 / 4, piglit_height / 2,
83 green) && pass;
84 pass = piglit_probe_pixel_rgb(piglit_width * 3 / 4, piglit_height / 2,
85 blue) && pass;
87 piglit_present_results();
89 return pass ? PIGLIT_PASS : PIGLIT_FAIL;