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