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
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
22 #include "piglit-util-gl.h"
23 #include "piglit-glx-util.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
,
36 ctx
= glXCreateContextAttribsARB(dpy
, fbconfig
, NULL
, True
, attribs
);
41 "Created OpenGL context with invalid version %d.%d\n",
43 glXDestroyContext(dpy
, ctx
);
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)) {
57 fprintf(stderr
, "Version = %d.%d\n", major
, minor
);
65 int main(int argc
, char **argv
)
69 for (int i
= 1; i
< argc
; i
++) {
70 if (!strcmp(argv
[i
], "-auto"))
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
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
);