VirtualBox

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

最後變更 在這個檔案從40734是 40267,由 vboxsync 提交於 13 年 前

crOpenGL: fixe VSG Open Inventor interop issues

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

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