VirtualBox

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

Last change on this file since 43898 was 43487, checked in by vboxsync, 12 years ago

crOpenGL/wddm: basics for miniport-based visible rects processing (guest part); export flushToHost command

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