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 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #define WGL_WGLEXT_PROTOTYPES
30 #include <GL/wglext.h>
33 #include "stw_context.h"
36 wglCreateContextAttribsARB(HDC hDC
, HGLRC hShareContext
, const int *attribList
)
38 int majorVersion
= 1, minorVersion
= 0, layerPlane
= 0;
39 int contextFlags
= 0x0;
40 int profileMask
= WGL_CONTEXT_CORE_PROFILE_BIT_ARB
;
44 /* parse attrib_list */
46 for (i
= 0; !done
&& attribList
[i
]; i
++) {
47 switch (attribList
[i
]) {
48 case WGL_CONTEXT_MAJOR_VERSION_ARB
:
49 majorVersion
= attribList
[++i
];
51 case WGL_CONTEXT_MINOR_VERSION_ARB
:
52 minorVersion
= attribList
[++i
];
54 case WGL_CONTEXT_LAYER_PLANE_ARB
:
55 layerPlane
= attribList
[++i
];
57 case WGL_CONTEXT_FLAGS_ARB
:
58 contextFlags
= attribList
[++i
];
60 case WGL_CONTEXT_PROFILE_MASK_ARB
:
61 profileMask
= attribList
[++i
];
69 SetLastError(ERROR_INVALID_PARAMETER
);
75 /* check version (generate ERROR_INVALID_VERSION_ARB if bad) */
76 switch (majorVersion
) {
78 if (minorVersion
< 0 || minorVersion
> 5) {
79 SetLastError(ERROR_INVALID_VERSION_ARB
);
84 if (minorVersion
< 0 || minorVersion
> 1) {
85 SetLastError(ERROR_INVALID_VERSION_ARB
);
90 if (minorVersion
< 0 || minorVersion
> 3) {
91 SetLastError(ERROR_INVALID_VERSION_ARB
);
96 if (minorVersion
< 0 || minorVersion
> 2) {
97 SetLastError(ERROR_INVALID_VERSION_ARB
);
105 if ((contextFlags
& WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
) &&
107 SetLastError(ERROR_INVALID_VERSION_ARB
);
111 /* check profileMask */
112 if (profileMask
!= WGL_CONTEXT_CORE_PROFILE_BIT_ARB
&&
113 profileMask
!= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
) {
114 SetLastError(ERROR_INVALID_PROFILE_ARB
);
118 return (HGLRC
) stw_create_context_attribs(hDC
, layerPlane
,
119 (DHGLRC
) (UINT_PTR
) hShareContext
,
120 majorVersion
, minorVersion
,
121 contextFlags
, profileMask
);