Merge branch 'asm-shader-rework-2'
[mesa.git] / src / gallium / state_trackers / wgl / stw_wgl.c
1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include <windows.h>
29
30 #include "util/u_debug.h"
31 #include "stw_icd.h"
32 #include "stw_context.h"
33 #include "stw_pixelformat.h"
34 #include "stw_wgl.h"
35
36
37 WINGDIAPI BOOL APIENTRY
38 wglCopyContext(
39 HGLRC hglrcSrc,
40 HGLRC hglrcDst,
41 UINT mask )
42 {
43 return DrvCopyContext( (DHGLRC)(UINT_PTR)hglrcSrc,
44 (DHGLRC)(UINT_PTR)hglrcDst,
45 mask );
46 }
47
48 WINGDIAPI HGLRC APIENTRY
49 wglCreateContext(
50 HDC hdc )
51 {
52 return (HGLRC) DrvCreateContext(hdc);
53 }
54
55 WINGDIAPI HGLRC APIENTRY
56 wglCreateLayerContext(
57 HDC hdc,
58 int iLayerPlane )
59 {
60 return (HGLRC) DrvCreateLayerContext( hdc, iLayerPlane );
61 }
62
63 WINGDIAPI BOOL APIENTRY
64 wglDeleteContext(
65 HGLRC hglrc )
66 {
67 return DrvDeleteContext((DHGLRC)(UINT_PTR)hglrc );
68 }
69
70
71 WINGDIAPI HGLRC APIENTRY
72 wglGetCurrentContext( VOID )
73 {
74 return (HGLRC)(UINT_PTR)stw_get_current_context();
75 }
76
77 WINGDIAPI HDC APIENTRY
78 wglGetCurrentDC( VOID )
79 {
80 return stw_get_current_dc();
81 }
82
83 WINGDIAPI BOOL APIENTRY
84 wglMakeCurrent(
85 HDC hdc,
86 HGLRC hglrc )
87 {
88 return DrvSetContext( hdc, (DHGLRC)(UINT_PTR)hglrc, NULL ) ? TRUE : FALSE;
89 }
90
91
92 WINGDIAPI BOOL APIENTRY
93 wglSwapBuffers(
94 HDC hdc )
95 {
96 return DrvSwapBuffers( hdc );
97 }
98
99
100 WINGDIAPI BOOL APIENTRY
101 wglSwapLayerBuffers(
102 HDC hdc,
103 UINT fuPlanes )
104 {
105 return DrvSwapLayerBuffers( hdc, fuPlanes );
106 }
107
108 WINGDIAPI PROC APIENTRY
109 wglGetProcAddress(
110 LPCSTR lpszProc )
111 {
112 return DrvGetProcAddress( lpszProc );
113 }
114
115
116 WINGDIAPI int APIENTRY
117 wglChoosePixelFormat(
118 HDC hdc,
119 CONST PIXELFORMATDESCRIPTOR *ppfd )
120 {
121 if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
122 return 0;
123 if (ppfd->iPixelType != PFD_TYPE_RGBA)
124 return 0;
125 if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
126 return 0;
127 if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
128 return 0;
129 if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
130 return 0;
131 if (ppfd->dwFlags & PFD_SUPPORT_GDI)
132 return 0;
133 if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
134 return 0;
135
136 return stw_pixelformat_choose( hdc, ppfd );
137 }
138
139 WINGDIAPI int APIENTRY
140 wglDescribePixelFormat(
141 HDC hdc,
142 int iPixelFormat,
143 UINT nBytes,
144 LPPIXELFORMATDESCRIPTOR ppfd )
145 {
146 return DrvDescribePixelFormat( hdc, iPixelFormat, nBytes, ppfd );
147 }
148
149 WINGDIAPI int APIENTRY
150 wglGetPixelFormat(
151 HDC hdc )
152 {
153 return stw_pixelformat_get( hdc );
154 }
155
156 WINGDIAPI BOOL APIENTRY
157 wglSetPixelFormat(
158 HDC hdc,
159 int iPixelFormat,
160 const PIXELFORMATDESCRIPTOR *ppfd )
161 {
162 if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
163 return FALSE;
164
165 return DrvSetPixelFormat( hdc, iPixelFormat );
166 }
167
168
169 WINGDIAPI BOOL APIENTRY
170 wglUseFontBitmapsA(
171 HDC hdc,
172 DWORD first,
173 DWORD count,
174 DWORD listBase )
175 {
176 (void) hdc;
177 (void) first;
178 (void) count;
179 (void) listBase;
180
181 assert( 0 );
182
183 return FALSE;
184 }
185
186 WINGDIAPI BOOL APIENTRY
187 wglShareLists(
188 HGLRC hglrc1,
189 HGLRC hglrc2 )
190 {
191 return DrvShareLists((DHGLRC)(UINT_PTR)hglrc1,
192 (DHGLRC)(UINT_PTR)hglrc2);
193 }
194
195 WINGDIAPI BOOL APIENTRY
196 wglUseFontBitmapsW(
197 HDC hdc,
198 DWORD first,
199 DWORD count,
200 DWORD listBase )
201 {
202 (void) hdc;
203 (void) first;
204 (void) count;
205 (void) listBase;
206
207 assert( 0 );
208
209 return FALSE;
210 }
211
212 WINGDIAPI BOOL APIENTRY
213 wglUseFontOutlinesA(
214 HDC hdc,
215 DWORD first,
216 DWORD count,
217 DWORD listBase,
218 FLOAT deviation,
219 FLOAT extrusion,
220 int format,
221 LPGLYPHMETRICSFLOAT lpgmf )
222 {
223 (void) hdc;
224 (void) first;
225 (void) count;
226 (void) listBase;
227 (void) deviation;
228 (void) extrusion;
229 (void) format;
230 (void) lpgmf;
231
232 assert( 0 );
233
234 return FALSE;
235 }
236
237 WINGDIAPI BOOL APIENTRY
238 wglUseFontOutlinesW(
239 HDC hdc,
240 DWORD first,
241 DWORD count,
242 DWORD listBase,
243 FLOAT deviation,
244 FLOAT extrusion,
245 int format,
246 LPGLYPHMETRICSFLOAT lpgmf )
247 {
248 (void) hdc;
249 (void) first;
250 (void) count;
251 (void) listBase;
252 (void) deviation;
253 (void) extrusion;
254 (void) format;
255 (void) lpgmf;
256
257 assert( 0 );
258
259 return FALSE;
260 }
261
262 WINGDIAPI BOOL APIENTRY
263 wglDescribeLayerPlane(
264 HDC hdc,
265 int iPixelFormat,
266 int iLayerPlane,
267 UINT nBytes,
268 LPLAYERPLANEDESCRIPTOR plpd )
269 {
270 return DrvDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
271 }
272
273 WINGDIAPI int APIENTRY
274 wglSetLayerPaletteEntries(
275 HDC hdc,
276 int iLayerPlane,
277 int iStart,
278 int cEntries,
279 CONST COLORREF *pcr )
280 {
281 return DrvSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
282 }
283
284 WINGDIAPI int APIENTRY
285 wglGetLayerPaletteEntries(
286 HDC hdc,
287 int iLayerPlane,
288 int iStart,
289 int cEntries,
290 COLORREF *pcr )
291 {
292 return DrvGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
293 }
294
295 WINGDIAPI BOOL APIENTRY
296 wglRealizeLayerPalette(
297 HDC hdc,
298 int iLayerPlane,
299 BOOL bRealize )
300 {
301 (void) hdc;
302 (void) iLayerPlane;
303 (void) bRealize;
304
305 assert( 0 );
306
307 return FALSE;
308 }