2 * Mesa 3-D graphics library
5 * Copyright (C) 2011 Morgan Armand <morgan.devel@gmail.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
28 #define WGL_WGLEXT_PROTOTYPES
31 #include <GL/wglext.h>
34 #include "stw_context.h"
37 wglCreateContextAttribsARB(HDC hDC
, HGLRC hShareContext
, const int *attribList
)
39 int majorVersion
= 1, minorVersion
= 0, layerPlane
= 0;
40 int contextFlags
= 0x0;
41 int profileMask
= WGL_CONTEXT_CORE_PROFILE_BIT_ARB
;
45 /* parse attrib_list */
47 for (i
= 0; !done
&& attribList
[i
]; i
++) {
48 switch (attribList
[i
]) {
49 case WGL_CONTEXT_MAJOR_VERSION_ARB
:
50 majorVersion
= attribList
[++i
];
52 case WGL_CONTEXT_MINOR_VERSION_ARB
:
53 minorVersion
= attribList
[++i
];
55 case WGL_CONTEXT_LAYER_PLANE_ARB
:
56 layerPlane
= attribList
[++i
];
58 case WGL_CONTEXT_FLAGS_ARB
:
59 contextFlags
= attribList
[++i
];
61 case WGL_CONTEXT_PROFILE_MASK_ARB
:
62 profileMask
= attribList
[++i
];
70 SetLastError(ERROR_INVALID_PARAMETER
);
76 /* check version (generate ERROR_INVALID_VERSION_ARB if bad) */
77 switch (majorVersion
) {
79 if (minorVersion
< 0 || minorVersion
> 5) {
80 SetLastError(ERROR_INVALID_VERSION_ARB
);
85 if (minorVersion
< 0 || minorVersion
> 1) {
86 SetLastError(ERROR_INVALID_VERSION_ARB
);
91 if (minorVersion
< 0 || minorVersion
> 3) {
92 SetLastError(ERROR_INVALID_VERSION_ARB
);
97 if (minorVersion
< 0 || minorVersion
> 2) {
98 SetLastError(ERROR_INVALID_VERSION_ARB
);
106 if ((contextFlags
& WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
) &&
108 SetLastError(ERROR_INVALID_VERSION_ARB
);
112 /* check profileMask */
113 if (profileMask
!= WGL_CONTEXT_CORE_PROFILE_BIT_ARB
&&
114 profileMask
!= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
) {
115 SetLastError(ERROR_INVALID_PROFILE_ARB
);
119 return (HGLRC
) stw_create_context_attribs(hDC
, layerPlane
,
120 (DHGLRC
) (UINT_PTR
) hShareContext
,
121 majorVersion
, minorVersion
,
122 contextFlags
, profileMask
);