fix the spelling in whole piglit
[piglit.git] / tests / spec / glx_arb_create_context / invalid-gl-version.c
blob565fc9bef577da42a7f9f75e07abd1024dc78eec
1 /* Copyright © 2011 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
22 #include "piglit-util-gl.h"
23 #include "piglit-glx-util.h"
24 #include "common.h"
26 static bool try_version(int major, int minor)
28 const int attribs[] = {
29 GLX_CONTEXT_MAJOR_VERSION_ARB, major,
30 GLX_CONTEXT_MINOR_VERSION_ARB, minor,
31 None
33 GLXContext ctx;
34 bool pass = true;
36 ctx = glXCreateContextAttribsARB(dpy, fbconfig, NULL, True, attribs);
37 XSync(dpy, 0);
39 if (ctx != NULL) {
40 fprintf(stderr,
41 "Created OpenGL context with invalid version %d.%d\n",
42 major, minor);
43 glXDestroyContext(dpy, ctx);
44 pass = false;
47 /* The GLX_ARB_create_context spec says:
49 * "If attributes GLX_CONTEXT_MAJOR_VERSION_ARB and
50 * GLX_CONTEXT_MINOR_VERSION_ARB, when considered together with
51 * attributes GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB and
52 * GLX_RENDER_TYPE, specify an OpenGL version and feature set that
53 * are not defined, BadMatch is generated."
55 if (!validate_glx_error_code(BadMatch, -1)) {
56 if (ctx == NULL)
57 fprintf(stderr, "Version = %d.%d\n", major, minor);
59 pass = false;
62 return pass;
65 int main(int argc, char **argv)
67 bool pass = true;
69 for (int i = 1; i < argc; i++) {
70 if (!strcmp(argv[i], "-auto"))
71 piglit_automatic = 1;
72 else
73 fprintf(stderr, "Unknown option: %s\n", argv[i]);
76 GLX_ARB_create_context_setup();
78 /* The GLX_ARB_create_context spec says:
80 * "The defined versions of OpenGL at the time of writing are
81 * OpenGL 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 2.0, 2.1, 3.0, 3.1, and
82 * 3.2. Feature deprecation was introduced with OpenGL 3.0, so
83 * forward-compatible contexts may only be requested for OpenGL
84 * 3.0 and above. Thus, examples of invalid combinations of
85 * attributes include:
87 * - Major version < 1 or > 3
88 * - Major version == 1 and minor version < 0 or > 5
89 * - Major version == 2 and minor version < 0 or > 1
90 * - Major version == 3 and minor version > 2
91 * - Forward-compatible flag set and major version < 3
92 * - Color index rendering and major version >= 3"
94 pass = try_version(-1, 0) && pass;
95 pass = try_version(0, 0) && pass;
96 pass = try_version(1, -1) && pass;
97 pass = try_version(1, 6) && pass;
98 pass = try_version(2, -1) && pass;
99 pass = try_version(2, 2) && pass;
100 pass = try_version(3, -1) && pass;
102 /* Since the writing of the GLX_ARB_create_context_spec, versions 3.3,
103 * 4.0, 4.1, and 4.2 have been released. There is no expectation that
104 * 3.4 will ever exist because it would have to include functionality
105 * not in 4.0, and that would be weird.
107 pass = try_version(3, 4) && pass;
109 GLX_ARB_create_context_teardown();
111 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
112 return 0;