wgl.c revision 1ec5aa48c1d7f43bcb79105d7f578c71f68ebae7
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "cr_error.h"
#include "cr_spu.h"
#include "cr_environment.h"
#include "stub.h"
/* I *know* most of the parameters are unused, dammit. */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
/**
* Compute a mask of CR_*_BIT flags which reflects the attributes of
* the pixel format of the given hdc.
*/
{
int iPixelFormat;
GLuint b = 0;
if (pfd.cDepthBits > 0)
b |= CR_DEPTH_BIT;
if (pfd.cAccumBits > 0)
b |= CR_ACCUM_BIT;
b |= CR_RGB_BIT;
if (pfd.cStencilBits > 0)
b |= CR_STENCIL_BIT;
if (pfd.cAlphaBits > 0)
b |= CR_ALPHA_BIT;
b |= CR_DOUBLE_BIT;
b |= CR_STEREO_BIT;
return b;
}
{
stubInit();
/*
* NOTE!!!
* Here we're telling the renderspu not to use the GDI
* equivalent's of ChoosePixelFormat/DescribePixelFormat etc
* There are subtle differences in the use of these calls.
*/
crError( "wglChoosePixelFormat: bad pfd\n" );
return 0;
}
okayFlags = ( PFD_DRAW_TO_WINDOW |
crWarning( "wglChoosePixelFormat: only support flags=0x%x, but you gave me flags=0x%x", okayFlags, pfd->dwFlags );
return 0;
}
crError( "wglChoosePixelFormat: only support RGBA\n" );
}
crWarning( "wglChoosePixelFormat: too much color precision requested\n" );
}
if ( pfd->cAccumBits > 0 ||
pfd->cAccumRedBits > 0 ||
pfd->cAccumGreenBits > 0 ||
pfd->cAccumBlueBits > 0 ||
pfd->cAccumAlphaBits > 0 ) {
crWarning( "wglChoosePixelFormat: asked for accumulation buffer, ignoring\n" );
}
if ( pfd->cAccumBits > 0 )
crError( "wglChoosePixelFormat; asked for too many depth bits\n" );
}
if ( pfd->cDepthBits > 0 )
crError( "wglChoosePixelFormat: asked for too many stencil bits\n" );
}
if ( pfd->cStencilBits > 0 )
if ( pfd->cAuxBuffers > 0 ) {
crError( "wglChoosePixelFormat: asked for aux buffers\n" );
}
crError( "wglChoosePixelFormat: asked for a strange layer\n" );
}
return 1;
}
{
if ( pixelFormat != 1 ) {
}
return 1;
}
{
stubDestroyContext( (unsigned long) hglrc );
return 1;
}
{
{
}
}
{
}
{
else
}
{
/* this is what we call our generic pixelformat, regardless of the HDC */
return 1;
}
{
/* if ( pixelFormat != 1 ) {
* crError( "wglDescribePixelFormat: pixelFormat=%d?\n", pixelFormat );
* return 0;
* } */
if ( !pfd ) {
crWarning( "wglDescribePixelFormat: pfd=NULL\n" );
return 1; /* There's only one, baby */
}
return 1; /* There's only one, baby */
}
pfd->cAlphaShift = 0;
pfd->cAccumBits = 0;
pfd->cAccumRedBits = 0;
pfd->cAccumGreenBits = 0;
pfd->cAccumBlueBits = 0;
pfd->cAccumAlphaBits = 0;
pfd->cAuxBuffers = 0;
pfd->dwLayerMask = 0;
pfd->dwVisibleMask = 0;
pfd->dwDamageMask = 0;
/* the max PFD index */
return 1;
}
{
crWarning( "wglShareLists: unsupported" );
return 0;
}
{
char dpyName[MAX_DPY_NAME];
stubInit();
if (stub.haveNativeOpenGL)
if (!context)
return 0;
}
{
stubSwapBuffers( window, 0 );
return 1;
}
{
crWarning( "wglCopyContext: unsupported" );
return 0;
}
{
stubInit();
crWarning( "wglCreateLayerContext: unsupported" );
return 0;
}
{
}
{
crWarning( "wglUseFontBitmapsA: unsupported" );
return 0;
}
{
crWarning( "wglUseFontBitmapsW: unsupported" );
return 0;
}
{
crWarning( "wglDescribeLayerPlane: unimplemented" );
return 0;
}
{
crWarning( "wglSetLayerPaletteEntries: unsupported" );
return 0;
}
{
crWarning( "wglGetLayerPaletteEntries: unsupported" );
return 0;
}
{
crWarning( "wglRealizeLayerPalette: unsupported" );
return 0;
}
{
crWarning( "wglSwapMultipleBuffer: unsupported" );
return 0;
}
{
crWarning( "wglUseFontOutlinesA: unsupported" );
return 0;
}
{
crWarning( "wglUseFontOutlinesW: unsupported" );
return 0;
}
{
crWarning( "wglSwapLayerBuffers: unsupported" );
return 0;
}
(HDC hdc, const int *piAttributes, const FLOAT *pfAttributes, UINT nMaxFormats, int *piFormats, UINT *nNumFormats)
{
int *pi;
int wants_rgb = 0;
stubInit();
/* TODO : Need to check pfAttributes too ! */
{
switch ( *pi )
{
case WGL_COLOR_BITS_EXT:
wants_rgb = 1;
pi++;
break;
case WGL_RED_BITS_EXT:
case WGL_GREEN_BITS_EXT:
case WGL_BLUE_BITS_EXT:
wants_rgb = 1;
pi++;
break;
case WGL_ACCUM_ALPHA_BITS_EXT:
case WGL_ALPHA_BITS_EXT:
if (pi[1] > 0)
pi++;
break;
case WGL_DOUBLE_BUFFER_EXT:
if (pi[1] > 0)
pi++;
break;
case WGL_STEREO_EXT:
if (pi[1] > 0)
pi++;
break;
case WGL_DEPTH_BITS_EXT:
if (pi[1] > 0)
pi++;
break;
case WGL_STENCIL_BITS_EXT:
if (pi[1] > 0)
pi++;
break;
case WGL_ACCUM_RED_BITS_EXT:
case WGL_ACCUM_GREEN_BITS_EXT:
case WGL_ACCUM_BLUE_BITS_EXT:
if (pi[1] > 0)
pi++;
break;
case WGL_SAMPLE_BUFFERS_EXT:
case WGL_SAMPLES_EXT:
if (pi[1] > 0)
pi++;
break;
case WGL_SUPPORT_OPENGL_ARB:
case WGL_DRAW_TO_WINDOW_ARB:
case WGL_ACCELERATION_ARB:
pi++;
break;
case WGL_PIXEL_TYPE_ARB:
{
return 0;
}
pi++;
break;
default:
return 0;
}
}
if (nMaxFormats>0 && piFormats)
{
piFormats[0] = 1;
}
return 1;
}
{
UINT i;
if (!pValues || !piAttributes) return 0;
{
if (iPixelFormat!=1)
{
return 0;
}
}
for (i=0; i<nAttributes; ++i)
{
switch (piAttributes[i])
{
pValues[i] = 1;
break;
case WGL_DRAW_TO_WINDOW_ARB:
case WGL_SUPPORT_OPENGL_ARB:
case WGL_DOUBLE_BUFFER_ARB:
case WGL_STEREO_ARB:
pValues[i] = 1;
break;
case WGL_DRAW_TO_BITMAP_ARB:
case WGL_NEED_PALETTE_ARB:
case WGL_NUMBER_OVERLAYS_ARB:
case WGL_NUMBER_UNDERLAYS_ARB:
case WGL_TRANSPARENT_ARB:
case WGL_SHARE_DEPTH_ARB:
case WGL_SHARE_STENCIL_ARB:
case WGL_SHARE_ACCUM_ARB:
case WGL_SUPPORT_GDI_ARB:
pValues[i] = 0;
break;
case WGL_ACCELERATION_ARB:
break;
case WGL_SWAP_METHOD_ARB:
break;
case WGL_PIXEL_TYPE_ARB:
pValues[i] = WGL_TYPE_RGBA_ARB;
break;
case WGL_COLOR_BITS_ARB:
pValues[i] = 32;
break;
case WGL_RED_BITS_ARB:
case WGL_GREEN_BITS_ARB:
case WGL_BLUE_BITS_ARB:
case WGL_ALPHA_BITS_ARB:
pValues[i] = 8;
break;
case WGL_RED_SHIFT_ARB:
pValues[i] = 24;
break;
case WGL_GREEN_SHIFT_ARB:
pValues[i] = 16;
break;
case WGL_BLUE_SHIFT_ARB:
pValues[i] = 8;
break;
case WGL_ALPHA_SHIFT_ARB:
pValues[i] = 0;
break;
case WGL_ACCUM_BITS_ARB:
pValues[i] = 0;
break;
case WGL_ACCUM_RED_BITS_ARB:
pValues[i] = 0;
break;
case WGL_ACCUM_GREEN_BITS_ARB:
pValues[i] = 0;
break;
case WGL_ACCUM_BLUE_BITS_ARB:
pValues[i] = 0;
break;
case WGL_ACCUM_ALPHA_BITS_ARB:
pValues[i] = 0;
break;
case WGL_DEPTH_BITS_ARB:
pValues[i] = 32;
break;
case WGL_STENCIL_BITS_ARB:
pValues[i] = 8;
break;
case WGL_AUX_BUFFERS_ARB:
pValues[i] = 0;
break;
case WGL_SAMPLE_BUFFERS_EXT:
pValues[i] = 1;
break;
case WGL_SAMPLES_EXT:
pValues[i] = 1;
break;
default:
return 0;
}
}
return 1;
}
{
UINT i;
if (!pValues || !piAttributes) return 0;
{
if (iPixelFormat!=1)
{
return 0;
}
}
for (i=0; i<nAttributes; ++i)
{
switch (piAttributes[i])
{
pValues[i] = 1.f;
break;
case WGL_DRAW_TO_WINDOW_ARB:
case WGL_SUPPORT_OPENGL_ARB:
case WGL_DOUBLE_BUFFER_ARB:
case WGL_STEREO_ARB:
pValues[i] = 1.f;
break;
case WGL_DRAW_TO_BITMAP_ARB:
case WGL_NEED_PALETTE_ARB:
case WGL_NUMBER_OVERLAYS_ARB:
case WGL_NUMBER_UNDERLAYS_ARB:
case WGL_TRANSPARENT_ARB:
case WGL_SHARE_DEPTH_ARB:
case WGL_SHARE_STENCIL_ARB:
case WGL_SHARE_ACCUM_ARB:
case WGL_SUPPORT_GDI_ARB:
pValues[i] = 0.f;
break;
case WGL_ACCELERATION_ARB:
break;
case WGL_SWAP_METHOD_ARB:
break;
case WGL_PIXEL_TYPE_ARB:
pValues[i] = WGL_TYPE_RGBA_ARB;
break;
case WGL_COLOR_BITS_ARB:
pValues[i] = 32.f;
break;
case WGL_RED_BITS_ARB:
case WGL_GREEN_BITS_ARB:
case WGL_BLUE_BITS_ARB:
case WGL_ALPHA_BITS_ARB:
pValues[i] = 8.f;
break;
case WGL_RED_SHIFT_ARB:
pValues[i] = 24.f;
break;
case WGL_GREEN_SHIFT_ARB:
pValues[i] = 16.f;
break;
case WGL_BLUE_SHIFT_ARB:
pValues[i] = 8.f;
break;
case WGL_ALPHA_SHIFT_ARB:
pValues[i] = 0.f;
break;
case WGL_ACCUM_BITS_ARB:
pValues[i] = 0.f;
break;
case WGL_ACCUM_RED_BITS_ARB:
pValues[i] = 0.f;
break;
case WGL_ACCUM_GREEN_BITS_ARB:
pValues[i] = 0.f;
break;
case WGL_ACCUM_BLUE_BITS_ARB:
pValues[i] = 0.f;
break;
case WGL_ACCUM_ALPHA_BITS_ARB:
pValues[i] = 0.f;
break;
case WGL_DEPTH_BITS_ARB:
pValues[i] = 32.f;
break;
case WGL_STENCIL_BITS_ARB:
pValues[i] = 8.f;
break;
case WGL_AUX_BUFFERS_ARB:
pValues[i] = 0.f;
break;
case WGL_SAMPLE_BUFFERS_EXT:
pValues[i] = 1.f;
break;
case WGL_SAMPLES_EXT:
pValues[i] = 1.f;
break;
default:
return 0;
}
}
return 1;
}
{
return TRUE;
}
{
return 1;
}
static GLubyte *gsz_wgl_extensions = "WGL_EXT_pixel_format WGL_ARB_pixel_format WGL_ARB_multisample";
{
return gsz_wgl_extensions;
}
{
(void) hdc;
return gsz_wgl_extensions;
}