1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "cr_error.h"
|
---|
8 | #include "cr_spu.h"
|
---|
9 | #include "cr_environment.h"
|
---|
10 | #include "stub.h"
|
---|
11 |
|
---|
12 | /* I *know* most of the parameters are unused, dammit. */
|
---|
13 | #pragma warning( disable: 4100 )
|
---|
14 |
|
---|
15 | #define WIN32_LEAN_AND_MEAN
|
---|
16 | #include <windows.h>
|
---|
17 | #include <stdio.h>
|
---|
18 |
|
---|
19 | static GLuint desiredVisual = CR_RGB_BIT;
|
---|
20 |
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Compute a mask of CR_*_BIT flags which reflects the attributes of
|
---|
24 | * the pixel format of the given hdc.
|
---|
25 | */
|
---|
26 | static GLuint ComputeVisBits( HDC hdc )
|
---|
27 | {
|
---|
28 | PIXELFORMATDESCRIPTOR pfd;
|
---|
29 | int iPixelFormat;
|
---|
30 | GLuint b = 0;
|
---|
31 |
|
---|
32 | iPixelFormat = GetPixelFormat( hdc );
|
---|
33 |
|
---|
34 | DescribePixelFormat( hdc, iPixelFormat, sizeof(pfd), &pfd );
|
---|
35 |
|
---|
36 | if (pfd.cDepthBits > 0)
|
---|
37 | b |= CR_DEPTH_BIT;
|
---|
38 | if (pfd.cAccumBits > 0)
|
---|
39 | b |= CR_ACCUM_BIT;
|
---|
40 | if (pfd.cColorBits > 8)
|
---|
41 | b |= CR_RGB_BIT;
|
---|
42 | if (pfd.cStencilBits > 0)
|
---|
43 | b |= CR_STENCIL_BIT;
|
---|
44 | if (pfd.cAlphaBits > 0)
|
---|
45 | b |= CR_ALPHA_BIT;
|
---|
46 | if (pfd.dwFlags & PFD_DOUBLEBUFFER)
|
---|
47 | b |= CR_DOUBLE_BIT;
|
---|
48 | if (pfd.dwFlags & PFD_STEREO)
|
---|
49 | b |= CR_STEREO_BIT;
|
---|
50 |
|
---|
51 | return b;
|
---|
52 | }
|
---|
53 |
|
---|
54 | int WINAPI wglChoosePixelFormat_prox( HDC hdc, CONST PIXELFORMATDESCRIPTOR *pfd )
|
---|
55 | {
|
---|
56 | DWORD okayFlags;
|
---|
57 |
|
---|
58 | stubInit();
|
---|
59 |
|
---|
60 | /*
|
---|
61 | * NOTE!!!
|
---|
62 | * Here we're telling the renderspu not to use the GDI
|
---|
63 | * equivalent's of ChoosePixelFormat/DescribePixelFormat etc
|
---|
64 | * There are subtle differences in the use of these calls.
|
---|
65 | */
|
---|
66 | crSetenv("CR_WGL_DO_NOT_USE_GDI", "yes");
|
---|
67 |
|
---|
68 | if ( pfd->nSize != sizeof(*pfd) || pfd->nVersion != 1 ) {
|
---|
69 | crError( "wglChoosePixelFormat: bad pfd\n" );
|
---|
70 | return 0;
|
---|
71 | }
|
---|
72 |
|
---|
73 | okayFlags = ( PFD_DRAW_TO_WINDOW |
|
---|
74 | PFD_SUPPORT_GDI |
|
---|
75 | PFD_SUPPORT_OPENGL |
|
---|
76 | PFD_DOUBLEBUFFER |
|
---|
77 | PFD_DOUBLEBUFFER_DONTCARE |
|
---|
78 | PFD_SWAP_EXCHANGE |
|
---|
79 | PFD_SWAP_COPY |
|
---|
80 | PFD_STEREO |
|
---|
81 | PFD_STEREO_DONTCARE |
|
---|
82 | PFD_DEPTH_DONTCARE );
|
---|
83 | if ( pfd->dwFlags & ~okayFlags ) {
|
---|
84 | crWarning( "wglChoosePixelFormat: only support flags=0x%x, but you gave me flags=0x%x", okayFlags, pfd->dwFlags );
|
---|
85 | return 0;
|
---|
86 | }
|
---|
87 |
|
---|
88 | if ( pfd->iPixelType != PFD_TYPE_RGBA ) {
|
---|
89 | crError( "wglChoosePixelFormat: only support RGBA\n" );
|
---|
90 | }
|
---|
91 |
|
---|
92 | if ( pfd->cColorBits > 32 ||
|
---|
93 | pfd->cRedBits > 8 ||
|
---|
94 | pfd->cGreenBits > 8 ||
|
---|
95 | pfd->cBlueBits > 8 ||
|
---|
96 | pfd->cAlphaBits > 8 ) {
|
---|
97 | crWarning( "wglChoosePixelFormat: too much color precision requested\n" );
|
---|
98 | }
|
---|
99 |
|
---|
100 | if ( pfd->dwFlags & PFD_DOUBLEBUFFER )
|
---|
101 | desiredVisual |= CR_DOUBLE_BIT;
|
---|
102 |
|
---|
103 | if ( pfd->dwFlags & PFD_STEREO )
|
---|
104 | desiredVisual |= CR_STEREO_BIT;
|
---|
105 |
|
---|
106 | if ( pfd->cColorBits > 8)
|
---|
107 | desiredVisual |= CR_RGB_BIT;
|
---|
108 |
|
---|
109 | if ( pfd->cAccumBits > 0 ||
|
---|
110 | pfd->cAccumRedBits > 0 ||
|
---|
111 | pfd->cAccumGreenBits > 0 ||
|
---|
112 | pfd->cAccumBlueBits > 0 ||
|
---|
113 | pfd->cAccumAlphaBits > 0 ) {
|
---|
114 | crWarning( "wglChoosePixelFormat: asked for accumulation buffer, ignoring\n" );
|
---|
115 | }
|
---|
116 |
|
---|
117 | if ( pfd->cAccumBits > 0 )
|
---|
118 | desiredVisual |= CR_ACCUM_BIT;
|
---|
119 |
|
---|
120 | if ( pfd->cDepthBits > 32 ) {
|
---|
121 | crError( "wglChoosePixelFormat; asked for too many depth bits\n" );
|
---|
122 | }
|
---|
123 |
|
---|
124 | if ( pfd->cDepthBits > 0 )
|
---|
125 | desiredVisual |= CR_DEPTH_BIT;
|
---|
126 |
|
---|
127 | if ( pfd->cStencilBits > 8 ) {
|
---|
128 | crError( "wglChoosePixelFormat: asked for too many stencil bits\n" );
|
---|
129 | }
|
---|
130 |
|
---|
131 | if ( pfd->cStencilBits > 0 )
|
---|
132 | desiredVisual |= CR_STENCIL_BIT;
|
---|
133 |
|
---|
134 | if ( pfd->cAuxBuffers > 0 ) {
|
---|
135 | crError( "wglChoosePixelFormat: asked for aux buffers\n" );
|
---|
136 | }
|
---|
137 |
|
---|
138 | if ( pfd->iLayerType != PFD_MAIN_PLANE ) {
|
---|
139 | crError( "wglChoosePixelFormat: asked for a strange layer\n" );
|
---|
140 | }
|
---|
141 |
|
---|
142 | return 1;
|
---|
143 | }
|
---|
144 |
|
---|
145 | BOOL WINAPI wglSetPixelFormat_prox( HDC hdc, int pixelFormat,
|
---|
146 | CONST PIXELFORMATDESCRIPTOR *pdf )
|
---|
147 | {
|
---|
148 | if ( pixelFormat != 1 ) {
|
---|
149 | crError( "wglSetPixelFormat: pixelFormat=%d?\n", pixelFormat );
|
---|
150 | }
|
---|
151 |
|
---|
152 | return 1;
|
---|
153 | }
|
---|
154 |
|
---|
155 | BOOL WINAPI wglDeleteContext_prox( HGLRC hglrc )
|
---|
156 | {
|
---|
157 | stubDestroyContext( (unsigned long) hglrc );
|
---|
158 | return 1;
|
---|
159 | }
|
---|
160 |
|
---|
161 | BOOL WINAPI wglMakeCurrent_prox( HDC hdc, HGLRC hglrc )
|
---|
162 | {
|
---|
163 | ContextInfo *context;
|
---|
164 | WindowInfo *window;
|
---|
165 | BOOL ret;
|
---|
166 |
|
---|
167 | crHashtableLock(stub.windowTable);
|
---|
168 | crHashtableLock(stub.contextTable);
|
---|
169 |
|
---|
170 | context = (ContextInfo *) crHashtableSearch(stub.contextTable, (unsigned long) hglrc);
|
---|
171 | window = stubGetWindowInfo(hdc);
|
---|
172 |
|
---|
173 | if (hglrc!=0 && !context)
|
---|
174 | {
|
---|
175 | crWarning("wglMakeCurrent got unexpected hglrc 0x%x", hglrc);
|
---|
176 | }
|
---|
177 |
|
---|
178 | ret = stubMakeCurrent( window, context );
|
---|
179 |
|
---|
180 | crHashtableUnlock(stub.contextTable);
|
---|
181 | crHashtableUnlock(stub.windowTable);
|
---|
182 |
|
---|
183 | return ret;
|
---|
184 | }
|
---|
185 |
|
---|
186 | HGLRC WINAPI wglGetCurrentContext_prox( void )
|
---|
187 | {
|
---|
188 | ContextInfo *context = stubGetCurrentContext();
|
---|
189 | return (HGLRC) (context ? context->id : 0);
|
---|
190 | }
|
---|
191 |
|
---|
192 | HDC WINAPI wglGetCurrentDC_prox( void )
|
---|
193 | {
|
---|
194 | ContextInfo *context = stubGetCurrentContext();
|
---|
195 | if (context && context->currentDrawable)
|
---|
196 | return (HDC) context->currentDrawable->drawable;
|
---|
197 | else
|
---|
198 | return (HDC) NULL;
|
---|
199 | }
|
---|
200 |
|
---|
201 | int WINAPI wglGetPixelFormat_prox( HDC hdc )
|
---|
202 | {
|
---|
203 | /* this is what we call our generic pixelformat, regardless of the HDC */
|
---|
204 | return 1;
|
---|
205 | }
|
---|
206 |
|
---|
207 | int WINAPI wglDescribePixelFormat_prox( HDC hdc, int pixelFormat, UINT nBytes,
|
---|
208 | LPPIXELFORMATDESCRIPTOR pfd )
|
---|
209 | {
|
---|
210 | /* if ( pixelFormat != 1 ) {
|
---|
211 | * crError( "wglDescribePixelFormat: pixelFormat=%d?\n", pixelFormat );
|
---|
212 | * return 0;
|
---|
213 | * } */
|
---|
214 |
|
---|
215 | if ( !pfd ) {
|
---|
216 | crWarning( "wglDescribePixelFormat: pfd=NULL\n" );
|
---|
217 | return 1; /* There's only one, baby */
|
---|
218 | }
|
---|
219 |
|
---|
220 | if ( nBytes != sizeof(*pfd) ) {
|
---|
221 | crWarning( "wglDescribePixelFormat: nBytes=%u?\n", nBytes );
|
---|
222 | return 1; /* There's only one, baby */
|
---|
223 | }
|
---|
224 |
|
---|
225 | pfd->nSize = sizeof(*pfd);
|
---|
226 | pfd->nVersion = 1;
|
---|
227 | pfd->dwFlags = ( PFD_DRAW_TO_WINDOW |
|
---|
228 | PFD_SUPPORT_GDI |
|
---|
229 | PFD_SUPPORT_OPENGL |
|
---|
230 | PFD_DOUBLEBUFFER );
|
---|
231 | pfd->iPixelType = PFD_TYPE_RGBA;
|
---|
232 | pfd->cColorBits = 32;
|
---|
233 | pfd->cRedBits = 8;
|
---|
234 | pfd->cRedShift = 24;
|
---|
235 | pfd->cGreenBits = 8;
|
---|
236 | pfd->cGreenShift = 16;
|
---|
237 | pfd->cBlueBits = 8;
|
---|
238 | pfd->cBlueShift = 8;
|
---|
239 | pfd->cAlphaBits = 8;
|
---|
240 | pfd->cAlphaShift = 0;
|
---|
241 | pfd->cAccumBits = 0;
|
---|
242 | pfd->cAccumRedBits = 0;
|
---|
243 | pfd->cAccumGreenBits = 0;
|
---|
244 | pfd->cAccumBlueBits = 0;
|
---|
245 | pfd->cAccumAlphaBits = 0;
|
---|
246 | pfd->cDepthBits = 32;
|
---|
247 | pfd->cStencilBits = 8;
|
---|
248 | pfd->cAuxBuffers = 0;
|
---|
249 | pfd->iLayerType = PFD_MAIN_PLANE;
|
---|
250 | pfd->bReserved = 0;
|
---|
251 | pfd->dwLayerMask = 0;
|
---|
252 | pfd->dwVisibleMask = 0;
|
---|
253 | pfd->dwDamageMask = 0;
|
---|
254 |
|
---|
255 | /* the max PFD index */
|
---|
256 | return 1;
|
---|
257 | }
|
---|
258 |
|
---|
259 | BOOL WINAPI wglShareLists_prox( HGLRC hglrc1, HGLRC hglrc2 )
|
---|
260 | {
|
---|
261 | crWarning( "wglShareLists: unsupported" );
|
---|
262 | return 0;
|
---|
263 | }
|
---|
264 |
|
---|
265 |
|
---|
266 | HGLRC WINAPI wglCreateContext_prox( HDC hdc )
|
---|
267 | {
|
---|
268 | char dpyName[MAX_DPY_NAME];
|
---|
269 | ContextInfo *context;
|
---|
270 |
|
---|
271 | stubInit();
|
---|
272 |
|
---|
273 | CRASSERT(stub.contextTable);
|
---|
274 |
|
---|
275 | sprintf(dpyName, "%d", hdc);
|
---|
276 | if (stub.haveNativeOpenGL)
|
---|
277 | desiredVisual |= ComputeVisBits( hdc );
|
---|
278 |
|
---|
279 | context = stubNewContext(dpyName, desiredVisual, UNDECIDED, 0);
|
---|
280 | if (!context)
|
---|
281 | return 0;
|
---|
282 |
|
---|
283 | return (HGLRC) context->id;
|
---|
284 | }
|
---|
285 |
|
---|
286 | BOOL WINAPI
|
---|
287 | wglSwapBuffers_prox( HDC hdc )
|
---|
288 | {
|
---|
289 | WindowInfo *window = stubGetWindowInfo(hdc);
|
---|
290 | stubSwapBuffers( window, 0 );
|
---|
291 | return 1;
|
---|
292 | }
|
---|
293 |
|
---|
294 | BOOL WINAPI wglCopyContext_prox( HGLRC src, HGLRC dst, UINT mask )
|
---|
295 | {
|
---|
296 | crWarning( "wglCopyContext: unsupported" );
|
---|
297 | return 0;
|
---|
298 | }
|
---|
299 |
|
---|
300 | HGLRC WINAPI wglCreateLayerContext_prox( HDC hdc, int layerPlane )
|
---|
301 | {
|
---|
302 | stubInit();
|
---|
303 | crWarning( "wglCreateLayerContext: unsupported" );
|
---|
304 | return 0;
|
---|
305 | }
|
---|
306 |
|
---|
307 | PROC WINAPI wglGetProcAddress_prox( LPCSTR name )
|
---|
308 | {
|
---|
309 | return (PROC) crGetProcAddress( name );
|
---|
310 | }
|
---|
311 |
|
---|
312 | BOOL WINAPI wglUseFontBitmapsA_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase )
|
---|
313 | {
|
---|
314 | crWarning( "wglUseFontBitmapsA: unsupported" );
|
---|
315 | return 0;
|
---|
316 | }
|
---|
317 |
|
---|
318 | BOOL WINAPI wglUseFontBitmapsW_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase )
|
---|
319 | {
|
---|
320 | crWarning( "wglUseFontBitmapsW: unsupported" );
|
---|
321 | return 0;
|
---|
322 | }
|
---|
323 |
|
---|
324 | BOOL WINAPI wglDescribeLayerPlane_prox( HDC hdc, int pixelFormat, int layerPlane,
|
---|
325 | UINT nBytes, LPLAYERPLANEDESCRIPTOR lpd )
|
---|
326 | {
|
---|
327 | crWarning( "wglDescribeLayerPlane: unimplemented" );
|
---|
328 | return 0;
|
---|
329 | }
|
---|
330 |
|
---|
331 | int WINAPI wglSetLayerPaletteEntries_prox( HDC hdc, int layerPlane, int start,
|
---|
332 | int entries, CONST COLORREF *cr )
|
---|
333 | {
|
---|
334 | crWarning( "wglSetLayerPaletteEntries: unsupported" );
|
---|
335 | return 0;
|
---|
336 | }
|
---|
337 |
|
---|
338 | int WINAPI wglGetLayerPaletteEntries_prox( HDC hdc, int layerPlane, int start,
|
---|
339 | int entries, COLORREF *cr )
|
---|
340 | {
|
---|
341 | crWarning( "wglGetLayerPaletteEntries: unsupported" );
|
---|
342 | return 0;
|
---|
343 | }
|
---|
344 |
|
---|
345 | BOOL WINAPI wglRealizeLayerPalette_prox( HDC hdc, int layerPlane, BOOL realize )
|
---|
346 | {
|
---|
347 | crWarning( "wglRealizeLayerPalette: unsupported" );
|
---|
348 | return 0;
|
---|
349 | }
|
---|
350 |
|
---|
351 | DWORD WINAPI wglSwapMultipleBuffers_prox( UINT a, CONST void *b )
|
---|
352 | {
|
---|
353 | crWarning( "wglSwapMultipleBuffer: unsupported" );
|
---|
354 | return 0;
|
---|
355 | }
|
---|
356 |
|
---|
357 | BOOL WINAPI wglUseFontOutlinesA_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase,
|
---|
358 | FLOAT deviation, FLOAT extrusion, int format,
|
---|
359 | LPGLYPHMETRICSFLOAT gmf )
|
---|
360 | {
|
---|
361 | crWarning( "wglUseFontOutlinesA: unsupported" );
|
---|
362 | return 0;
|
---|
363 | }
|
---|
364 |
|
---|
365 | BOOL WINAPI wglUseFontOutlinesW_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase,
|
---|
366 | FLOAT deviation, FLOAT extrusion, int format,
|
---|
367 | LPGLYPHMETRICSFLOAT gmf )
|
---|
368 | {
|
---|
369 | crWarning( "wglUseFontOutlinesW: unsupported" );
|
---|
370 | return 0;
|
---|
371 | }
|
---|
372 |
|
---|
373 | BOOL WINAPI wglSwapLayerBuffers_prox( HDC hdc, UINT planes )
|
---|
374 | {
|
---|
375 | if (planes == WGL_SWAP_MAIN_PLANE)
|
---|
376 | {
|
---|
377 | return wglSwapBuffers_prox(hdc);
|
---|
378 | }
|
---|
379 | else
|
---|
380 | {
|
---|
381 | crWarning( "wglSwapLayerBuffers: unsupported" );
|
---|
382 | return 0;
|
---|
383 | }
|
---|
384 | }
|
---|
385 |
|
---|
386 | BOOL WINAPI wglChoosePixelFormatEXT_prox
|
---|
387 | (HDC hdc, const int *piAttributes, const FLOAT *pfAttributes, UINT nMaxFormats, int *piFormats, UINT *nNumFormats)
|
---|
388 | {
|
---|
389 | int *pi;
|
---|
390 | int wants_rgb = 0;
|
---|
391 |
|
---|
392 | stubInit();
|
---|
393 |
|
---|
394 | /* TODO : Need to check pfAttributes too ! */
|
---|
395 |
|
---|
396 | for ( pi = (int *)piAttributes; *pi != 0; pi++ )
|
---|
397 | {
|
---|
398 | switch ( *pi )
|
---|
399 | {
|
---|
400 | case WGL_COLOR_BITS_EXT:
|
---|
401 | if (pi[1] > 8)
|
---|
402 | wants_rgb = 1;
|
---|
403 | pi++;
|
---|
404 | break;
|
---|
405 |
|
---|
406 | case WGL_RED_BITS_EXT:
|
---|
407 | case WGL_GREEN_BITS_EXT:
|
---|
408 | case WGL_BLUE_BITS_EXT:
|
---|
409 | if (pi[1] > 3)
|
---|
410 | wants_rgb = 1;
|
---|
411 | pi++;
|
---|
412 | break;
|
---|
413 |
|
---|
414 | case WGL_ACCUM_ALPHA_BITS_EXT:
|
---|
415 | case WGL_ALPHA_BITS_EXT:
|
---|
416 | if (pi[1] > 0)
|
---|
417 | desiredVisual |= CR_ALPHA_BIT;
|
---|
418 | pi++;
|
---|
419 | break;
|
---|
420 |
|
---|
421 | case WGL_DOUBLE_BUFFER_EXT:
|
---|
422 | if (pi[1] > 0)
|
---|
423 | desiredVisual |= CR_DOUBLE_BIT;
|
---|
424 | pi++;
|
---|
425 | break;
|
---|
426 |
|
---|
427 | case WGL_STEREO_EXT:
|
---|
428 | if (pi[1] > 0)
|
---|
429 | desiredVisual |= CR_STEREO_BIT;
|
---|
430 | pi++;
|
---|
431 | break;
|
---|
432 |
|
---|
433 | case WGL_DEPTH_BITS_EXT:
|
---|
434 | if (pi[1] > 0)
|
---|
435 | desiredVisual |= CR_DEPTH_BIT;
|
---|
436 | pi++;
|
---|
437 | break;
|
---|
438 |
|
---|
439 | case WGL_STENCIL_BITS_EXT:
|
---|
440 | if (pi[1] > 0)
|
---|
441 | desiredVisual |= CR_STENCIL_BIT;
|
---|
442 | pi++;
|
---|
443 | break;
|
---|
444 |
|
---|
445 | case WGL_ACCUM_RED_BITS_EXT:
|
---|
446 | case WGL_ACCUM_GREEN_BITS_EXT:
|
---|
447 | case WGL_ACCUM_BLUE_BITS_EXT:
|
---|
448 | if (pi[1] > 0)
|
---|
449 | desiredVisual |= CR_ACCUM_BIT;
|
---|
450 | pi++;
|
---|
451 | break;
|
---|
452 |
|
---|
453 | case WGL_SAMPLE_BUFFERS_EXT:
|
---|
454 | case WGL_SAMPLES_EXT:
|
---|
455 | if (pi[1] > 0)
|
---|
456 | desiredVisual |= CR_MULTISAMPLE_BIT;
|
---|
457 | pi++;
|
---|
458 | break;
|
---|
459 |
|
---|
460 | case WGL_SUPPORT_OPENGL_ARB:
|
---|
461 | case WGL_DRAW_TO_WINDOW_ARB:
|
---|
462 | case WGL_ACCELERATION_ARB:
|
---|
463 | pi++;
|
---|
464 | break;
|
---|
465 |
|
---|
466 | case WGL_PIXEL_TYPE_ARB:
|
---|
467 | if(pi[1]!=WGL_TYPE_RGBA_ARB)
|
---|
468 | {
|
---|
469 | crWarning("WGL_PIXEL_TYPE 0x%x not supported!", pi[1]);
|
---|
470 | return 0;
|
---|
471 | }
|
---|
472 | pi++;
|
---|
473 | break;
|
---|
474 |
|
---|
475 | default:
|
---|
476 | crWarning( "wglChoosePixelFormatEXT: bad pi=0x%x", *pi );
|
---|
477 | return 0;
|
---|
478 | }
|
---|
479 | }
|
---|
480 |
|
---|
481 | if (nNumFormats) *nNumFormats = 1;
|
---|
482 | if (nMaxFormats>0 && piFormats)
|
---|
483 | {
|
---|
484 | piFormats[0] = 1;
|
---|
485 | }
|
---|
486 |
|
---|
487 | return 1;
|
---|
488 | }
|
---|
489 |
|
---|
490 | BOOL WINAPI wglGetPixelFormatAttribivEXT_prox
|
---|
491 | (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *pValues)
|
---|
492 | {
|
---|
493 | UINT i;
|
---|
494 |
|
---|
495 | if (!pValues || !piAttributes) return 0;
|
---|
496 |
|
---|
497 | if ((nAttributes!=1) || (piAttributes && piAttributes[0]!=WGL_NUMBER_PIXEL_FORMATS_ARB))
|
---|
498 | {
|
---|
499 | if (iPixelFormat!=1)
|
---|
500 | {
|
---|
501 | crDebug("wglGetPixelFormatAttribivARB: bad pf:%i", iPixelFormat);
|
---|
502 | return 0;
|
---|
503 | }
|
---|
504 | }
|
---|
505 |
|
---|
506 | for (i=0; i<nAttributes; ++i)
|
---|
507 | {
|
---|
508 | switch (piAttributes[i])
|
---|
509 | {
|
---|
510 | case WGL_NUMBER_PIXEL_FORMATS_ARB:
|
---|
511 | pValues[i] = 1;
|
---|
512 | break;
|
---|
513 | case WGL_DRAW_TO_WINDOW_ARB:
|
---|
514 | case WGL_SUPPORT_OPENGL_ARB:
|
---|
515 | case WGL_DOUBLE_BUFFER_ARB:
|
---|
516 | case WGL_STEREO_ARB:
|
---|
517 | pValues[i] = 1;
|
---|
518 | break;
|
---|
519 | case WGL_DRAW_TO_BITMAP_ARB:
|
---|
520 | case WGL_NEED_PALETTE_ARB:
|
---|
521 | case WGL_NEED_SYSTEM_PALETTE_ARB:
|
---|
522 | case WGL_SWAP_LAYER_BUFFERS_ARB:
|
---|
523 | case WGL_NUMBER_OVERLAYS_ARB:
|
---|
524 | case WGL_NUMBER_UNDERLAYS_ARB:
|
---|
525 | case WGL_TRANSPARENT_ARB:
|
---|
526 | case WGL_TRANSPARENT_RED_VALUE_ARB:
|
---|
527 | case WGL_TRANSPARENT_GREEN_VALUE_ARB:
|
---|
528 | case WGL_TRANSPARENT_BLUE_VALUE_ARB:
|
---|
529 | case WGL_TRANSPARENT_ALPHA_VALUE_ARB:
|
---|
530 | case WGL_TRANSPARENT_INDEX_VALUE_ARB:
|
---|
531 | case WGL_SHARE_DEPTH_ARB:
|
---|
532 | case WGL_SHARE_STENCIL_ARB:
|
---|
533 | case WGL_SHARE_ACCUM_ARB:
|
---|
534 | case WGL_SUPPORT_GDI_ARB:
|
---|
535 | pValues[i] = 0;
|
---|
536 | break;
|
---|
537 | case WGL_ACCELERATION_ARB:
|
---|
538 | pValues[i] = WGL_FULL_ACCELERATION_ARB;
|
---|
539 | break;
|
---|
540 | case WGL_SWAP_METHOD_ARB:
|
---|
541 | pValues[i] = WGL_SWAP_UNDEFINED_ARB;
|
---|
542 | break;
|
---|
543 | case WGL_PIXEL_TYPE_ARB:
|
---|
544 | pValues[i] = WGL_TYPE_RGBA_ARB;
|
---|
545 | break;
|
---|
546 | case WGL_COLOR_BITS_ARB:
|
---|
547 | pValues[i] = 32;
|
---|
548 | break;
|
---|
549 | case WGL_RED_BITS_ARB:
|
---|
550 | case WGL_GREEN_BITS_ARB:
|
---|
551 | case WGL_BLUE_BITS_ARB:
|
---|
552 | case WGL_ALPHA_BITS_ARB:
|
---|
553 | pValues[i] = 8;
|
---|
554 | break;
|
---|
555 | case WGL_RED_SHIFT_ARB:
|
---|
556 | pValues[i] = 24;
|
---|
557 | break;
|
---|
558 | case WGL_GREEN_SHIFT_ARB:
|
---|
559 | pValues[i] = 16;
|
---|
560 | break;
|
---|
561 | case WGL_BLUE_SHIFT_ARB:
|
---|
562 | pValues[i] = 8;
|
---|
563 | break;
|
---|
564 | case WGL_ALPHA_SHIFT_ARB:
|
---|
565 | pValues[i] = 0;
|
---|
566 | break;
|
---|
567 | case WGL_ACCUM_BITS_ARB:
|
---|
568 | pValues[i] = 0;
|
---|
569 | break;
|
---|
570 | case WGL_ACCUM_RED_BITS_ARB:
|
---|
571 | pValues[i] = 0;
|
---|
572 | break;
|
---|
573 | case WGL_ACCUM_GREEN_BITS_ARB:
|
---|
574 | pValues[i] = 0;
|
---|
575 | break;
|
---|
576 | case WGL_ACCUM_BLUE_BITS_ARB:
|
---|
577 | pValues[i] = 0;
|
---|
578 | break;
|
---|
579 | case WGL_ACCUM_ALPHA_BITS_ARB:
|
---|
580 | pValues[i] = 0;
|
---|
581 | break;
|
---|
582 | case WGL_DEPTH_BITS_ARB:
|
---|
583 | pValues[i] = 32;
|
---|
584 | break;
|
---|
585 | case WGL_STENCIL_BITS_ARB:
|
---|
586 | pValues[i] = 8;
|
---|
587 | break;
|
---|
588 | case WGL_AUX_BUFFERS_ARB:
|
---|
589 | pValues[i] = 0;
|
---|
590 | break;
|
---|
591 | case WGL_SAMPLE_BUFFERS_EXT:
|
---|
592 | pValues[i] = 1;
|
---|
593 | break;
|
---|
594 | case WGL_SAMPLES_EXT:
|
---|
595 | pValues[i] = 1;
|
---|
596 | break;
|
---|
597 | default:
|
---|
598 | crWarning("wglGetPixelFormatAttribivARB: bad attrib=0x%x", piAttributes[i]);
|
---|
599 | return 0;
|
---|
600 | }
|
---|
601 | }
|
---|
602 |
|
---|
603 | return 1;
|
---|
604 | }
|
---|
605 |
|
---|
606 | BOOL WINAPI wglGetPixelFormatAttribfvEXT_prox
|
---|
607 | (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, float *pValues)
|
---|
608 | {
|
---|
609 | UINT i;
|
---|
610 |
|
---|
611 | if (!pValues || !piAttributes) return 0;
|
---|
612 |
|
---|
613 | if ((nAttributes!=1) || (piAttributes && piAttributes[0]!=WGL_NUMBER_PIXEL_FORMATS_ARB))
|
---|
614 | {
|
---|
615 | if (iPixelFormat!=1)
|
---|
616 | {
|
---|
617 | crDebug("wglGetPixelFormatAttribivARB: bad pf:%i", iPixelFormat);
|
---|
618 | return 0;
|
---|
619 | }
|
---|
620 | }
|
---|
621 |
|
---|
622 | for (i=0; i<nAttributes; ++i)
|
---|
623 | {
|
---|
624 | switch (piAttributes[i])
|
---|
625 | {
|
---|
626 | case WGL_NUMBER_PIXEL_FORMATS_ARB:
|
---|
627 | pValues[i] = 1.f;
|
---|
628 | break;
|
---|
629 | case WGL_DRAW_TO_WINDOW_ARB:
|
---|
630 | case WGL_SUPPORT_OPENGL_ARB:
|
---|
631 | case WGL_DOUBLE_BUFFER_ARB:
|
---|
632 | case WGL_STEREO_ARB:
|
---|
633 | pValues[i] = 1.f;
|
---|
634 | break;
|
---|
635 | case WGL_DRAW_TO_BITMAP_ARB:
|
---|
636 | case WGL_NEED_PALETTE_ARB:
|
---|
637 | case WGL_NEED_SYSTEM_PALETTE_ARB:
|
---|
638 | case WGL_SWAP_LAYER_BUFFERS_ARB:
|
---|
639 | case WGL_NUMBER_OVERLAYS_ARB:
|
---|
640 | case WGL_NUMBER_UNDERLAYS_ARB:
|
---|
641 | case WGL_TRANSPARENT_ARB:
|
---|
642 | case WGL_TRANSPARENT_RED_VALUE_ARB:
|
---|
643 | case WGL_TRANSPARENT_GREEN_VALUE_ARB:
|
---|
644 | case WGL_TRANSPARENT_BLUE_VALUE_ARB:
|
---|
645 | case WGL_TRANSPARENT_ALPHA_VALUE_ARB:
|
---|
646 | case WGL_TRANSPARENT_INDEX_VALUE_ARB:
|
---|
647 | case WGL_SHARE_DEPTH_ARB:
|
---|
648 | case WGL_SHARE_STENCIL_ARB:
|
---|
649 | case WGL_SHARE_ACCUM_ARB:
|
---|
650 | case WGL_SUPPORT_GDI_ARB:
|
---|
651 | pValues[i] = 0.f;
|
---|
652 | break;
|
---|
653 | case WGL_ACCELERATION_ARB:
|
---|
654 | pValues[i] = WGL_FULL_ACCELERATION_ARB;
|
---|
655 | break;
|
---|
656 | case WGL_SWAP_METHOD_ARB:
|
---|
657 | pValues[i] = WGL_SWAP_UNDEFINED_ARB;
|
---|
658 | break;
|
---|
659 | case WGL_PIXEL_TYPE_ARB:
|
---|
660 | pValues[i] = WGL_TYPE_RGBA_ARB;
|
---|
661 | break;
|
---|
662 | case WGL_COLOR_BITS_ARB:
|
---|
663 | pValues[i] = 32.f;
|
---|
664 | break;
|
---|
665 | case WGL_RED_BITS_ARB:
|
---|
666 | case WGL_GREEN_BITS_ARB:
|
---|
667 | case WGL_BLUE_BITS_ARB:
|
---|
668 | case WGL_ALPHA_BITS_ARB:
|
---|
669 | pValues[i] = 8.f;
|
---|
670 | break;
|
---|
671 | case WGL_RED_SHIFT_ARB:
|
---|
672 | pValues[i] = 24.f;
|
---|
673 | break;
|
---|
674 | case WGL_GREEN_SHIFT_ARB:
|
---|
675 | pValues[i] = 16.f;
|
---|
676 | break;
|
---|
677 | case WGL_BLUE_SHIFT_ARB:
|
---|
678 | pValues[i] = 8.f;
|
---|
679 | break;
|
---|
680 | case WGL_ALPHA_SHIFT_ARB:
|
---|
681 | pValues[i] = 0.f;
|
---|
682 | break;
|
---|
683 | case WGL_ACCUM_BITS_ARB:
|
---|
684 | pValues[i] = 0.f;
|
---|
685 | break;
|
---|
686 | case WGL_ACCUM_RED_BITS_ARB:
|
---|
687 | pValues[i] = 0.f;
|
---|
688 | break;
|
---|
689 | case WGL_ACCUM_GREEN_BITS_ARB:
|
---|
690 | pValues[i] = 0.f;
|
---|
691 | break;
|
---|
692 | case WGL_ACCUM_BLUE_BITS_ARB:
|
---|
693 | pValues[i] = 0.f;
|
---|
694 | break;
|
---|
695 | case WGL_ACCUM_ALPHA_BITS_ARB:
|
---|
696 | pValues[i] = 0.f;
|
---|
697 | break;
|
---|
698 | case WGL_DEPTH_BITS_ARB:
|
---|
699 | pValues[i] = 32.f;
|
---|
700 | break;
|
---|
701 | case WGL_STENCIL_BITS_ARB:
|
---|
702 | pValues[i] = 8.f;
|
---|
703 | break;
|
---|
704 | case WGL_AUX_BUFFERS_ARB:
|
---|
705 | pValues[i] = 0.f;
|
---|
706 | break;
|
---|
707 | case WGL_SAMPLE_BUFFERS_EXT:
|
---|
708 | pValues[i] = 1.f;
|
---|
709 | break;
|
---|
710 | case WGL_SAMPLES_EXT:
|
---|
711 | pValues[i] = 1.f;
|
---|
712 | break;
|
---|
713 | default:
|
---|
714 | crWarning("wglGetPixelFormatAttribivARB: bad attrib=0x%x", piAttributes[i]);
|
---|
715 | return 0;
|
---|
716 | }
|
---|
717 | }
|
---|
718 |
|
---|
719 | return 1;
|
---|
720 | }
|
---|
721 |
|
---|
722 | BOOL WINAPI wglSwapIntervalEXT_prox(int interval)
|
---|
723 | {
|
---|
724 | return TRUE;
|
---|
725 | }
|
---|
726 |
|
---|
727 | int WINAPI wglGetSwapIntervalEXT_prox()
|
---|
728 | {
|
---|
729 | return 1;
|
---|
730 | }
|
---|
731 |
|
---|
732 | static GLubyte *gsz_wgl_extensions = "WGL_EXT_pixel_format WGL_ARB_pixel_format WGL_ARB_multisample";
|
---|
733 |
|
---|
734 | const GLubyte * WINAPI wglGetExtensionsStringEXT_prox()
|
---|
735 | {
|
---|
736 | return gsz_wgl_extensions;
|
---|
737 | }
|
---|
738 |
|
---|
739 | const GLubyte * WINAPI wglGetExtensionsStringARB_prox(HDC hdc)
|
---|
740 | {
|
---|
741 | (void) hdc;
|
---|
742 |
|
---|
743 | return gsz_wgl_extensions;
|
---|
744 | }
|
---|