Merge branch 'glsl2-head' into glsl2
[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 DWORD WINAPI
101 wglSwapMultipleBuffers(UINT n,
102 CONST WGLSWAP *ps)
103 {
104 UINT i;
105
106 for (i =0; i < n; ++i)
107 wglSwapBuffers(ps->hdc);
108
109 return 0;
110 }
111
112
113 WINGDIAPI BOOL APIENTRY
114 wglSwapLayerBuffers(
115 HDC hdc,
116 UINT fuPlanes )
117 {
118 return DrvSwapLayerBuffers( hdc, fuPlanes );
119 }
120
121 WINGDIAPI PROC APIENTRY
122 wglGetProcAddress(
123 LPCSTR lpszProc )
124 {
125 return DrvGetProcAddress( lpszProc );
126 }
127
128
129 WINGDIAPI int APIENTRY
130 wglChoosePixelFormat(
131 HDC hdc,
132 CONST PIXELFORMATDESCRIPTOR *ppfd )
133 {
134 if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
135 return 0;
136 if (ppfd->iPixelType != PFD_TYPE_RGBA)
137 return 0;
138 if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
139 return 0;
140 if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
141 return 0;
142 if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
143 return 0;
144 if (ppfd->dwFlags & PFD_SUPPORT_GDI)
145 return 0;
146 if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
147 return 0;
148
149 return stw_pixelformat_choose( hdc, ppfd );
150 }
151
152 WINGDIAPI int APIENTRY
153 wglDescribePixelFormat(
154 HDC hdc,
155 int iPixelFormat,
156 UINT nBytes,
157 LPPIXELFORMATDESCRIPTOR ppfd )
158 {
159 return DrvDescribePixelFormat( hdc, iPixelFormat, nBytes, ppfd );
160 }
161
162 WINGDIAPI int APIENTRY
163 wglGetPixelFormat(
164 HDC hdc )
165 {
166 return stw_pixelformat_get( hdc );
167 }
168
169 WINGDIAPI BOOL APIENTRY
170 wglSetPixelFormat(
171 HDC hdc,
172 int iPixelFormat,
173 const PIXELFORMATDESCRIPTOR *ppfd )
174 {
175 if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
176 return FALSE;
177
178 return DrvSetPixelFormat( hdc, iPixelFormat );
179 }
180
181
182 WINGDIAPI BOOL APIENTRY
183 wglUseFontBitmapsA(
184 HDC hdc,
185 DWORD first,
186 DWORD count,
187 DWORD listBase )
188 {
189 (void) hdc;
190 (void) first;
191 (void) count;
192 (void) listBase;
193
194 assert( 0 );
195
196 return FALSE;
197 }
198
199 WINGDIAPI BOOL APIENTRY
200 wglShareLists(
201 HGLRC hglrc1,
202 HGLRC hglrc2 )
203 {
204 return DrvShareLists((DHGLRC)(UINT_PTR)hglrc1,
205 (DHGLRC)(UINT_PTR)hglrc2);
206 }
207
208 WINGDIAPI BOOL APIENTRY
209 wglUseFontBitmapsW(
210 HDC hdc,
211 DWORD first,
212 DWORD count,
213 DWORD listBase )
214 {
215 (void) hdc;
216 (void) first;
217 (void) count;
218 (void) listBase;
219
220 assert( 0 );
221
222 return FALSE;
223 }
224
225 WINGDIAPI BOOL APIENTRY
226 wglUseFontOutlinesA(
227 HDC hdc,
228 DWORD first,
229 DWORD count,
230 DWORD listBase,
231 FLOAT deviation,
232 FLOAT extrusion,
233 int format,
234 LPGLYPHMETRICSFLOAT lpgmf )
235 {
236 (void) hdc;
237 (void) first;
238 (void) count;
239 (void) listBase;
240 (void) deviation;
241 (void) extrusion;
242 (void) format;
243 (void) lpgmf;
244
245 assert( 0 );
246
247 return FALSE;
248 }
249
250 WINGDIAPI BOOL APIENTRY
251 wglUseFontOutlinesW(
252 HDC hdc,
253 DWORD first,
254 DWORD count,
255 DWORD listBase,
256 FLOAT deviation,
257 FLOAT extrusion,
258 int format,
259 LPGLYPHMETRICSFLOAT lpgmf )
260 {
261 (void) hdc;
262 (void) first;
263 (void) count;
264 (void) listBase;
265 (void) deviation;
266 (void) extrusion;
267 (void) format;
268 (void) lpgmf;
269
270 assert( 0 );
271
272 return FALSE;
273 }
274
275 WINGDIAPI BOOL APIENTRY
276 wglDescribeLayerPlane(
277 HDC hdc,
278 int iPixelFormat,
279 int iLayerPlane,
280 UINT nBytes,
281 LPLAYERPLANEDESCRIPTOR plpd )
282 {
283 return DrvDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
284 }
285
286 WINGDIAPI int APIENTRY
287 wglSetLayerPaletteEntries(
288 HDC hdc,
289 int iLayerPlane,
290 int iStart,
291 int cEntries,
292 CONST COLORREF *pcr )
293 {
294 return DrvSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
295 }
296
297 WINGDIAPI int APIENTRY
298 wglGetLayerPaletteEntries(
299 HDC hdc,
300 int iLayerPlane,
301 int iStart,
302 int cEntries,
303 COLORREF *pcr )
304 {
305 return DrvGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
306 }
307
308 WINGDIAPI BOOL APIENTRY
309 wglRealizeLayerPalette(
310 HDC hdc,
311 int iLayerPlane,
312 BOOL bRealize )
313 {
314 (void) hdc;
315 (void) iLayerPlane;
316 (void) bRealize;
317
318 assert( 0 );
319
320 return FALSE;
321 }