VirtualBox

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

Last change on this file since 45540 was 45484, checked in by vboxsync, 12 years ago

crOpenGL: correct VBoxOGL exports defs

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