wgl.c revision e0e0c19eefceaf5d4ec40f9466b58a771f50e799
/* 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;
}
BOOL WINAPI wglChoosePixelFormatEXT_prox(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;
default:
return 0;
}
}
return 1;
}
BOOL WINAPI wglGetPixelFormatAttribivEXT_prox(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *pValues)
{
/* TODO */
return 1;
}
BOOL WINAPI wglGetPixelFormatAttribfvEXT_prox(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *pValues)
{
/* TODO */
return 1;
}
{
(void) hdc;
return retval;
}