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
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
24 * Eric Anholt <eric@anholt.net>
28 /** @file depthrange-clear.c
30 * Tests that clears are appropriately unaffected by glDepthRange().
31 * Caught a regression in the intel driver with the metaops clear code.
34 #include "piglit-util.h"
36 int piglit_width
= 100, piglit_height
= 100;
37 int piglit_window_mode
= GLUT_RGB
| GLUT_DOUBLE
| GLUT_DEPTH
;
40 * Convenience function to draw an axis-aligned rectangle.
43 draw_rect(float x
, float y
, float w
, float h
, float d
)
64 glVertexPointer(4, GL_FLOAT
, 0, verts
);
65 glEnableClientState(GL_VERTEX_ARRAY
);
67 glDrawArrays(GL_QUADS
, 0, 4);
69 glDisableClientState(GL_VERTEX_ARRAY
);
75 draw_rect(10, y
, 10, 10, -.75);
76 draw_rect(30, y
, 10, 10, -.25);
77 draw_rect(50, y
, 10, 10, .25);
78 draw_rect(70, y
, 10, 10, .75);
84 GLboolean pass
= GL_TRUE
;
86 static float red
[] = {1.0, 0.0, 0.0, 0.0};
87 static float green
[] = {0.0, 1.0, 0.0, 0.0};
89 glEnable(GL_DEPTH_TEST
);
91 glClearColor(0.0, 1.0, 0.0, 0.0);
92 glClear(GL_COLOR_BUFFER_BIT
);
97 glClear(GL_DEPTH_BUFFER_BIT
);
100 glDepthRange(0.5, 1.0);
102 glClear(GL_DEPTH_BUFFER_BIT
);
103 glDepthRange(0.0, 1.0);
106 glDepthRange(0.0, 0.5);
108 glClear(GL_DEPTH_BUFFER_BIT
);
109 glDepthRange(0.0, 1.0);
112 for (y
= 0; y
< 3; y
++) {
113 for (x
= 0; x
< 4; x
++) {
121 pass
&= piglit_probe_pixel_rgb(15 + x
* 20, 15 + y
* 20,
128 return pass
? PIGLIT_SUCCESS
: PIGLIT_FAILURE
;
132 static void reshape(int width
, int height
)
134 piglit_width
= width
;
135 piglit_height
= height
;
137 glViewport(0, 0, width
, height
);
138 piglit_ortho_projection(width
, height
, GL_FALSE
);
142 piglit_init(int argc
, char **argv
)
144 reshape(piglit_width
, piglit_height
);