ilo: hook up pipe context state functions
[mesa.git] / src / gallium / state_trackers / wgl / stw_ext_context.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.11
4 *
5 * Copyright (C) 2011 Morgan Armand <morgan.devel@gmail.com>
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
24 */
25
26 #include <windows.h>
27
28 #define WGL_WGLEXT_PROTOTYPES
29
30 #include <GL/gl.h>
31 #include <GL/wglext.h>
32
33 #include "stw_icd.h"
34 #include "stw_context.h"
35
36 HGLRC WINAPI
37 wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList)
38 {
39 int majorVersion = 1, minorVersion = 0, layerPlane = 0;
40 int contextFlags = 0x0;
41 int profileMask = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
42 int i;
43 BOOL done = FALSE;
44
45 /* parse attrib_list */
46 if (attribList) {
47 for (i = 0; !done && attribList[i]; i++) {
48 switch (attribList[i]) {
49 case WGL_CONTEXT_MAJOR_VERSION_ARB:
50 majorVersion = attribList[++i];
51 break;
52 case WGL_CONTEXT_MINOR_VERSION_ARB:
53 minorVersion = attribList[++i];
54 break;
55 case WGL_CONTEXT_LAYER_PLANE_ARB:
56 layerPlane = attribList[++i];
57 break;
58 case WGL_CONTEXT_FLAGS_ARB:
59 contextFlags = attribList[++i];
60 break;
61 case WGL_CONTEXT_PROFILE_MASK_ARB:
62 profileMask = attribList[++i];
63 break;
64 case 0:
65 /* end of list */
66 done = TRUE;
67 break;
68 default:
69 /* bad attribute */
70 SetLastError(ERROR_INVALID_PARAMETER);
71 return NULL;
72 }
73 }
74 }
75
76 /* check version (generate ERROR_INVALID_VERSION_ARB if bad) */
77 switch (majorVersion) {
78 case 1:
79 if (minorVersion < 0 || minorVersion > 5) {
80 SetLastError(ERROR_INVALID_VERSION_ARB);
81 return NULL;
82 }
83 break;
84 case 2:
85 if (minorVersion < 0 || minorVersion > 1) {
86 SetLastError(ERROR_INVALID_VERSION_ARB);
87 return NULL;
88 }
89 break;
90 case 3:
91 if (minorVersion < 0 || minorVersion > 3) {
92 SetLastError(ERROR_INVALID_VERSION_ARB);
93 return NULL;
94 }
95 break;
96 case 4:
97 if (minorVersion < 0 || minorVersion > 2) {
98 SetLastError(ERROR_INVALID_VERSION_ARB);
99 return NULL;
100 }
101 break;
102 default:
103 return NULL;
104 }
105
106 if ((contextFlags & WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) &&
107 majorVersion < 3) {
108 SetLastError(ERROR_INVALID_VERSION_ARB);
109 return NULL;
110 }
111
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);
116 return NULL;
117 }
118
119 return (HGLRC) stw_create_context_attribs(hDC, layerPlane,
120 (DHGLRC) (UINT_PTR) hShareContext,
121 majorVersion, minorVersion,
122 contextFlags, profileMask);
123 }