2 * Copyright (c) 2010 VMware, Inc.
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
27 * Test basic GL 3.0 features.
34 #include "piglit-util-gl.h"
36 PIGLIT_GL_TEST_CONFIG_BEGIN
38 config
.supports_gl_compat_version
= 10;
40 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DEPTH
| PIGLIT_GL_VISUAL_STENCIL
;
42 config
.requires_displayed_window
= true;
44 PIGLIT_GL_TEST_CONFIG_END
46 static const char *Prog
= "gl30basic";
50 static enum piglit_result
53 const GLubyte
*version
= glGetString(GL_VERSION
);
55 GLint major
, minor
, k
;
57 piglit_require_gl_version(30);
59 major
= version
[0] - '0';
60 minor
= version
[2] - '0';
62 iversion
= major
* 10 + minor
;
68 glGetIntegerv(GL_MAJOR_VERSION
, &k
);
70 printf("%s: major version mismatch (%d vs. %d)\n", Prog
, k
, major
);
74 glGetIntegerv(GL_MINOR_VERSION
, &k
);
76 printf("%s: minor version mismatch (%d vs. %d)\n", Prog
, k
, minor
);
84 static enum piglit_result
85 test_extension_list(void)
89 glGetIntegerv(GL_NUM_EXTENSIONS
, &num_ext
);
90 if (num_ext
< 1 || num_ext
> 10000) {
91 printf("%s: unreasonable value for GL_NUM_EXTENSIONS: %d\n", Prog
, num_ext
);
95 /* check that extension strings are reasonable */
96 for (k
= 0; k
< num_ext
; k
++) {
97 const char *ext
= (const char *) glGetStringi(GL_EXTENSIONS
, k
);
99 printf("Ext[%d] = %s\n", k
, ext
);
101 /* In some drivers WGL_EXT_swap_control is in the extension string
102 * for historical reasons.
104 if (!ext
|| (strncmp(ext
, "GL_", 3) != 0 &&
105 strcmp(ext
, "WGL_EXT_swap_control") != 0)){
106 printf("%s: bad extension string [%d]: %s\n", Prog
, k
, ext
);
109 if (strchr((char *) ext
, ' ')) {
110 printf("%s: extension string [%d] contains a space: %s\n", Prog
, k
, ext
);
122 static const GLfloat purple
[] = {1.0, 0.0, 1.0};
123 static const GLfloat blue
[] = {0.0, 0.0, 1.0};
124 static const GLfloat green
[] = {0.0, 1.0, 0.0};
126 GLboolean pass
= GL_TRUE
;
128 while (glGetError() != GL_NO_ERROR
)
132 glDrawBuffer(GL_FRONT
);
133 glClearBufferfv(GL_COLOR
, 0, purple
);
136 printf("%s: glClearBufferfv(GL_FRONT) generated error 0x%x.\n", Prog
, err
);
140 glReadBuffer(GL_FRONT
);
141 if (!piglit_probe_rect_rgb(0, 0, piglit_width
, piglit_height
, purple
)) {
142 printf(" from glClearBufferfv(GL_FRONT) failed.\n");
147 glDrawBuffer(GL_BACK
);
148 glClearBufferfv(GL_COLOR
, 0, blue
);
151 printf("%s: glClearBufferfv(GL_BACK) generated error 0x%x.\n", Prog
, err
);
155 glReadBuffer(GL_BACK
);
156 if (!piglit_probe_rect_rgb(0, 0, piglit_width
, piglit_height
, blue
)) {
157 printf(" from glClearBufferfv(GL_BACK) failed.\n");
161 /* Front and back buffer. */
162 glDrawBuffer(GL_FRONT_AND_BACK
);
163 glClearBufferfv(GL_COLOR
, 0, green
);
166 printf("%s: glClearBufferfv(GL_FRONT_AND_BACK) generated error 0x%x.\n", Prog
, err
);
170 glReadBuffer(GL_FRONT
);
171 if (!piglit_probe_rect_rgb(0, 0, piglit_width
, piglit_height
, green
)) {
172 printf(" the front buffer from glClearBufferfv(GL_FRONT_AND_BACK) failed.\n");
176 glReadBuffer(GL_BACK
);
177 if (!piglit_probe_rect_rgb(0, 0, piglit_width
, piglit_height
, green
)) {
178 printf(" the back buffer from glClearBufferfv(GL_FRONT_AND_BACK) failed.\n");
182 /* Depth & Stencil */
183 glClearBufferfi(GL_DEPTH_STENCIL
, 0, 0.5, 3);
186 printf("%s: glClearBufferfi() generated error 0x%x.\n", Prog
, err
);
190 if (!piglit_probe_rect_depth(0, 0, piglit_width
, piglit_height
, 0.5)) {
191 printf(" from glClearBufferfi() failed.\n");
195 if (!piglit_probe_rect_stencil(0, 0, piglit_width
, piglit_height
, 3)) {
196 printf(" from glClearBufferfi() failed.\n");
200 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
207 enum piglit_result res
;
209 res
= test_version();
210 if (res
!= PIGLIT_PASS
)
213 res
= test_extension_list();
214 if (res
!= PIGLIT_PASS
)
217 res
= test_clearing();
218 if (res
!= PIGLIT_PASS
)
226 void piglit_init(int argc
, char**argv
)