2 * Copyright © 2013 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
25 * Test that GL_DEPTH_CLAMP is a valid state
27 * Table 6.8 (Transformation state) of OpenGL 3.2 Core added DEPTH_CLAMP
31 #include "piglit-util-gl.h"
33 PIGLIT_GL_TEST_CONFIG_BEGIN
35 config
.supports_gl_compat_version
= 32;
36 config
.supports_gl_core_version
= 32;
38 PIGLIT_GL_TEST_CONFIG_END
41 piglit_init(int argc
, char **argv
)
49 /* Check that GL_DEPTH_CLAMP was initialized to TRUE */
50 if (glIsEnabled(GL_DEPTH_CLAMP
)) {
51 printf("GL_DEPTH_CLAMP was not initialized to FALSE\n");
54 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
56 /* Test that GL_DEPTH_CLAMP is enable/disabled correctly */
57 glEnable(GL_DEPTH_CLAMP
);
58 if (!glIsEnabled(GL_DEPTH_CLAMP
)) {
59 printf("GL_DEPTH_CLAMP was not enabled properly\n");
62 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
64 glDisable(GL_DEPTH_CLAMP
);
65 if (glIsEnabled(GL_DEPTH_CLAMP
)) {
66 printf("GL_DEPTH_CLAMP was not disabled properly\n");
69 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
71 /* Test that GL_DEPTH_CLAMP disabled is returned from glGet calls */
72 glGetIntegerv(GL_DEPTH_CLAMP
, &i
);
74 printf("i expected to be 0, but returned %d\n", i
);
77 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
78 glGetFloatv(GL_DEPTH_CLAMP
, &f
);
80 printf("f expected to be 0.0, but returned %f\n", f
);
83 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
84 glGetBooleanv(GL_DEPTH_CLAMP
, &b
);
86 printf("b expected to be 0, but returned %d\n", (int)b
);
89 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
90 glGetDoublev(GL_DEPTH_CLAMP
, &d
);
92 printf("d expected to be 0.0, but returned %f\n", d
);
95 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
97 /* Test that GL_DEPTH_CLAMP enabled is returned from glGet calls */
98 glEnable(GL_DEPTH_CLAMP
);
100 glGetIntegerv(GL_DEPTH_CLAMP
, &i
);
102 printf("i expected to be 1, but returned %d\n", i
);
105 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
106 glGetFloatv(GL_DEPTH_CLAMP
, &f
);
108 printf("f expected to be 1.0, but returned %f\n", f
);
111 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
112 glGetBooleanv(GL_DEPTH_CLAMP
, &b
);
114 printf("b expected to be 1, but returned %d\n", (int)b
);
117 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
118 glGetDoublev(GL_DEPTH_CLAMP
, &d
);
120 printf("d expected to be 1.0, but returned %f\n", d
);
123 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
125 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);