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 |
|
---|
166 | context = (ContextInfo *) crHashtableSearch(stub.contextTable, (unsigned long) hglrc);
|
---|
167 | window = stubGetWindowInfo(hdc);
|
---|
168 |
|
---|
169 | if (hglrc!=0 && !context)
|
---|
170 | {
|
---|
171 | crWarning("wglMakeCurrent got unexpected hglrc 0x%x", hglrc);
|
---|
172 | }
|
---|
173 |
|
---|
174 | return stubMakeCurrent( window, context );
|
---|
175 | }
|
---|
176 |
|
---|
177 | HGLRC WINAPI wglGetCurrentContext_prox( void )
|
---|
178 | {
|
---|
179 | return (HGLRC) (stub.currentContext ? stub.currentContext->id : 0);
|
---|
180 | }
|
---|
181 |
|
---|
182 | HDC WINAPI wglGetCurrentDC_prox( void )
|
---|
183 | {
|
---|
184 | if (stub.currentContext && stub.currentContext->currentDrawable)
|
---|
185 | return (HDC) stub.currentContext->currentDrawable->drawable;
|
---|
186 | else
|
---|
187 | return (HDC) NULL;
|
---|
188 | }
|
---|
189 |
|
---|
190 | int WINAPI wglGetPixelFormat_prox( HDC hdc )
|
---|
191 | {
|
---|
192 | /* this is what we call our generic pixelformat, regardless of the HDC */
|
---|
193 | return 1;
|
---|
194 | }
|
---|
195 |
|
---|
196 | int WINAPI wglDescribePixelFormat_prox( HDC hdc, int pixelFormat, UINT nBytes,
|
---|
197 | LPPIXELFORMATDESCRIPTOR pfd )
|
---|
198 | {
|
---|
199 | /* if ( pixelFormat != 1 ) {
|
---|
200 | * crError( "wglDescribePixelFormat: pixelFormat=%d?\n", pixelFormat );
|
---|
201 | * return 0;
|
---|
202 | * } */
|
---|
203 |
|
---|
204 | if ( !pfd ) {
|
---|
205 | crWarning( "wglDescribePixelFormat: pfd=NULL\n" );
|
---|
206 | return 1; /* There's only one, baby */
|
---|
207 | }
|
---|
208 |
|
---|
209 | if ( nBytes != sizeof(*pfd) ) {
|
---|
210 | crWarning( "wglDescribePixelFormat: nBytes=%u?\n", nBytes );
|
---|
211 | return 1; /* There's only one, baby */
|
---|
212 | }
|
---|
213 |
|
---|
214 | pfd->nSize = sizeof(*pfd);
|
---|
215 | pfd->nVersion = 1;
|
---|
216 | pfd->dwFlags = ( PFD_DRAW_TO_WINDOW |
|
---|
217 | PFD_SUPPORT_GDI |
|
---|
218 | PFD_SUPPORT_OPENGL |
|
---|
219 | PFD_DOUBLEBUFFER );
|
---|
220 | pfd->iPixelType = PFD_TYPE_RGBA;
|
---|
221 | pfd->cColorBits = 32;
|
---|
222 | pfd->cRedBits = 8;
|
---|
223 | pfd->cRedShift = 24;
|
---|
224 | pfd->cGreenBits = 8;
|
---|
225 | pfd->cGreenShift = 16;
|
---|
226 | pfd->cBlueBits = 8;
|
---|
227 | pfd->cBlueShift = 8;
|
---|
228 | pfd->cAlphaBits = 8;
|
---|
229 | pfd->cAlphaShift = 0;
|
---|
230 | pfd->cAccumBits = 0;
|
---|
231 | pfd->cAccumRedBits = 0;
|
---|
232 | pfd->cAccumGreenBits = 0;
|
---|
233 | pfd->cAccumBlueBits = 0;
|
---|
234 | pfd->cAccumAlphaBits = 0;
|
---|
235 | pfd->cDepthBits = 32;
|
---|
236 | pfd->cStencilBits = 8;
|
---|
237 | pfd->cAuxBuffers = 0;
|
---|
238 | pfd->iLayerType = PFD_MAIN_PLANE;
|
---|
239 | pfd->bReserved = 0;
|
---|
240 | pfd->dwLayerMask = 0;
|
---|
241 | pfd->dwVisibleMask = 0;
|
---|
242 | pfd->dwDamageMask = 0;
|
---|
243 |
|
---|
244 | /* the max PFD index */
|
---|
245 | return 1;
|
---|
246 | }
|
---|
247 |
|
---|
248 | BOOL WINAPI wglShareLists_prox( HGLRC hglrc1, HGLRC hglrc2 )
|
---|
249 | {
|
---|
250 | crWarning( "wglShareLists: unsupported" );
|
---|
251 | return 0;
|
---|
252 | }
|
---|
253 |
|
---|
254 |
|
---|
255 | HGLRC WINAPI wglCreateContext_prox( HDC hdc )
|
---|
256 | {
|
---|
257 | char dpyName[MAX_DPY_NAME];
|
---|
258 | ContextInfo *context;
|
---|
259 |
|
---|
260 | stubInit();
|
---|
261 |
|
---|
262 | CRASSERT(stub.contextTable);
|
---|
263 |
|
---|
264 | sprintf(dpyName, "%d", hdc);
|
---|
265 | if (stub.haveNativeOpenGL)
|
---|
266 | desiredVisual |= ComputeVisBits( hdc );
|
---|
267 |
|
---|
268 | context = stubNewContext(dpyName, desiredVisual, UNDECIDED, 0);
|
---|
269 | if (!context)
|
---|
270 | return 0;
|
---|
271 |
|
---|
272 | return (HGLRC) context->id;
|
---|
273 | }
|
---|
274 |
|
---|
275 | BOOL WINAPI
|
---|
276 | wglSwapBuffers_prox( HDC hdc )
|
---|
277 | {
|
---|
278 | WindowInfo *window = stubGetWindowInfo(hdc);
|
---|
279 | stubSwapBuffers( window, 0 );
|
---|
280 | return 1;
|
---|
281 | }
|
---|
282 |
|
---|
283 | BOOL WINAPI wglCopyContext_prox( HGLRC src, HGLRC dst, UINT mask )
|
---|
284 | {
|
---|
285 | crWarning( "wglCopyContext: unsupported" );
|
---|
286 | return 0;
|
---|
287 | }
|
---|
288 |
|
---|
289 | HGLRC WINAPI wglCreateLayerContext_prox( HDC hdc, int layerPlane )
|
---|
290 | {
|
---|
291 | stubInit();
|
---|
292 | crWarning( "wglCreateLayerContext: unsupported" );
|
---|
293 | return 0;
|
---|
294 | }
|
---|
295 |
|
---|
296 | PROC WINAPI wglGetProcAddress_prox( LPCSTR name )
|
---|
297 | {
|
---|
298 | return (PROC) crGetProcAddress( name );
|
---|
299 | }
|
---|
300 |
|
---|
301 | BOOL WINAPI wglUseFontBitmapsA_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase )
|
---|
302 | {
|
---|
303 | crWarning( "wglUseFontBitmapsA: unsupported" );
|
---|
304 | return 0;
|
---|
305 | }
|
---|
306 |
|
---|
307 | BOOL WINAPI wglUseFontBitmapsW_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase )
|
---|
308 | {
|
---|
309 | crWarning( "wglUseFontBitmapsW: unsupported" );
|
---|
310 | return 0;
|
---|
311 | }
|
---|
312 |
|
---|
313 | BOOL WINAPI wglDescribeLayerPlane_prox( HDC hdc, int pixelFormat, int layerPlane,
|
---|
314 | UINT nBytes, LPLAYERPLANEDESCRIPTOR lpd )
|
---|
315 | {
|
---|
316 | crWarning( "wglDescribeLayerPlane: unimplemented" );
|
---|
317 | return 0;
|
---|
318 | }
|
---|
319 |
|
---|
320 | int WINAPI wglSetLayerPaletteEntries_prox( HDC hdc, int layerPlane, int start,
|
---|
321 | int entries, CONST COLORREF *cr )
|
---|
322 | {
|
---|
323 | crWarning( "wglSetLayerPaletteEntries: unsupported" );
|
---|
324 | return 0;
|
---|
325 | }
|
---|
326 |
|
---|
327 | int WINAPI wglGetLayerPaletteEntries_prox( HDC hdc, int layerPlane, int start,
|
---|
328 | int entries, COLORREF *cr )
|
---|
329 | {
|
---|
330 | crWarning( "wglGetLayerPaletteEntries: unsupported" );
|
---|
331 | return 0;
|
---|
332 | }
|
---|
333 |
|
---|
334 | BOOL WINAPI wglRealizeLayerPalette_prox( HDC hdc, int layerPlane, BOOL realize )
|
---|
335 | {
|
---|
336 | crWarning( "wglRealizeLayerPalette: unsupported" );
|
---|
337 | return 0;
|
---|
338 | }
|
---|
339 |
|
---|
340 | DWORD WINAPI wglSwapMultipleBuffers_prox( UINT a, CONST void *b )
|
---|
341 | {
|
---|
342 | crWarning( "wglSwapMultipleBuffer: unsupported" );
|
---|
343 | return 0;
|
---|
344 | }
|
---|
345 |
|
---|
346 | BOOL WINAPI wglUseFontOutlinesA_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase,
|
---|
347 | FLOAT deviation, FLOAT extrusion, int format,
|
---|
348 | LPGLYPHMETRICSFLOAT gmf )
|
---|
349 | {
|
---|
350 | crWarning( "wglUseFontOutlinesA: unsupported" );
|
---|
351 | return 0;
|
---|
352 | }
|
---|
353 |
|
---|
354 | BOOL WINAPI wglUseFontOutlinesW_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase,
|
---|
355 | FLOAT deviation, FLOAT extrusion, int format,
|
---|
356 | LPGLYPHMETRICSFLOAT gmf )
|
---|
357 | {
|
---|
358 | crWarning( "wglUseFontOutlinesW: unsupported" );
|
---|
359 | return 0;
|
---|
360 | }
|
---|
361 |
|
---|
362 | BOOL WINAPI wglSwapLayerBuffers_prox( HDC hdc, UINT planes )
|
---|
363 | {
|
---|
364 | crWarning( "wglSwapLayerBuffers: unsupported" );
|
---|
365 | return 0;
|
---|
366 | }
|
---|
367 |
|
---|
368 | BOOL WINAPI wglChoosePixelFormatEXT_prox
|
---|
369 | (HDC hdc, const int *piAttributes, const FLOAT *pfAttributes, UINT nMaxFormats, int *piFormats, UINT *nNumFormats)
|
---|
370 | {
|
---|
371 | int *pi;
|
---|
372 | int wants_rgb = 0;
|
---|
373 |
|
---|
374 | stubInit();
|
---|
375 |
|
---|
376 | /* TODO : Need to check pfAttributes too ! */
|
---|
377 |
|
---|
378 | for ( pi = (int *)piAttributes; *pi != 0; pi++ )
|
---|
379 | {
|
---|
380 | switch ( *pi )
|
---|
381 | {
|
---|
382 | case WGL_COLOR_BITS_EXT:
|
---|
383 | if (pi[1] > 8)
|
---|
384 | wants_rgb = 1;
|
---|
385 | pi++;
|
---|
386 | break;
|
---|
387 |
|
---|
388 | case WGL_RED_BITS_EXT:
|
---|
389 | case WGL_GREEN_BITS_EXT:
|
---|
390 | case WGL_BLUE_BITS_EXT:
|
---|
391 | if (pi[1] > 3)
|
---|
392 | wants_rgb = 1;
|
---|
393 | pi++;
|
---|
394 | break;
|
---|
395 |
|
---|
396 | case WGL_ACCUM_ALPHA_BITS_EXT:
|
---|
397 | case WGL_ALPHA_BITS_EXT:
|
---|
398 | if (pi[1] > 0)
|
---|
399 | desiredVisual |= CR_ALPHA_BIT;
|
---|
400 | pi++;
|
---|
401 | break;
|
---|
402 |
|
---|
403 | case WGL_DOUBLE_BUFFER_EXT:
|
---|
404 | if (pi[1] > 0)
|
---|
405 | desiredVisual |= CR_DOUBLE_BIT;
|
---|
406 | pi++;
|
---|
407 | break;
|
---|
408 |
|
---|
409 | case WGL_STEREO_EXT:
|
---|
410 | if (pi[1] > 0)
|
---|
411 | desiredVisual |= CR_STEREO_BIT;
|
---|
412 | pi++;
|
---|
413 | break;
|
---|
414 |
|
---|
415 | case WGL_DEPTH_BITS_EXT:
|
---|
416 | if (pi[1] > 0)
|
---|
417 | desiredVisual |= CR_DEPTH_BIT;
|
---|
418 | pi++;
|
---|
419 | break;
|
---|
420 |
|
---|
421 | case WGL_STENCIL_BITS_EXT:
|
---|
422 | if (pi[1] > 0)
|
---|
423 | desiredVisual |= CR_STENCIL_BIT;
|
---|
424 | pi++;
|
---|
425 | break;
|
---|
426 |
|
---|
427 | case WGL_ACCUM_RED_BITS_EXT:
|
---|
428 | case WGL_ACCUM_GREEN_BITS_EXT:
|
---|
429 | case WGL_ACCUM_BLUE_BITS_EXT:
|
---|
430 | if (pi[1] > 0)
|
---|
431 | desiredVisual |= CR_ACCUM_BIT;
|
---|
432 | pi++;
|
---|
433 | break;
|
---|
434 |
|
---|
435 | case WGL_SAMPLE_BUFFERS_EXT:
|
---|
436 | case WGL_SAMPLES_EXT:
|
---|
437 | if (pi[1] > 0)
|
---|
438 | desiredVisual |= CR_MULTISAMPLE_BIT;
|
---|
439 | pi++;
|
---|
440 | break;
|
---|
441 |
|
---|
442 | case WGL_SUPPORT_OPENGL_ARB:
|
---|
443 | case WGL_DRAW_TO_WINDOW_ARB:
|
---|
444 | case WGL_ACCELERATION_ARB:
|
---|
445 | pi++;
|
---|
446 | break;
|
---|
447 |
|
---|
448 | case WGL_PIXEL_TYPE_ARB:
|
---|
449 | if(pi[1]!=WGL_TYPE_RGBA_ARB)
|
---|
450 | {
|
---|
451 | crWarning("WGL_PIXEL_TYPE 0x%x not supported!", pi[1]);
|
---|
452 | return 0;
|
---|
453 | }
|
---|
454 | pi++;
|
---|
455 | break;
|
---|
456 |
|
---|
457 | default:
|
---|
458 | crWarning( "wglChoosePixelFormatEXT: bad pi=0x%x", *pi );
|
---|
459 | return 0;
|
---|
460 | }
|
---|
461 | }
|
---|
462 |
|
---|
463 | if (nNumFormats) *nNumFormats = 1;
|
---|
464 | if (nMaxFormats>0 && piFormats)
|
---|
465 | {
|
---|
466 | piFormats[0] = 1;
|
---|
467 | }
|
---|
468 |
|
---|
469 | return 1;
|
---|
470 | }
|
---|
471 |
|
---|
472 | BOOL WINAPI wglGetPixelFormatAttribivEXT_prox
|
---|
473 | (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *pValues)
|
---|
474 | {
|
---|
475 | UINT i;
|
---|
476 |
|
---|
477 | if (!pValues || !piAttributes) return 0;
|
---|
478 |
|
---|
479 | if ((nAttributes!=1) || (piAttributes && piAttributes[0]!=WGL_NUMBER_PIXEL_FORMATS_ARB))
|
---|
480 | {
|
---|
481 | if (iPixelFormat!=1)
|
---|
482 | {
|
---|
483 | crDebug("wglGetPixelFormatAttribivARB: bad pf:%i", iPixelFormat);
|
---|
484 | return 0;
|
---|
485 | }
|
---|
486 | }
|
---|
487 |
|
---|
488 | for (i=0; i<nAttributes; ++i)
|
---|
489 | {
|
---|
490 | switch (piAttributes[i])
|
---|
491 | {
|
---|
492 | case WGL_NUMBER_PIXEL_FORMATS_ARB:
|
---|
493 | pValues[i] = 1;
|
---|
494 | break;
|
---|
495 | case WGL_DRAW_TO_WINDOW_ARB:
|
---|
496 | case WGL_SUPPORT_OPENGL_ARB:
|
---|
497 | case WGL_DOUBLE_BUFFER_ARB:
|
---|
498 | case WGL_STEREO_ARB:
|
---|
499 | pValues[i] = 1;
|
---|
500 | break;
|
---|
501 | case WGL_DRAW_TO_BITMAP_ARB:
|
---|
502 | case WGL_NEED_PALETTE_ARB:
|
---|
503 | case WGL_NEED_SYSTEM_PALETTE_ARB:
|
---|
504 | case WGL_SWAP_LAYER_BUFFERS_ARB:
|
---|
505 | case WGL_NUMBER_OVERLAYS_ARB:
|
---|
506 | case WGL_NUMBER_UNDERLAYS_ARB:
|
---|
507 | case WGL_TRANSPARENT_ARB:
|
---|
508 | case WGL_TRANSPARENT_RED_VALUE_ARB:
|
---|
509 | case WGL_TRANSPARENT_GREEN_VALUE_ARB:
|
---|
510 | case WGL_TRANSPARENT_BLUE_VALUE_ARB:
|
---|
511 | case WGL_TRANSPARENT_ALPHA_VALUE_ARB:
|
---|
512 | case WGL_TRANSPARENT_INDEX_VALUE_ARB:
|
---|
513 | case WGL_SHARE_DEPTH_ARB:
|
---|
514 | case WGL_SHARE_STENCIL_ARB:
|
---|
515 | case WGL_SHARE_ACCUM_ARB:
|
---|
516 | case WGL_SUPPORT_GDI_ARB:
|
---|
517 | pValues[i] = 0;
|
---|
518 | break;
|
---|
519 | case WGL_ACCELERATION_ARB:
|
---|
520 | pValues[i] = WGL_FULL_ACCELERATION_ARB;
|
---|
521 | break;
|
---|
522 | case WGL_SWAP_METHOD_ARB:
|
---|
523 | pValues[i] = WGL_SWAP_UNDEFINED_ARB;
|
---|
524 | break;
|
---|
525 | case WGL_PIXEL_TYPE_ARB:
|
---|
526 | pValues[i] = WGL_TYPE_RGBA_ARB;
|
---|
527 | break;
|
---|
528 | case WGL_COLOR_BITS_ARB:
|
---|
529 | pValues[i] = 32;
|
---|
530 | break;
|
---|
531 | case WGL_RED_BITS_ARB:
|
---|
532 | case WGL_GREEN_BITS_ARB:
|
---|
533 | case WGL_BLUE_BITS_ARB:
|
---|
534 | case WGL_ALPHA_BITS_ARB:
|
---|
535 | pValues[i] = 8;
|
---|
536 | break;
|
---|
537 | case WGL_RED_SHIFT_ARB:
|
---|
538 | pValues[i] = 24;
|
---|
539 | break;
|
---|
540 | case WGL_GREEN_SHIFT_ARB:
|
---|
541 | pValues[i] = 16;
|
---|
542 | break;
|
---|
543 | case WGL_BLUE_SHIFT_ARB:
|
---|
544 | pValues[i] = 8;
|
---|
545 | break;
|
---|
546 | case WGL_ALPHA_SHIFT_ARB:
|
---|
547 | pValues[i] = 0;
|
---|
548 | break;
|
---|
549 | case WGL_ACCUM_BITS_ARB:
|
---|
550 | pValues[i] = 0;
|
---|
551 | break;
|
---|
552 | case WGL_ACCUM_RED_BITS_ARB:
|
---|
553 | pValues[i] = 0;
|
---|
554 | break;
|
---|
555 | case WGL_ACCUM_GREEN_BITS_ARB:
|
---|
556 | pValues[i] = 0;
|
---|
557 | break;
|
---|
558 | case WGL_ACCUM_BLUE_BITS_ARB:
|
---|
559 | pValues[i] = 0;
|
---|
560 | break;
|
---|
561 | case WGL_ACCUM_ALPHA_BITS_ARB:
|
---|
562 | pValues[i] = 0;
|
---|
563 | break;
|
---|
564 | case WGL_DEPTH_BITS_ARB:
|
---|
565 | pValues[i] = 32;
|
---|
566 | break;
|
---|
567 | case WGL_STENCIL_BITS_ARB:
|
---|
568 | pValues[i] = 8;
|
---|
569 | break;
|
---|
570 | case WGL_AUX_BUFFERS_ARB:
|
---|
571 | pValues[i] = 0;
|
---|
572 | break;
|
---|
573 | case WGL_SAMPLE_BUFFERS_EXT:
|
---|
574 | pValues[i] = 1;
|
---|
575 | break;
|
---|
576 | case WGL_SAMPLES_EXT:
|
---|
577 | pValues[i] = 1;
|
---|
578 | break;
|
---|
579 | default:
|
---|
580 | crWarning("wglGetPixelFormatAttribivARB: bad attrib=0x%x", piAttributes[i]);
|
---|
581 | return 0;
|
---|
582 | }
|
---|
583 | }
|
---|
584 |
|
---|
585 | return 1;
|
---|
586 | }
|
---|
587 |
|
---|
588 | BOOL WINAPI wglGetPixelFormatAttribfvEXT_prox
|
---|
589 | (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, float *pValues)
|
---|
590 | {
|
---|
591 | UINT i;
|
---|
592 |
|
---|
593 | if (!pValues || !piAttributes) return 0;
|
---|
594 |
|
---|
595 | if ((nAttributes!=1) || (piAttributes && piAttributes[0]!=WGL_NUMBER_PIXEL_FORMATS_ARB))
|
---|
596 | {
|
---|
597 | if (iPixelFormat!=1)
|
---|
598 | {
|
---|
599 | crDebug("wglGetPixelFormatAttribivARB: bad pf:%i", iPixelFormat);
|
---|
600 | return 0;
|
---|
601 | }
|
---|
602 | }
|
---|
603 |
|
---|
604 | for (i=0; i<nAttributes; ++i)
|
---|
605 | {
|
---|
606 | switch (piAttributes[i])
|
---|
607 | {
|
---|
608 | case WGL_NUMBER_PIXEL_FORMATS_ARB:
|
---|
609 | pValues[i] = 1.f;
|
---|
610 | break;
|
---|
611 | case WGL_DRAW_TO_WINDOW_ARB:
|
---|
612 | case WGL_SUPPORT_OPENGL_ARB:
|
---|
613 | case WGL_DOUBLE_BUFFER_ARB:
|
---|
614 | case WGL_STEREO_ARB:
|
---|
615 | pValues[i] = 1.f;
|
---|
616 | break;
|
---|
617 | case WGL_DRAW_TO_BITMAP_ARB:
|
---|
618 | case WGL_NEED_PALETTE_ARB:
|
---|
619 | case WGL_NEED_SYSTEM_PALETTE_ARB:
|
---|
620 | case WGL_SWAP_LAYER_BUFFERS_ARB:
|
---|
621 | case WGL_NUMBER_OVERLAYS_ARB:
|
---|
622 | case WGL_NUMBER_UNDERLAYS_ARB:
|
---|
623 | case WGL_TRANSPARENT_ARB:
|
---|
624 | case WGL_TRANSPARENT_RED_VALUE_ARB:
|
---|
625 | case WGL_TRANSPARENT_GREEN_VALUE_ARB:
|
---|
626 | case WGL_TRANSPARENT_BLUE_VALUE_ARB:
|
---|
627 | case WGL_TRANSPARENT_ALPHA_VALUE_ARB:
|
---|
628 | case WGL_TRANSPARENT_INDEX_VALUE_ARB:
|
---|
629 | case WGL_SHARE_DEPTH_ARB:
|
---|
630 | case WGL_SHARE_STENCIL_ARB:
|
---|
631 | case WGL_SHARE_ACCUM_ARB:
|
---|
632 | case WGL_SUPPORT_GDI_ARB:
|
---|
633 | pValues[i] = 0.f;
|
---|
634 | break;
|
---|
635 | case WGL_ACCELERATION_ARB:
|
---|
636 | pValues[i] = WGL_FULL_ACCELERATION_ARB;
|
---|
637 | break;
|
---|
638 | case WGL_SWAP_METHOD_ARB:
|
---|
639 | pValues[i] = WGL_SWAP_UNDEFINED_ARB;
|
---|
640 | break;
|
---|
641 | case WGL_PIXEL_TYPE_ARB:
|
---|
642 | pValues[i] = WGL_TYPE_RGBA_ARB;
|
---|
643 | break;
|
---|
644 | case WGL_COLOR_BITS_ARB:
|
---|
645 | pValues[i] = 32.f;
|
---|
646 | break;
|
---|
647 | case WGL_RED_BITS_ARB:
|
---|
648 | case WGL_GREEN_BITS_ARB:
|
---|
649 | case WGL_BLUE_BITS_ARB:
|
---|
650 | case WGL_ALPHA_BITS_ARB:
|
---|
651 | pValues[i] = 8.f;
|
---|
652 | break;
|
---|
653 | case WGL_RED_SHIFT_ARB:
|
---|
654 | pValues[i] = 24.f;
|
---|
655 | break;
|
---|
656 | case WGL_GREEN_SHIFT_ARB:
|
---|
657 | pValues[i] = 16.f;
|
---|
658 | break;
|
---|
659 | case WGL_BLUE_SHIFT_ARB:
|
---|
660 | pValues[i] = 8.f;
|
---|
661 | break;
|
---|
662 | case WGL_ALPHA_SHIFT_ARB:
|
---|
663 | pValues[i] = 0.f;
|
---|
664 | break;
|
---|
665 | case WGL_ACCUM_BITS_ARB:
|
---|
666 | pValues[i] = 0.f;
|
---|
667 | break;
|
---|
668 | case WGL_ACCUM_RED_BITS_ARB:
|
---|
669 | pValues[i] = 0.f;
|
---|
670 | break;
|
---|
671 | case WGL_ACCUM_GREEN_BITS_ARB:
|
---|
672 | pValues[i] = 0.f;
|
---|
673 | break;
|
---|
674 | case WGL_ACCUM_BLUE_BITS_ARB:
|
---|
675 | pValues[i] = 0.f;
|
---|
676 | break;
|
---|
677 | case WGL_ACCUM_ALPHA_BITS_ARB:
|
---|
678 | pValues[i] = 0.f;
|
---|
679 | break;
|
---|
680 | case WGL_DEPTH_BITS_ARB:
|
---|
681 | pValues[i] = 32.f;
|
---|
682 | break;
|
---|
683 | case WGL_STENCIL_BITS_ARB:
|
---|
684 | pValues[i] = 8.f;
|
---|
685 | break;
|
---|
686 | case WGL_AUX_BUFFERS_ARB:
|
---|
687 | pValues[i] = 0.f;
|
---|
688 | break;
|
---|
689 | case WGL_SAMPLE_BUFFERS_EXT:
|
---|
690 | pValues[i] = 1.f;
|
---|
691 | break;
|
---|
692 | case WGL_SAMPLES_EXT:
|
---|
693 | pValues[i] = 1.f;
|
---|
694 | break;
|
---|
695 | default:
|
---|
696 | crWarning("wglGetPixelFormatAttribivARB: bad attrib=0x%x", piAttributes[i]);
|
---|
697 | return 0;
|
---|
698 | }
|
---|
699 | }
|
---|
700 |
|
---|
701 | return 1;
|
---|
702 | }
|
---|
703 |
|
---|
704 | BOOL WINAPI wglSwapIntervalEXT_prox(int interval)
|
---|
705 | {
|
---|
706 | return TRUE;
|
---|
707 | }
|
---|
708 |
|
---|
709 | int WINAPI wglGetSwapIntervalEXT_prox()
|
---|
710 | {
|
---|
711 | return 1;
|
---|
712 | }
|
---|
713 |
|
---|
714 | static GLubyte *gsz_wgl_extensions = "WGL_EXT_pixel_format WGL_ARB_pixel_format WGL_ARB_multisample";
|
---|
715 |
|
---|
716 | const GLubyte * WINAPI wglGetExtensionsStringEXT_prox()
|
---|
717 | {
|
---|
718 | return gsz_wgl_extensions;
|
---|
719 | }
|
---|
720 |
|
---|
721 | const GLubyte * WINAPI wglGetExtensionsStringARB_prox(HDC hdc)
|
---|
722 | {
|
---|
723 | (void) hdc;
|
---|
724 |
|
---|
725 | return gsz_wgl_extensions;
|
---|
726 | }
|
---|