VirtualBox

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

Last change on this file since 47631 was 46966, checked in by vboxsync, 12 years ago

wddm/crOpenGL: some bugfixes, more TexPresent fixes

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

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