VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/wgl.c@ 42261

Last change on this file since 42261 was 41971, checked in by vboxsync, 13 years ago

crOpenGL: report visual bits superset to avoid host context recreation misbehave

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 25.2 KB
Line 
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
29static GLuint desiredVisual = CR_RGB_BIT | CR_ALPHA_BIT | CR_DEPTH_BIT | CR_STENCIL_BIT | CR_ACCUM_BIT | CR_DOUBLE_BIT;
30#else
31static 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 */
39static 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
68int 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
165BOOL 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
177BOOL WINAPI wglDeleteContext_prox( HGLRC hglrc )
178{
179 CR_DDI_PROLOGUE();
180 stubDestroyContext( (unsigned long) hglrc );
181 return 1;
182}
183
184BOOL 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
211HGLRC WINAPI wglGetCurrentContext_prox( void )
212{
213 ContextInfo *context = stubGetCurrentContext();
214 CR_DDI_PROLOGUE();
215 return (HGLRC) (context ? context->id : 0);
216}
217
218HDC 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
228int 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
235int 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
289BOOL WINAPI wglShareLists_prox( HGLRC hglrc1, HGLRC hglrc2 )
290{
291 CR_DDI_PROLOGUE();
292 crWarning( "wglShareLists: unsupported" );
293 return 0;
294}
295
296
297HGLRC WINAPI wglCreateContext_prox( HDC hdc )
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 (!context)
316 return 0;
317
318 return (HGLRC) context->id;
319}
320
321BOOL WINAPI
322wglSwapBuffers_prox( HDC hdc )
323{
324 WindowInfo *window = stubGetWindowInfo(hdc);
325 CR_DDI_PROLOGUE();
326 stubSwapBuffers( window, 0 );
327 return 1;
328}
329
330BOOL WINAPI wglCopyContext_prox( HGLRC src, HGLRC dst, UINT mask )
331{
332 CR_DDI_PROLOGUE();
333 crWarning( "wglCopyContext: unsupported" );
334 return 0;
335}
336
337HGLRC WINAPI wglCreateLayerContext_prox( HDC hdc, int layerPlane )
338{
339 CR_DDI_PROLOGUE();
340 stubInit();
341 crWarning( "wglCreateLayerContext: unsupported" );
342 return 0;
343}
344
345PROC WINAPI wglGetProcAddress_prox( LPCSTR name )
346{
347 CR_DDI_PROLOGUE();
348 return (PROC) crGetProcAddress( name );
349}
350
351BOOL WINAPI wglUseFontBitmapsA_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase )
352{
353 CR_DDI_PROLOGUE();
354 crWarning( "wglUseFontBitmapsA: unsupported" );
355 return 0;
356}
357
358BOOL WINAPI wglUseFontBitmapsW_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase )
359{
360 CR_DDI_PROLOGUE();
361 crWarning( "wglUseFontBitmapsW: unsupported" );
362 return 0;
363}
364
365BOOL WINAPI wglDescribeLayerPlane_prox( HDC hdc, int pixelFormat, int layerPlane,
366 UINT nBytes, LPLAYERPLANEDESCRIPTOR lpd )
367{
368 CR_DDI_PROLOGUE();
369 crWarning( "wglDescribeLayerPlane: unimplemented" );
370 return 0;
371}
372
373int WINAPI wglSetLayerPaletteEntries_prox( HDC hdc, int layerPlane, int start,
374 int entries, CONST COLORREF *cr )
375{
376 CR_DDI_PROLOGUE();
377 crWarning( "wglSetLayerPaletteEntries: unsupported" );
378 return 0;
379}
380
381int WINAPI wglGetLayerPaletteEntries_prox( HDC hdc, int layerPlane, int start,
382 int entries, COLORREF *cr )
383{
384 CR_DDI_PROLOGUE();
385 crWarning( "wglGetLayerPaletteEntries: unsupported" );
386 return 0;
387}
388
389BOOL WINAPI wglRealizeLayerPalette_prox( HDC hdc, int layerPlane, BOOL realize )
390{
391 CR_DDI_PROLOGUE();
392 crWarning( "wglRealizeLayerPalette: unsupported" );
393 return 0;
394}
395
396DWORD WINAPI wglSwapMultipleBuffers_prox( UINT a, CONST void *b )
397{
398 CR_DDI_PROLOGUE();
399 crWarning( "wglSwapMultipleBuffer: unsupported" );
400 return 0;
401}
402
403BOOL WINAPI wglUseFontOutlinesA_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase,
404 FLOAT deviation, FLOAT extrusion, int format,
405 LPGLYPHMETRICSFLOAT gmf )
406{
407 CR_DDI_PROLOGUE();
408 crWarning( "wglUseFontOutlinesA: unsupported" );
409 return 0;
410}
411
412BOOL WINAPI wglUseFontOutlinesW_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase,
413 FLOAT deviation, FLOAT extrusion, int format,
414 LPGLYPHMETRICSFLOAT gmf )
415{
416 CR_DDI_PROLOGUE();
417 crWarning( "wglUseFontOutlinesW: unsupported" );
418 return 0;
419}
420
421BOOL WINAPI wglSwapLayerBuffers_prox( HDC hdc, UINT planes )
422{
423 CR_DDI_PROLOGUE();
424 if (planes == WGL_SWAP_MAIN_PLANE)
425 {
426 return wglSwapBuffers_prox(hdc);
427 }
428 else
429 {
430 crWarning( "wglSwapLayerBuffers: unsupported" );
431 return 0;
432 }
433}
434
435BOOL WINAPI wglChoosePixelFormatEXT_prox
436(HDC hdc, const int *piAttributes, const FLOAT *pfAttributes, UINT nMaxFormats, int *piFormats, UINT *nNumFormats)
437{
438 int *pi;
439 int wants_rgb = 0;
440
441 CR_DDI_PROLOGUE();
442
443 stubInit();
444
445 /* TODO : Need to check pfAttributes too ! */
446
447 for ( pi = (int *)piAttributes; *pi != 0; pi++ )
448 {
449 switch ( *pi )
450 {
451 case WGL_COLOR_BITS_EXT:
452 if (pi[1] > 8)
453 wants_rgb = 1;
454 pi++;
455 break;
456
457 case WGL_RED_BITS_EXT:
458 case WGL_GREEN_BITS_EXT:
459 case WGL_BLUE_BITS_EXT:
460 if (pi[1] > 3)
461 wants_rgb = 1;
462 pi++;
463 break;
464
465 case WGL_ACCUM_ALPHA_BITS_EXT:
466 case WGL_ALPHA_BITS_EXT:
467 if (pi[1] > 0)
468 desiredVisual |= CR_ALPHA_BIT;
469 pi++;
470 break;
471
472 case WGL_DOUBLE_BUFFER_EXT:
473 if (pi[1] > 0)
474 desiredVisual |= CR_DOUBLE_BIT;
475 pi++;
476 break;
477
478 case WGL_STEREO_EXT:
479 if (pi[1] > 0)
480 {
481 /* @todo: this is disabled due to VSG Open Inventor interop issues
482 * it does not make any sense actually since reporting this
483 * as well as choosing a pixel format with this cap would not do anything
484 * since ICD stuff has its own pixelformat state var */
485 crWarning("WGL_STEREO_EXT not supporteed!");
486 return 0;
487// desiredVisual |= CR_STEREO_BIT;
488 }
489 pi++;
490 break;
491
492 case WGL_DEPTH_BITS_EXT:
493 if (pi[1] > 0)
494 desiredVisual |= CR_DEPTH_BIT;
495 pi++;
496 break;
497
498 case WGL_STENCIL_BITS_EXT:
499 if (pi[1] > 0)
500 desiredVisual |= CR_STENCIL_BIT;
501 pi++;
502 break;
503
504 case WGL_ACCUM_RED_BITS_EXT:
505 case WGL_ACCUM_GREEN_BITS_EXT:
506 case WGL_ACCUM_BLUE_BITS_EXT:
507 if (pi[1] > 0)
508 desiredVisual |= CR_ACCUM_BIT;
509 pi++;
510 break;
511
512 case WGL_SAMPLE_BUFFERS_EXT:
513 case WGL_SAMPLES_EXT:
514 if (pi[1] > 0)
515 {
516 /* @todo: this is disabled due to VSG Open Inventor interop issues
517 * it does not make any sense actually since reporting this
518 * as well as choosing a pixel format with this cap would not do anything
519 * since ICD stuff has its own pixelformat state var */
520 crWarning("WGL_SAMPLE_BUFFERS_EXT & WGL_SAMPLES_EXT not supporteed!");
521 return 0;
522// desiredVisual |= CR_MULTISAMPLE_BIT;
523 }
524 pi++;
525 break;
526
527 case WGL_SUPPORT_OPENGL_ARB:
528 case WGL_DRAW_TO_WINDOW_ARB:
529 case WGL_ACCELERATION_ARB:
530 pi++;
531 break;
532
533 case WGL_PIXEL_TYPE_ARB:
534 if(pi[1]!=WGL_TYPE_RGBA_ARB)
535 {
536 crWarning("WGL_PIXEL_TYPE 0x%x not supported!", pi[1]);
537 return 0;
538 }
539 pi++;
540 break;
541
542 default:
543 crWarning( "wglChoosePixelFormatEXT: bad pi=0x%x", *pi );
544 return 0;
545 }
546 }
547
548 if (nNumFormats) *nNumFormats = 1;
549 if (nMaxFormats>0 && piFormats)
550 {
551 piFormats[0] = 1;
552 }
553
554 return 1;
555}
556
557BOOL WINAPI wglGetPixelFormatAttribivEXT_prox
558(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *pValues)
559{
560 UINT i;
561
562 CR_DDI_PROLOGUE();
563
564 if (!pValues || !piAttributes) return 0;
565
566 if ((nAttributes!=1) || (piAttributes && piAttributes[0]!=WGL_NUMBER_PIXEL_FORMATS_ARB))
567 {
568 if (iPixelFormat!=1)
569 {
570 crDebug("wglGetPixelFormatAttribivARB: bad pf:%i", iPixelFormat);
571 return 0;
572 }
573 }
574
575 for (i=0; i<nAttributes; ++i)
576 {
577 switch (piAttributes[i])
578 {
579 case WGL_NUMBER_PIXEL_FORMATS_ARB:
580 pValues[i] = 1;
581 break;
582 case WGL_DRAW_TO_WINDOW_ARB:
583 case WGL_SUPPORT_OPENGL_ARB:
584 case WGL_DOUBLE_BUFFER_ARB:
585 pValues[i] = 1;
586 break;
587 case WGL_STEREO_ARB:
588 /* @todo: this is disabled due to VSG Open Inventor interop issues
589 * it does not make any sense actually since reporting this
590 * as well as choosing a pixel format with this cap would not do anything
591 * since ICD stuff has its own pixelformat state var */
592 pValues[i] = 0;
593 break;
594 case WGL_DRAW_TO_BITMAP_ARB:
595 case WGL_NEED_PALETTE_ARB:
596 case WGL_NEED_SYSTEM_PALETTE_ARB:
597 case WGL_SWAP_LAYER_BUFFERS_ARB:
598 case WGL_NUMBER_OVERLAYS_ARB:
599 case WGL_NUMBER_UNDERLAYS_ARB:
600 case WGL_TRANSPARENT_ARB:
601 case WGL_TRANSPARENT_RED_VALUE_ARB:
602 case WGL_TRANSPARENT_GREEN_VALUE_ARB:
603 case WGL_TRANSPARENT_BLUE_VALUE_ARB:
604 case WGL_TRANSPARENT_ALPHA_VALUE_ARB:
605 case WGL_TRANSPARENT_INDEX_VALUE_ARB:
606 case WGL_SHARE_DEPTH_ARB:
607 case WGL_SHARE_STENCIL_ARB:
608 case WGL_SHARE_ACCUM_ARB:
609 case WGL_SUPPORT_GDI_ARB:
610 pValues[i] = 0;
611 break;
612 case WGL_ACCELERATION_ARB:
613 pValues[i] = WGL_FULL_ACCELERATION_ARB;
614 break;
615 case WGL_SWAP_METHOD_ARB:
616 pValues[i] = WGL_SWAP_UNDEFINED_ARB;
617 break;
618 case WGL_PIXEL_TYPE_ARB:
619 pValues[i] = WGL_TYPE_RGBA_ARB;
620 break;
621 case WGL_COLOR_BITS_ARB:
622 pValues[i] = 32;
623 break;
624 case WGL_RED_BITS_ARB:
625 case WGL_GREEN_BITS_ARB:
626 case WGL_BLUE_BITS_ARB:
627 case WGL_ALPHA_BITS_ARB:
628 pValues[i] = 8;
629 break;
630 case WGL_RED_SHIFT_ARB:
631 pValues[i] = 24;
632 break;
633 case WGL_GREEN_SHIFT_ARB:
634 pValues[i] = 16;
635 break;
636 case WGL_BLUE_SHIFT_ARB:
637 pValues[i] = 8;
638 break;
639 case WGL_ALPHA_SHIFT_ARB:
640 pValues[i] = 0;
641 break;
642 case WGL_ACCUM_BITS_ARB:
643 pValues[i] = 0;
644 break;
645 case WGL_ACCUM_RED_BITS_ARB:
646 pValues[i] = 0;
647 break;
648 case WGL_ACCUM_GREEN_BITS_ARB:
649 pValues[i] = 0;
650 break;
651 case WGL_ACCUM_BLUE_BITS_ARB:
652 pValues[i] = 0;
653 break;
654 case WGL_ACCUM_ALPHA_BITS_ARB:
655 pValues[i] = 0;
656 break;
657 case WGL_DEPTH_BITS_ARB:
658 pValues[i] = 32;
659 break;
660 case WGL_STENCIL_BITS_ARB:
661 pValues[i] = 8;
662 break;
663 case WGL_AUX_BUFFERS_ARB:
664 pValues[i] = 0;
665 break;
666 case WGL_SAMPLE_BUFFERS_EXT:
667 /* @todo: this is disabled due to VSG Open Inventor interop issues
668 * it does not make any sense actually since reporting this
669 * as well as choosing a pixel format with this cap would not do anything
670 * since ICD stuff has its own pixelformat state var */
671 pValues[i] = 0;
672 break;
673 case WGL_SAMPLES_EXT:
674 /* @todo: this is disabled due to VSG Open Inventor interop issues
675 * it does not make any sense actually since reporting this
676 * as well as choosing a pixel format with this cap would not do anything
677 * since ICD stuff has its own pixelformat state var */
678 pValues[i] = 0;
679 break;
680 case 0x202d: /* <- WGL_DRAW_TO_PBUFFER_ARB this is to make VSG Open Inventor happy */
681 pValues[i] = 0;
682 break;
683 default:
684 crWarning("wglGetPixelFormatAttribivARB: bad attrib=0x%x", piAttributes[i]);
685 return 0;
686 }
687 }
688
689 return 1;
690}
691
692BOOL WINAPI wglGetPixelFormatAttribfvEXT_prox
693(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, float *pValues)
694{
695 UINT i;
696
697 CR_DDI_PROLOGUE();
698
699 if (!pValues || !piAttributes) return 0;
700
701 if ((nAttributes!=1) || (piAttributes && piAttributes[0]!=WGL_NUMBER_PIXEL_FORMATS_ARB))
702 {
703 if (iPixelFormat!=1)
704 {
705 crDebug("wglGetPixelFormatAttribivARB: bad pf:%i", iPixelFormat);
706 return 0;
707 }
708 }
709
710 for (i=0; i<nAttributes; ++i)
711 {
712 switch (piAttributes[i])
713 {
714 case WGL_NUMBER_PIXEL_FORMATS_ARB:
715 pValues[i] = 1.f;
716 break;
717 case WGL_DRAW_TO_WINDOW_ARB:
718 case WGL_SUPPORT_OPENGL_ARB:
719 case WGL_DOUBLE_BUFFER_ARB:
720 pValues[i] = 1.f;
721 break;
722 case WGL_STEREO_ARB:
723 /* @todo: this is disabled due to VSG Open Inventor interop issues
724 * it does not make any sense actually since reporting this
725 * as well as choosing a pixel format with this cap would not do anything
726 * since ICD stuff has its own pixelformat state var */
727 pValues[i] = 0.f;
728 break;
729 case WGL_DRAW_TO_BITMAP_ARB:
730 case WGL_NEED_PALETTE_ARB:
731 case WGL_NEED_SYSTEM_PALETTE_ARB:
732 case WGL_SWAP_LAYER_BUFFERS_ARB:
733 case WGL_NUMBER_OVERLAYS_ARB:
734 case WGL_NUMBER_UNDERLAYS_ARB:
735 case WGL_TRANSPARENT_ARB:
736 case WGL_TRANSPARENT_RED_VALUE_ARB:
737 case WGL_TRANSPARENT_GREEN_VALUE_ARB:
738 case WGL_TRANSPARENT_BLUE_VALUE_ARB:
739 case WGL_TRANSPARENT_ALPHA_VALUE_ARB:
740 case WGL_TRANSPARENT_INDEX_VALUE_ARB:
741 case WGL_SHARE_DEPTH_ARB:
742 case WGL_SHARE_STENCIL_ARB:
743 case WGL_SHARE_ACCUM_ARB:
744 case WGL_SUPPORT_GDI_ARB:
745 pValues[i] = 0.f;
746 break;
747 case WGL_ACCELERATION_ARB:
748 pValues[i] = WGL_FULL_ACCELERATION_ARB;
749 break;
750 case WGL_SWAP_METHOD_ARB:
751 pValues[i] = WGL_SWAP_UNDEFINED_ARB;
752 break;
753 case WGL_PIXEL_TYPE_ARB:
754 pValues[i] = WGL_TYPE_RGBA_ARB;
755 break;
756 case WGL_COLOR_BITS_ARB:
757 pValues[i] = 32.f;
758 break;
759 case WGL_RED_BITS_ARB:
760 case WGL_GREEN_BITS_ARB:
761 case WGL_BLUE_BITS_ARB:
762 case WGL_ALPHA_BITS_ARB:
763 pValues[i] = 8.f;
764 break;
765 case WGL_RED_SHIFT_ARB:
766 pValues[i] = 24.f;
767 break;
768 case WGL_GREEN_SHIFT_ARB:
769 pValues[i] = 16.f;
770 break;
771 case WGL_BLUE_SHIFT_ARB:
772 pValues[i] = 8.f;
773 break;
774 case WGL_ALPHA_SHIFT_ARB:
775 pValues[i] = 0.f;
776 break;
777 case WGL_ACCUM_BITS_ARB:
778 pValues[i] = 0.f;
779 break;
780 case WGL_ACCUM_RED_BITS_ARB:
781 pValues[i] = 0.f;
782 break;
783 case WGL_ACCUM_GREEN_BITS_ARB:
784 pValues[i] = 0.f;
785 break;
786 case WGL_ACCUM_BLUE_BITS_ARB:
787 pValues[i] = 0.f;
788 break;
789 case WGL_ACCUM_ALPHA_BITS_ARB:
790 pValues[i] = 0.f;
791 break;
792 case WGL_DEPTH_BITS_ARB:
793 pValues[i] = 32.f;
794 break;
795 case WGL_STENCIL_BITS_ARB:
796 pValues[i] = 8.f;
797 break;
798 case WGL_AUX_BUFFERS_ARB:
799 pValues[i] = 0.f;
800 break;
801 case WGL_SAMPLE_BUFFERS_EXT:
802 /* @todo: this is disabled due to VSG Open Inventor interop issues
803 * it does not make any sense actually since reporting this
804 * as well as choosing a pixel format with this cap would not do anything
805 * since ICD stuff has its own pixelformat state var */
806 pValues[i] = 0.f;
807 break;
808 case WGL_SAMPLES_EXT:
809 /* @todo: this is disabled due to VSG Open Inventor interop issues
810 * it does not make any sense actually since reporting this
811 * as well as choosing a pixel format with this cap would not do anything
812 * since ICD stuff has its own pixelformat state var */
813 pValues[i] = 0.f;
814 break;
815 case 0x202d: /* <- WGL_DRAW_TO_PBUFFER_ARB this is to make VSG Open Inventor happy */
816 pValues[i] = 0.f;
817 break;
818 default:
819 crWarning("wglGetPixelFormatAttribivARB: bad attrib=0x%x", piAttributes[i]);
820 return 0;
821 }
822 }
823
824 return 1;
825}
826
827BOOL WINAPI wglSwapIntervalEXT_prox(int interval)
828{
829 CR_DDI_PROLOGUE();
830 return TRUE;
831}
832
833int WINAPI wglGetSwapIntervalEXT_prox()
834{
835 CR_DDI_PROLOGUE();
836 return 1;
837}
838
839static GLubyte *gsz_wgl_extensions = "WGL_EXT_pixel_format WGL_ARB_pixel_format WGL_ARB_multisample";
840
841const GLubyte * WINAPI wglGetExtensionsStringEXT_prox()
842{
843 CR_DDI_PROLOGUE();
844 return gsz_wgl_extensions;
845}
846
847const GLubyte * WINAPI wglGetExtensionsStringARB_prox(HDC hdc)
848{
849 CR_DDI_PROLOGUE();
850 (void) hdc;
851
852 return gsz_wgl_extensions;
853}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette