VirtualBox

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

最後變更 在這個檔案從49891是 48999,由 vboxsync 提交於 11 年 前

wddm: ensure all windows are initially hidden

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

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