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