VirtualBox

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

最後變更 在這個檔案從64530是 55622,由 vboxsync 提交於 10 年 前

3D: Windows GAs: drop relatively big buffer allocation on stack.

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

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