VirtualBox

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

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

crOpenGL: wglShareLists support

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

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