])
sources = [
- 'icd/stw_icd.c',
-
- 'wgl/stw_wgl.c',
-
- 'shared/stw_context.c',
- 'shared/stw_device.c',
- 'shared/stw_framebuffer.c',
- 'shared/stw_pixelformat.c',
- 'shared/stw_extensionsstring.c',
- 'shared/stw_extswapinterval.c',
- 'shared/stw_getprocaddress.c',
- 'shared/stw_extgallium.c',
- 'shared/stw_arbpixelformat.c',
- 'shared/stw_tls.c',
+ 'stw_context.c',
+ 'stw_device.c',
+ 'stw_ext_extensionsstring.c',
+ 'stw_ext_gallium.c',
+ 'stw_ext_pixelformat.c',
+ 'stw_ext_swapinterval.c',
+ 'stw_framebuffer.c',
+ 'stw_getprocaddress.c',
+ 'stw_icd.c',
+ 'stw_pixelformat.c',
+ 'stw_tls.c',
+ 'stw_wgl.c',
]
wgl = env.ConvenienceLibrary(
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <windows.h>
-#include <stdio.h>
-
-#include "GL/gl.h"
-
-#include "util/u_debug.h"
-#include "pipe/p_thread.h"
-
-#include "shared/stw_public.h"
-#include "icd/stw_icd.h"
-
-#define DBG 0
-
-
-BOOL APIENTRY
-DrvCopyContext(
- DHGLRC dhrcSource,
- DHGLRC dhrcDest,
- UINT fuMask )
-{
- return stw_copy_context(dhrcSource, dhrcDest, fuMask);
-}
-
-
-DHGLRC APIENTRY
-DrvCreateLayerContext(
- HDC hdc,
- INT iLayerPlane )
-{
- DHGLRC r;
-
- r = stw_create_layer_context( hdc, iLayerPlane );
-
- if (DBG)
- debug_printf( "%s( %p, %i ) = %lu\n",
- __FUNCTION__, hdc, iLayerPlane, r );
-
- return r;
-}
-
-DHGLRC APIENTRY
-DrvCreateContext(
- HDC hdc )
-{
- return DrvCreateLayerContext( hdc, 0 );
-}
-
-BOOL APIENTRY
-DrvDeleteContext(
- DHGLRC dhglrc )
-{
- BOOL r;
-
- r = stw_delete_context( dhglrc );
-
- if (DBG)
- debug_printf( "%s( %lu ) = %u\n",
- __FUNCTION__, dhglrc, r );
-
- return r;
-}
-
-BOOL APIENTRY
-DrvDescribeLayerPlane(
- HDC hdc,
- INT iPixelFormat,
- INT iLayerPlane,
- UINT nBytes,
- LPLAYERPLANEDESCRIPTOR plpd )
-{
- if (DBG)
- debug_printf( "%s\n", __FUNCTION__ );
-
- return FALSE;
-}
-
-LONG APIENTRY
-DrvDescribePixelFormat(
- HDC hdc,
- INT iPixelFormat,
- ULONG cjpfd,
- PIXELFORMATDESCRIPTOR *ppfd )
-{
- LONG r;
-
- r = stw_pixelformat_describe( hdc, iPixelFormat, cjpfd, ppfd );
-
- if (DBG)
- debug_printf( "%s( %p, %i, %lu, %p ) = %li\n",
- __FUNCTION__, hdc, iPixelFormat, cjpfd, ppfd, r );
-
- return r;
-}
-
-int APIENTRY
-DrvGetLayerPaletteEntries(
- HDC hdc,
- INT iLayerPlane,
- INT iStart,
- INT cEntries,
- COLORREF *pcr )
-{
- if (DBG)
- debug_printf( "%s\n", __FUNCTION__ );
-
- return 0;
-}
-
-PROC APIENTRY
-DrvGetProcAddress(
- LPCSTR lpszProc )
-{
- PROC r;
-
- r = stw_get_proc_address( lpszProc );
-
- if (DBG)
- debug_printf( "%s( \"%s\" ) = %p\n", __FUNCTION__, lpszProc, r );
-
- return r;
-}
-
-BOOL APIENTRY
-DrvRealizeLayerPalette(
- HDC hdc,
- INT iLayerPlane,
- BOOL bRealize )
-{
- if (DBG)
- debug_printf( "%s\n", __FUNCTION__ );
-
- return FALSE;
-}
-
-BOOL APIENTRY
-DrvReleaseContext(
- DHGLRC dhglrc )
-{
- return stw_release_context(dhglrc);
-}
-
-void APIENTRY
-DrvSetCallbackProcs(
- INT nProcs,
- PROC *pProcs )
-{
- if (DBG)
- debug_printf( "%s( %d, %p )\n", __FUNCTION__, nProcs, pProcs );
-
- return;
-}
-
-
-/**
- * Although WGL allows different dispatch entrypoints per context
- */
-static const GLCLTPROCTABLE cpt =
-{
- OPENGL_VERSION_110_ENTRIES,
- {
- &glNewList,
- &glEndList,
- &glCallList,
- &glCallLists,
- &glDeleteLists,
- &glGenLists,
- &glListBase,
- &glBegin,
- &glBitmap,
- &glColor3b,
- &glColor3bv,
- &glColor3d,
- &glColor3dv,
- &glColor3f,
- &glColor3fv,
- &glColor3i,
- &glColor3iv,
- &glColor3s,
- &glColor3sv,
- &glColor3ub,
- &glColor3ubv,
- &glColor3ui,
- &glColor3uiv,
- &glColor3us,
- &glColor3usv,
- &glColor4b,
- &glColor4bv,
- &glColor4d,
- &glColor4dv,
- &glColor4f,
- &glColor4fv,
- &glColor4i,
- &glColor4iv,
- &glColor4s,
- &glColor4sv,
- &glColor4ub,
- &glColor4ubv,
- &glColor4ui,
- &glColor4uiv,
- &glColor4us,
- &glColor4usv,
- &glEdgeFlag,
- &glEdgeFlagv,
- &glEnd,
- &glIndexd,
- &glIndexdv,
- &glIndexf,
- &glIndexfv,
- &glIndexi,
- &glIndexiv,
- &glIndexs,
- &glIndexsv,
- &glNormal3b,
- &glNormal3bv,
- &glNormal3d,
- &glNormal3dv,
- &glNormal3f,
- &glNormal3fv,
- &glNormal3i,
- &glNormal3iv,
- &glNormal3s,
- &glNormal3sv,
- &glRasterPos2d,
- &glRasterPos2dv,
- &glRasterPos2f,
- &glRasterPos2fv,
- &glRasterPos2i,
- &glRasterPos2iv,
- &glRasterPos2s,
- &glRasterPos2sv,
- &glRasterPos3d,
- &glRasterPos3dv,
- &glRasterPos3f,
- &glRasterPos3fv,
- &glRasterPos3i,
- &glRasterPos3iv,
- &glRasterPos3s,
- &glRasterPos3sv,
- &glRasterPos4d,
- &glRasterPos4dv,
- &glRasterPos4f,
- &glRasterPos4fv,
- &glRasterPos4i,
- &glRasterPos4iv,
- &glRasterPos4s,
- &glRasterPos4sv,
- &glRectd,
- &glRectdv,
- &glRectf,
- &glRectfv,
- &glRecti,
- &glRectiv,
- &glRects,
- &glRectsv,
- &glTexCoord1d,
- &glTexCoord1dv,
- &glTexCoord1f,
- &glTexCoord1fv,
- &glTexCoord1i,
- &glTexCoord1iv,
- &glTexCoord1s,
- &glTexCoord1sv,
- &glTexCoord2d,
- &glTexCoord2dv,
- &glTexCoord2f,
- &glTexCoord2fv,
- &glTexCoord2i,
- &glTexCoord2iv,
- &glTexCoord2s,
- &glTexCoord2sv,
- &glTexCoord3d,
- &glTexCoord3dv,
- &glTexCoord3f,
- &glTexCoord3fv,
- &glTexCoord3i,
- &glTexCoord3iv,
- &glTexCoord3s,
- &glTexCoord3sv,
- &glTexCoord4d,
- &glTexCoord4dv,
- &glTexCoord4f,
- &glTexCoord4fv,
- &glTexCoord4i,
- &glTexCoord4iv,
- &glTexCoord4s,
- &glTexCoord4sv,
- &glVertex2d,
- &glVertex2dv,
- &glVertex2f,
- &glVertex2fv,
- &glVertex2i,
- &glVertex2iv,
- &glVertex2s,
- &glVertex2sv,
- &glVertex3d,
- &glVertex3dv,
- &glVertex3f,
- &glVertex3fv,
- &glVertex3i,
- &glVertex3iv,
- &glVertex3s,
- &glVertex3sv,
- &glVertex4d,
- &glVertex4dv,
- &glVertex4f,
- &glVertex4fv,
- &glVertex4i,
- &glVertex4iv,
- &glVertex4s,
- &glVertex4sv,
- &glClipPlane,
- &glColorMaterial,
- &glCullFace,
- &glFogf,
- &glFogfv,
- &glFogi,
- &glFogiv,
- &glFrontFace,
- &glHint,
- &glLightf,
- &glLightfv,
- &glLighti,
- &glLightiv,
- &glLightModelf,
- &glLightModelfv,
- &glLightModeli,
- &glLightModeliv,
- &glLineStipple,
- &glLineWidth,
- &glMaterialf,
- &glMaterialfv,
- &glMateriali,
- &glMaterialiv,
- &glPointSize,
- &glPolygonMode,
- &glPolygonStipple,
- &glScissor,
- &glShadeModel,
- &glTexParameterf,
- &glTexParameterfv,
- &glTexParameteri,
- &glTexParameteriv,
- &glTexImage1D,
- &glTexImage2D,
- &glTexEnvf,
- &glTexEnvfv,
- &glTexEnvi,
- &glTexEnviv,
- &glTexGend,
- &glTexGendv,
- &glTexGenf,
- &glTexGenfv,
- &glTexGeni,
- &glTexGeniv,
- &glFeedbackBuffer,
- &glSelectBuffer,
- &glRenderMode,
- &glInitNames,
- &glLoadName,
- &glPassThrough,
- &glPopName,
- &glPushName,
- &glDrawBuffer,
- &glClear,
- &glClearAccum,
- &glClearIndex,
- &glClearColor,
- &glClearStencil,
- &glClearDepth,
- &glStencilMask,
- &glColorMask,
- &glDepthMask,
- &glIndexMask,
- &glAccum,
- &glDisable,
- &glEnable,
- &glFinish,
- &glFlush,
- &glPopAttrib,
- &glPushAttrib,
- &glMap1d,
- &glMap1f,
- &glMap2d,
- &glMap2f,
- &glMapGrid1d,
- &glMapGrid1f,
- &glMapGrid2d,
- &glMapGrid2f,
- &glEvalCoord1d,
- &glEvalCoord1dv,
- &glEvalCoord1f,
- &glEvalCoord1fv,
- &glEvalCoord2d,
- &glEvalCoord2dv,
- &glEvalCoord2f,
- &glEvalCoord2fv,
- &glEvalMesh1,
- &glEvalPoint1,
- &glEvalMesh2,
- &glEvalPoint2,
- &glAlphaFunc,
- &glBlendFunc,
- &glLogicOp,
- &glStencilFunc,
- &glStencilOp,
- &glDepthFunc,
- &glPixelZoom,
- &glPixelTransferf,
- &glPixelTransferi,
- &glPixelStoref,
- &glPixelStorei,
- &glPixelMapfv,
- &glPixelMapuiv,
- &glPixelMapusv,
- &glReadBuffer,
- &glCopyPixels,
- &glReadPixels,
- &glDrawPixels,
- &glGetBooleanv,
- &glGetClipPlane,
- &glGetDoublev,
- &glGetError,
- &glGetFloatv,
- &glGetIntegerv,
- &glGetLightfv,
- &glGetLightiv,
- &glGetMapdv,
- &glGetMapfv,
- &glGetMapiv,
- &glGetMaterialfv,
- &glGetMaterialiv,
- &glGetPixelMapfv,
- &glGetPixelMapuiv,
- &glGetPixelMapusv,
- &glGetPolygonStipple,
- &glGetString,
- &glGetTexEnvfv,
- &glGetTexEnviv,
- &glGetTexGendv,
- &glGetTexGenfv,
- &glGetTexGeniv,
- &glGetTexImage,
- &glGetTexParameterfv,
- &glGetTexParameteriv,
- &glGetTexLevelParameterfv,
- &glGetTexLevelParameteriv,
- &glIsEnabled,
- &glIsList,
- &glDepthRange,
- &glFrustum,
- &glLoadIdentity,
- &glLoadMatrixf,
- &glLoadMatrixd,
- &glMatrixMode,
- &glMultMatrixf,
- &glMultMatrixd,
- &glOrtho,
- &glPopMatrix,
- &glPushMatrix,
- &glRotated,
- &glRotatef,
- &glScaled,
- &glScalef,
- &glTranslated,
- &glTranslatef,
- &glViewport,
- &glArrayElement,
- &glBindTexture,
- &glColorPointer,
- &glDisableClientState,
- &glDrawArrays,
- &glDrawElements,
- &glEdgeFlagPointer,
- &glEnableClientState,
- &glIndexPointer,
- &glIndexub,
- &glIndexubv,
- &glInterleavedArrays,
- &glNormalPointer,
- &glPolygonOffset,
- &glTexCoordPointer,
- &glVertexPointer,
- &glAreTexturesResident,
- &glCopyTexImage1D,
- &glCopyTexImage2D,
- &glCopyTexSubImage1D,
- &glCopyTexSubImage2D,
- &glDeleteTextures,
- &glGenTextures,
- &glGetPointerv,
- &glIsTexture,
- &glPrioritizeTextures,
- &glTexSubImage1D,
- &glTexSubImage2D,
- &glPopClientAttrib,
- &glPushClientAttrib
- }
-};
-
-
-PGLCLTPROCTABLE APIENTRY
-DrvSetContext(
- HDC hdc,
- DHGLRC dhglrc,
- PFN_SETPROCTABLE pfnSetProcTable )
-{
- PGLCLTPROCTABLE r = (PGLCLTPROCTABLE)&cpt;
-
- if (!stw_make_current( hdc, dhglrc ))
- r = NULL;
-
- if (DBG)
- debug_printf( "%s( 0x%p, %lu, 0x%p ) = %p\n",
- __FUNCTION__, hdc, dhglrc, pfnSetProcTable, r );
-
- return r;
-}
-
-int APIENTRY
-DrvSetLayerPaletteEntries(
- HDC hdc,
- INT iLayerPlane,
- INT iStart,
- INT cEntries,
- CONST COLORREF *pcr )
-{
- if (DBG)
- debug_printf( "%s\n", __FUNCTION__ );
-
- return 0;
-}
-
-BOOL APIENTRY
-DrvSetPixelFormat(
- HDC hdc,
- LONG iPixelFormat )
-{
- BOOL r;
-
- r = stw_pixelformat_set( hdc, iPixelFormat );
-
- if (DBG)
- debug_printf( "%s( %p, %li ) = %s\n", __FUNCTION__, hdc, iPixelFormat, r ? "TRUE" : "FALSE" );
-
- return r;
-}
-
-BOOL APIENTRY
-DrvShareLists(
- DHGLRC dhglrc1,
- DHGLRC dhglrc2 )
-{
- if (DBG)
- debug_printf( "%s\n", __FUNCTION__ );
-
- return stw_share_lists(dhglrc1, dhglrc2);
-}
-
-BOOL APIENTRY
-DrvSwapBuffers(
- HDC hdc )
-{
- if (DBG)
- debug_printf( "%s( %p )\n", __FUNCTION__, hdc );
-
- return stw_swap_buffers( hdc );
-}
-
-BOOL APIENTRY
-DrvSwapLayerBuffers(
- HDC hdc,
- UINT fuPlanes )
-{
- if (DBG)
- debug_printf( "%s\n", __FUNCTION__ );
-
- return stw_swap_layer_buffers( hdc, fuPlanes );
-}
-
-BOOL APIENTRY
-DrvValidateVersion(
- ULONG ulVersion )
-{
- if (DBG)
- debug_printf( "%s( %lu )\n", __FUNCTION__, ulVersion );
-
- /* TODO: get the expected version from the winsys */
-
- return ulVersion == 1;
-}
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef STW_ICD_H
-#define STW_ICD_H
-
-
-#include <windows.h>
-
-#include "GL/gl.h"
-
-
-typedef ULONG DHGLRC;
-
-#define OPENGL_VERSION_110_ENTRIES 336
-
-struct __GLdispatchTableRec
-{
- void (GLAPIENTRY * NewList)(GLuint, GLenum);
- void (GLAPIENTRY * EndList)(void);
- void (GLAPIENTRY * CallList)(GLuint);
- void (GLAPIENTRY * CallLists)(GLsizei, GLenum, const GLvoid *);
- void (GLAPIENTRY * DeleteLists)(GLuint, GLsizei);
- GLuint (GLAPIENTRY * GenLists)(GLsizei);
- void (GLAPIENTRY * ListBase)(GLuint);
- void (GLAPIENTRY * Begin)(GLenum);
- void (GLAPIENTRY * Bitmap)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *);
- void (GLAPIENTRY * Color3b)(GLbyte, GLbyte, GLbyte);
- void (GLAPIENTRY * Color3bv)(const GLbyte *);
- void (GLAPIENTRY * Color3d)(GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * Color3dv)(const GLdouble *);
- void (GLAPIENTRY * Color3f)(GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * Color3fv)(const GLfloat *);
- void (GLAPIENTRY * Color3i)(GLint, GLint, GLint);
- void (GLAPIENTRY * Color3iv)(const GLint *);
- void (GLAPIENTRY * Color3s)(GLshort, GLshort, GLshort);
- void (GLAPIENTRY * Color3sv)(const GLshort *);
- void (GLAPIENTRY * Color3ub)(GLubyte, GLubyte, GLubyte);
- void (GLAPIENTRY * Color3ubv)(const GLubyte *);
- void (GLAPIENTRY * Color3ui)(GLuint, GLuint, GLuint);
- void (GLAPIENTRY * Color3uiv)(const GLuint *);
- void (GLAPIENTRY * Color3us)(GLushort, GLushort, GLushort);
- void (GLAPIENTRY * Color3usv)(const GLushort *);
- void (GLAPIENTRY * Color4b)(GLbyte, GLbyte, GLbyte, GLbyte);
- void (GLAPIENTRY * Color4bv)(const GLbyte *);
- void (GLAPIENTRY * Color4d)(GLdouble, GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * Color4dv)(const GLdouble *);
- void (GLAPIENTRY * Color4f)(GLfloat, GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * Color4fv)(const GLfloat *);
- void (GLAPIENTRY * Color4i)(GLint, GLint, GLint, GLint);
- void (GLAPIENTRY * Color4iv)(const GLint *);
- void (GLAPIENTRY * Color4s)(GLshort, GLshort, GLshort, GLshort);
- void (GLAPIENTRY * Color4sv)(const GLshort *);
- void (GLAPIENTRY * Color4ub)(GLubyte, GLubyte, GLubyte, GLubyte);
- void (GLAPIENTRY * Color4ubv)(const GLubyte *);
- void (GLAPIENTRY * Color4ui)(GLuint, GLuint, GLuint, GLuint);
- void (GLAPIENTRY * Color4uiv)(const GLuint *);
- void (GLAPIENTRY * Color4us)(GLushort, GLushort, GLushort, GLushort);
- void (GLAPIENTRY * Color4usv)(const GLushort *);
- void (GLAPIENTRY * EdgeFlag)(GLboolean);
- void (GLAPIENTRY * EdgeFlagv)(const GLboolean *);
- void (GLAPIENTRY * End)(void);
- void (GLAPIENTRY * Indexd)(GLdouble);
- void (GLAPIENTRY * Indexdv)(const GLdouble *);
- void (GLAPIENTRY * Indexf)(GLfloat);
- void (GLAPIENTRY * Indexfv)(const GLfloat *);
- void (GLAPIENTRY * Indexi)(GLint);
- void (GLAPIENTRY * Indexiv)(const GLint *);
- void (GLAPIENTRY * Indexs)(GLshort);
- void (GLAPIENTRY * Indexsv)(const GLshort *);
- void (GLAPIENTRY * Normal3b)(GLbyte, GLbyte, GLbyte);
- void (GLAPIENTRY * Normal3bv)(const GLbyte *);
- void (GLAPIENTRY * Normal3d)(GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * Normal3dv)(const GLdouble *);
- void (GLAPIENTRY * Normal3f)(GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * Normal3fv)(const GLfloat *);
- void (GLAPIENTRY * Normal3i)(GLint, GLint, GLint);
- void (GLAPIENTRY * Normal3iv)(const GLint *);
- void (GLAPIENTRY * Normal3s)(GLshort, GLshort, GLshort);
- void (GLAPIENTRY * Normal3sv)(const GLshort *);
- void (GLAPIENTRY * RasterPos2d)(GLdouble, GLdouble);
- void (GLAPIENTRY * RasterPos2dv)(const GLdouble *);
- void (GLAPIENTRY * RasterPos2f)(GLfloat, GLfloat);
- void (GLAPIENTRY * RasterPos2fv)(const GLfloat *);
- void (GLAPIENTRY * RasterPos2i)(GLint, GLint);
- void (GLAPIENTRY * RasterPos2iv)(const GLint *);
- void (GLAPIENTRY * RasterPos2s)(GLshort, GLshort);
- void (GLAPIENTRY * RasterPos2sv)(const GLshort *);
- void (GLAPIENTRY * RasterPos3d)(GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * RasterPos3dv)(const GLdouble *);
- void (GLAPIENTRY * RasterPos3f)(GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * RasterPos3fv)(const GLfloat *);
- void (GLAPIENTRY * RasterPos3i)(GLint, GLint, GLint);
- void (GLAPIENTRY * RasterPos3iv)(const GLint *);
- void (GLAPIENTRY * RasterPos3s)(GLshort, GLshort, GLshort);
- void (GLAPIENTRY * RasterPos3sv)(const GLshort *);
- void (GLAPIENTRY * RasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * RasterPos4dv)(const GLdouble *);
- void (GLAPIENTRY * RasterPos4f)(GLfloat, GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * RasterPos4fv)(const GLfloat *);
- void (GLAPIENTRY * RasterPos4i)(GLint, GLint, GLint, GLint);
- void (GLAPIENTRY * RasterPos4iv)(const GLint *);
- void (GLAPIENTRY * RasterPos4s)(GLshort, GLshort, GLshort, GLshort);
- void (GLAPIENTRY * RasterPos4sv)(const GLshort *);
- void (GLAPIENTRY * Rectd)(GLdouble, GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * Rectdv)(const GLdouble *, const GLdouble *);
- void (GLAPIENTRY * Rectf)(GLfloat, GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * Rectfv)(const GLfloat *, const GLfloat *);
- void (GLAPIENTRY * Recti)(GLint, GLint, GLint, GLint);
- void (GLAPIENTRY * Rectiv)(const GLint *, const GLint *);
- void (GLAPIENTRY * Rects)(GLshort, GLshort, GLshort, GLshort);
- void (GLAPIENTRY * Rectsv)(const GLshort *, const GLshort *);
- void (GLAPIENTRY * TexCoord1d)(GLdouble);
- void (GLAPIENTRY * TexCoord1dv)(const GLdouble *);
- void (GLAPIENTRY * TexCoord1f)(GLfloat);
- void (GLAPIENTRY * TexCoord1fv)(const GLfloat *);
- void (GLAPIENTRY * TexCoord1i)(GLint);
- void (GLAPIENTRY * TexCoord1iv)(const GLint *);
- void (GLAPIENTRY * TexCoord1s)(GLshort);
- void (GLAPIENTRY * TexCoord1sv)(const GLshort *);
- void (GLAPIENTRY * TexCoord2d)(GLdouble, GLdouble);
- void (GLAPIENTRY * TexCoord2dv)(const GLdouble *);
- void (GLAPIENTRY * TexCoord2f)(GLfloat, GLfloat);
- void (GLAPIENTRY * TexCoord2fv)(const GLfloat *);
- void (GLAPIENTRY * TexCoord2i)(GLint, GLint);
- void (GLAPIENTRY * TexCoord2iv)(const GLint *);
- void (GLAPIENTRY * TexCoord2s)(GLshort, GLshort);
- void (GLAPIENTRY * TexCoord2sv)(const GLshort *);
- void (GLAPIENTRY * TexCoord3d)(GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * TexCoord3dv)(const GLdouble *);
- void (GLAPIENTRY * TexCoord3f)(GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * TexCoord3fv)(const GLfloat *);
- void (GLAPIENTRY * TexCoord3i)(GLint, GLint, GLint);
- void (GLAPIENTRY * TexCoord3iv)(const GLint *);
- void (GLAPIENTRY * TexCoord3s)(GLshort, GLshort, GLshort);
- void (GLAPIENTRY * TexCoord3sv)(const GLshort *);
- void (GLAPIENTRY * TexCoord4d)(GLdouble, GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * TexCoord4dv)(const GLdouble *);
- void (GLAPIENTRY * TexCoord4f)(GLfloat, GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * TexCoord4fv)(const GLfloat *);
- void (GLAPIENTRY * TexCoord4i)(GLint, GLint, GLint, GLint);
- void (GLAPIENTRY * TexCoord4iv)(const GLint *);
- void (GLAPIENTRY * TexCoord4s)(GLshort, GLshort, GLshort, GLshort);
- void (GLAPIENTRY * TexCoord4sv)(const GLshort *);
- void (GLAPIENTRY * Vertex2d)(GLdouble, GLdouble);
- void (GLAPIENTRY * Vertex2dv)(const GLdouble *);
- void (GLAPIENTRY * Vertex2f)(GLfloat, GLfloat);
- void (GLAPIENTRY * Vertex2fv)(const GLfloat *);
- void (GLAPIENTRY * Vertex2i)(GLint, GLint);
- void (GLAPIENTRY * Vertex2iv)(const GLint *);
- void (GLAPIENTRY * Vertex2s)(GLshort, GLshort);
- void (GLAPIENTRY * Vertex2sv)(const GLshort *);
- void (GLAPIENTRY * Vertex3d)(GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * Vertex3dv)(const GLdouble *);
- void (GLAPIENTRY * Vertex3f)(GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * Vertex3fv)(const GLfloat *);
- void (GLAPIENTRY * Vertex3i)(GLint, GLint, GLint);
- void (GLAPIENTRY * Vertex3iv)(const GLint *);
- void (GLAPIENTRY * Vertex3s)(GLshort, GLshort, GLshort);
- void (GLAPIENTRY * Vertex3sv)(const GLshort *);
- void (GLAPIENTRY * Vertex4d)(GLdouble, GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * Vertex4dv)(const GLdouble *);
- void (GLAPIENTRY * Vertex4f)(GLfloat, GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * Vertex4fv)(const GLfloat *);
- void (GLAPIENTRY * Vertex4i)(GLint, GLint, GLint, GLint);
- void (GLAPIENTRY * Vertex4iv)(const GLint *);
- void (GLAPIENTRY * Vertex4s)(GLshort, GLshort, GLshort, GLshort);
- void (GLAPIENTRY * Vertex4sv)(const GLshort *);
- void (GLAPIENTRY * ClipPlane)(GLenum, const GLdouble *);
- void (GLAPIENTRY * ColorMaterial)(GLenum, GLenum);
- void (GLAPIENTRY * CullFace)(GLenum);
- void (GLAPIENTRY * Fogf)(GLenum, GLfloat);
- void (GLAPIENTRY * Fogfv)(GLenum, const GLfloat *);
- void (GLAPIENTRY * Fogi)(GLenum, GLint);
- void (GLAPIENTRY * Fogiv)(GLenum, const GLint *);
- void (GLAPIENTRY * FrontFace)(GLenum);
- void (GLAPIENTRY * Hint)(GLenum, GLenum);
- void (GLAPIENTRY * Lightf)(GLenum, GLenum, GLfloat);
- void (GLAPIENTRY * Lightfv)(GLenum, GLenum, const GLfloat *);
- void (GLAPIENTRY * Lighti)(GLenum, GLenum, GLint);
- void (GLAPIENTRY * Lightiv)(GLenum, GLenum, const GLint *);
- void (GLAPIENTRY * LightModelf)(GLenum, GLfloat);
- void (GLAPIENTRY * LightModelfv)(GLenum, const GLfloat *);
- void (GLAPIENTRY * LightModeli)(GLenum, GLint);
- void (GLAPIENTRY * LightModeliv)(GLenum, const GLint *);
- void (GLAPIENTRY * LineStipple)(GLint, GLushort);
- void (GLAPIENTRY * LineWidth)(GLfloat);
- void (GLAPIENTRY * Materialf)(GLenum, GLenum, GLfloat);
- void (GLAPIENTRY * Materialfv)(GLenum, GLenum, const GLfloat *);
- void (GLAPIENTRY * Materiali)(GLenum, GLenum, GLint);
- void (GLAPIENTRY * Materialiv)(GLenum, GLenum, const GLint *);
- void (GLAPIENTRY * PointSize)(GLfloat);
- void (GLAPIENTRY * PolygonMode)(GLenum, GLenum);
- void (GLAPIENTRY * PolygonStipple)(const GLubyte *);
- void (GLAPIENTRY * Scissor)(GLint, GLint, GLsizei, GLsizei);
- void (GLAPIENTRY * ShadeModel)(GLenum);
- void (GLAPIENTRY * TexParameterf)(GLenum, GLenum, GLfloat);
- void (GLAPIENTRY * TexParameterfv)(GLenum, GLenum, const GLfloat *);
- void (GLAPIENTRY * TexParameteri)(GLenum, GLenum, GLint);
- void (GLAPIENTRY * TexParameteriv)(GLenum, GLenum, const GLint *);
- void (GLAPIENTRY * TexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
- void (GLAPIENTRY * TexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
- void (GLAPIENTRY * TexEnvf)(GLenum, GLenum, GLfloat);
- void (GLAPIENTRY * TexEnvfv)(GLenum, GLenum, const GLfloat *);
- void (GLAPIENTRY * TexEnvi)(GLenum, GLenum, GLint);
- void (GLAPIENTRY * TexEnviv)(GLenum, GLenum, const GLint *);
- void (GLAPIENTRY * TexGend)(GLenum, GLenum, GLdouble);
- void (GLAPIENTRY * TexGendv)(GLenum, GLenum, const GLdouble *);
- void (GLAPIENTRY * TexGenf)(GLenum, GLenum, GLfloat);
- void (GLAPIENTRY * TexGenfv)(GLenum, GLenum, const GLfloat *);
- void (GLAPIENTRY * TexGeni)(GLenum, GLenum, GLint);
- void (GLAPIENTRY * TexGeniv)(GLenum, GLenum, const GLint *);
- void (GLAPIENTRY * FeedbackBuffer)(GLsizei, GLenum, GLfloat *);
- void (GLAPIENTRY * SelectBuffer)(GLsizei, GLuint *);
- GLint (GLAPIENTRY * RenderMode)(GLenum);
- void (GLAPIENTRY * InitNames)(void);
- void (GLAPIENTRY * LoadName)(GLuint);
- void (GLAPIENTRY * PassThrough)(GLfloat);
- void (GLAPIENTRY * PopName)(void);
- void (GLAPIENTRY * PushName)(GLuint);
- void (GLAPIENTRY * DrawBuffer)(GLenum);
- void (GLAPIENTRY * Clear)(GLbitfield);
- void (GLAPIENTRY * ClearAccum)(GLfloat, GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * ClearIndex)(GLfloat);
- void (GLAPIENTRY * ClearColor)(GLclampf, GLclampf, GLclampf, GLclampf);
- void (GLAPIENTRY * ClearStencil)(GLint);
- void (GLAPIENTRY * ClearDepth)(GLclampd);
- void (GLAPIENTRY * StencilMask)(GLuint);
- void (GLAPIENTRY * ColorMask)(GLboolean, GLboolean, GLboolean, GLboolean);
- void (GLAPIENTRY * DepthMask)(GLboolean);
- void (GLAPIENTRY * IndexMask)(GLuint);
- void (GLAPIENTRY * Accum)(GLenum, GLfloat);
- void (GLAPIENTRY * Disable)(GLenum);
- void (GLAPIENTRY * Enable)(GLenum);
- void (GLAPIENTRY * Finish)(void);
- void (GLAPIENTRY * Flush)(void);
- void (GLAPIENTRY * PopAttrib)(void);
- void (GLAPIENTRY * PushAttrib)(GLbitfield);
- void (GLAPIENTRY * Map1d)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *);
- void (GLAPIENTRY * Map1f)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *);
- void (GLAPIENTRY * Map2d)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *);
- void (GLAPIENTRY * Map2f)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *);
- void (GLAPIENTRY * MapGrid1d)(GLint, GLdouble, GLdouble);
- void (GLAPIENTRY * MapGrid1f)(GLint, GLfloat, GLfloat);
- void (GLAPIENTRY * MapGrid2d)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble);
- void (GLAPIENTRY * MapGrid2f)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat);
- void (GLAPIENTRY * EvalCoord1d)(GLdouble);
- void (GLAPIENTRY * EvalCoord1dv)(const GLdouble *);
- void (GLAPIENTRY * EvalCoord1f)(GLfloat);
- void (GLAPIENTRY * EvalCoord1fv)(const GLfloat *);
- void (GLAPIENTRY * EvalCoord2d)(GLdouble, GLdouble);
- void (GLAPIENTRY * EvalCoord2dv)(const GLdouble *);
- void (GLAPIENTRY * EvalCoord2f)(GLfloat, GLfloat);
- void (GLAPIENTRY * EvalCoord2fv)(const GLfloat *);
- void (GLAPIENTRY * EvalMesh1)(GLenum, GLint, GLint);
- void (GLAPIENTRY * EvalPoint1)(GLint);
- void (GLAPIENTRY * EvalMesh2)(GLenum, GLint, GLint, GLint, GLint);
- void (GLAPIENTRY * EvalPoint2)(GLint, GLint);
- void (GLAPIENTRY * AlphaFunc)(GLenum, GLclampf);
- void (GLAPIENTRY * BlendFunc)(GLenum, GLenum);
- void (GLAPIENTRY * LogicOp)(GLenum);
- void (GLAPIENTRY * StencilFunc)(GLenum, GLint, GLuint);
- void (GLAPIENTRY * StencilOp)(GLenum, GLenum, GLenum);
- void (GLAPIENTRY * DepthFunc)(GLenum);
- void (GLAPIENTRY * PixelZoom)(GLfloat, GLfloat);
- void (GLAPIENTRY * PixelTransferf)(GLenum, GLfloat);
- void (GLAPIENTRY * PixelTransferi)(GLenum, GLint);
- void (GLAPIENTRY * PixelStoref)(GLenum, GLfloat);
- void (GLAPIENTRY * PixelStorei)(GLenum, GLint);
- void (GLAPIENTRY * PixelMapfv)(GLenum, GLint, const GLfloat *);
- void (GLAPIENTRY * PixelMapuiv)(GLenum, GLint, const GLuint *);
- void (GLAPIENTRY * PixelMapusv)(GLenum, GLint, const GLushort *);
- void (GLAPIENTRY * ReadBuffer)(GLenum);
- void (GLAPIENTRY * CopyPixels)(GLint, GLint, GLsizei, GLsizei, GLenum);
- void (GLAPIENTRY * ReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *);
- void (GLAPIENTRY * DrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
- void (GLAPIENTRY * GetBooleanv)(GLenum, GLboolean *);
- void (GLAPIENTRY * GetClipPlane)(GLenum, GLdouble *);
- void (GLAPIENTRY * GetDoublev)(GLenum, GLdouble *);
- GLenum (GLAPIENTRY * GetError)(void);
- void (GLAPIENTRY * GetFloatv)(GLenum, GLfloat *);
- void (GLAPIENTRY * GetIntegerv)(GLenum, GLint *);
- void (GLAPIENTRY * GetLightfv)(GLenum, GLenum, GLfloat *);
- void (GLAPIENTRY * GetLightiv)(GLenum, GLenum, GLint *);
- void (GLAPIENTRY * GetMapdv)(GLenum, GLenum, GLdouble *);
- void (GLAPIENTRY * GetMapfv)(GLenum, GLenum, GLfloat *);
- void (GLAPIENTRY * GetMapiv)(GLenum, GLenum, GLint *);
- void (GLAPIENTRY * GetMaterialfv)(GLenum, GLenum, GLfloat *);
- void (GLAPIENTRY * GetMaterialiv)(GLenum, GLenum, GLint *);
- void (GLAPIENTRY * GetPixelMapfv)(GLenum, GLfloat *);
- void (GLAPIENTRY * GetPixelMapuiv)(GLenum, GLuint *);
- void (GLAPIENTRY * GetPixelMapusv)(GLenum, GLushort *);
- void (GLAPIENTRY * GetPolygonStipple)(GLubyte *);
- const GLubyte * (GLAPIENTRY * GetString)(GLenum);
- void (GLAPIENTRY * GetTexEnvfv)(GLenum, GLenum, GLfloat *);
- void (GLAPIENTRY * GetTexEnviv)(GLenum, GLenum, GLint *);
- void (GLAPIENTRY * GetTexGendv)(GLenum, GLenum, GLdouble *);
- void (GLAPIENTRY * GetTexGenfv)(GLenum, GLenum, GLfloat *);
- void (GLAPIENTRY * GetTexGeniv)(GLenum, GLenum, GLint *);
- void (GLAPIENTRY * GetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *);
- void (GLAPIENTRY * GetTexParameterfv)(GLenum, GLenum, GLfloat *);
- void (GLAPIENTRY * GetTexParameteriv)(GLenum, GLenum, GLint *);
- void (GLAPIENTRY * GetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *);
- void (GLAPIENTRY * GetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *);
- GLboolean (GLAPIENTRY * IsEnabled)(GLenum);
- GLboolean (GLAPIENTRY * IsList)(GLuint);
- void (GLAPIENTRY * DepthRange)(GLclampd, GLclampd);
- void (GLAPIENTRY * Frustum)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * LoadIdentity)(void);
- void (GLAPIENTRY * LoadMatrixf)(const GLfloat *);
- void (GLAPIENTRY * LoadMatrixd)(const GLdouble *);
- void (GLAPIENTRY * MatrixMode)(GLenum);
- void (GLAPIENTRY * MultMatrixf)(const GLfloat *);
- void (GLAPIENTRY * MultMatrixd)(const GLdouble *);
- void (GLAPIENTRY * Ortho)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * PopMatrix)(void);
- void (GLAPIENTRY * PushMatrix)(void);
- void (GLAPIENTRY * Rotated)(GLdouble, GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * Rotatef)(GLfloat, GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * Scaled)(GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * Scalef)(GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * Translated)(GLdouble, GLdouble, GLdouble);
- void (GLAPIENTRY * Translatef)(GLfloat, GLfloat, GLfloat);
- void (GLAPIENTRY * Viewport)(GLint, GLint, GLsizei, GLsizei);
- void (GLAPIENTRY * ArrayElement)(GLint);
- void (GLAPIENTRY * BindTexture)(GLenum, GLuint);
- void (GLAPIENTRY * ColorPointer)(GLint, GLenum, GLsizei, const GLvoid *);
- void (GLAPIENTRY * DisableClientState)(GLenum);
- void (GLAPIENTRY * DrawArrays)(GLenum, GLint, GLsizei);
- void (GLAPIENTRY * DrawElements)(GLenum, GLsizei, GLenum, const GLvoid *);
- void (GLAPIENTRY * EdgeFlagPointer)(GLsizei, const GLvoid *);
- void (GLAPIENTRY * EnableClientState)(GLenum);
- void (GLAPIENTRY * IndexPointer)(GLenum, GLsizei, const GLvoid *);
- void (GLAPIENTRY * Indexub)(GLubyte);
- void (GLAPIENTRY * Indexubv)(const GLubyte *);
- void (GLAPIENTRY * InterleavedArrays)(GLenum, GLsizei, const GLvoid *);
- void (GLAPIENTRY * NormalPointer)(GLenum, GLsizei, const GLvoid *);
- void (GLAPIENTRY * PolygonOffset)(GLfloat, GLfloat);
- void (GLAPIENTRY * TexCoordPointer)(GLint, GLenum, GLsizei, const GLvoid *);
- void (GLAPIENTRY * VertexPointer)(GLint, GLenum, GLsizei, const GLvoid *);
- GLboolean (GLAPIENTRY * AreTexturesResident)(GLsizei, const GLuint *, GLboolean *);
- void (GLAPIENTRY * CopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);
- void (GLAPIENTRY * CopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
- void (GLAPIENTRY * CopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei);
- void (GLAPIENTRY * CopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
- void (GLAPIENTRY * DeleteTextures)(GLsizei, const GLuint *);
- void (GLAPIENTRY * GenTextures)(GLsizei, GLuint *);
- void (GLAPIENTRY * GetPointerv)(GLenum, GLvoid **);
- GLboolean (GLAPIENTRY * IsTexture)(GLuint);
- void (GLAPIENTRY * PrioritizeTextures)(GLsizei, const GLuint *, const GLclampf *);
- void (GLAPIENTRY * TexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *);
- void (GLAPIENTRY * TexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
- void (GLAPIENTRY * PopClientAttrib)(void);
- void (GLAPIENTRY * PushClientAttrib)(GLbitfield);
-};
-
-typedef struct __GLdispatchTableRec GLDISPATCHTABLE;
-
-typedef struct _GLCLTPROCTABLE
-{
- int cEntries;
- GLDISPATCHTABLE glDispatchTable;
-} GLCLTPROCTABLE, * PGLCLTPROCTABLE;
-
-typedef VOID (APIENTRY * PFN_SETPROCTABLE)(PGLCLTPROCTABLE);
-
-BOOL APIENTRY
-DrvCopyContext(
- DHGLRC dhrcSource,
- DHGLRC dhrcDest,
- UINT fuMask );
-
-DHGLRC APIENTRY
-DrvCreateLayerContext(
- HDC hdc,
- INT iLayerPlane );
-
-DHGLRC APIENTRY
-DrvCreateContext(
- HDC hdc );
-
-BOOL APIENTRY
-DrvDeleteContext(
- DHGLRC dhglrc );
-
-BOOL APIENTRY
-DrvDescribeLayerPlane(
- HDC hdc,
- INT iPixelFormat,
- INT iLayerPlane,
- UINT nBytes,
- LPLAYERPLANEDESCRIPTOR plpd );
-
-LONG APIENTRY
-DrvDescribePixelFormat(
- HDC hdc,
- INT iPixelFormat,
- ULONG cjpfd,
- PIXELFORMATDESCRIPTOR *ppfd );
-
-int APIENTRY
-DrvGetLayerPaletteEntries(
- HDC hdc,
- INT iLayerPlane,
- INT iStart,
- INT cEntries,
- COLORREF *pcr );
-
-PROC APIENTRY
-DrvGetProcAddress(
- LPCSTR lpszProc );
-
-BOOL APIENTRY
-DrvRealizeLayerPalette(
- HDC hdc,
- INT iLayerPlane,
- BOOL bRealize );
-
-BOOL APIENTRY
-DrvReleaseContext(
- DHGLRC dhglrc );
-
-void APIENTRY
-DrvSetCallbackProcs(
- INT nProcs,
- PROC *pProcs );
-
-PGLCLTPROCTABLE APIENTRY
-DrvSetContext(
- HDC hdc,
- DHGLRC dhglrc,
- PFN_SETPROCTABLE pfnSetProcTable );
-
-int APIENTRY
-DrvSetLayerPaletteEntries(
- HDC hdc,
- INT iLayerPlane,
- INT iStart,
- INT cEntries,
- CONST COLORREF *pcr );
-
-BOOL APIENTRY
-DrvSetPixelFormat(
- HDC hdc,
- LONG iPixelFormat );
-
-BOOL APIENTRY
-DrvShareLists(
- DHGLRC dhglrc1,
- DHGLRC dhglrc2 );
-
-BOOL APIENTRY
-DrvSwapBuffers(
- HDC hdc );
-
-BOOL APIENTRY
-DrvSwapLayerBuffers(
- HDC hdc,
- UINT fuPlanes );
-
-BOOL APIENTRY
-DrvValidateVersion(
- ULONG ulVersion );
-
-#endif /* STW_ICD_H */
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * @file
- *
- * WGL_ARB_pixel_format extension implementation.
- *
- * @sa http://www.opengl.org/registry/specs/ARB/wgl_pixel_format.txt
- */
-
-
-#include <windows.h>
-
-#define WGL_WGLEXT_PROTOTYPES
-
-#include <GL/gl.h>
-#include <GL/wglext.h>
-
-#include "pipe/p_compiler.h"
-#include "util/u_memory.h"
-#include "stw_public.h"
-#include "stw_pixelformat.h"
-
-
-static boolean
-stw_query_attrib(
- int iPixelFormat,
- int iLayerPlane,
- int attrib,
- int *pvalue )
-{
- uint count;
- uint index;
- const struct stw_pixelformat_info *pfi;
-
- count = stw_pixelformat_get_extended_count();
-
- if (attrib == WGL_NUMBER_PIXEL_FORMATS_ARB) {
- *pvalue = (int) count;
- return TRUE;
- }
-
- index = (uint) iPixelFormat - 1;
- if (index >= count)
- return FALSE;
-
- pfi = stw_pixelformat_get_info( index );
-
- switch (attrib) {
- case WGL_DRAW_TO_WINDOW_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_DRAW_TO_WINDOW ? TRUE : FALSE;
- return TRUE;
-
- case WGL_DRAW_TO_BITMAP_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_DRAW_TO_BITMAP ? TRUE : FALSE;
- return TRUE;
-
- case WGL_NEED_PALETTE_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_NEED_PALETTE ? TRUE : FALSE;
- return TRUE;
-
- case WGL_NEED_SYSTEM_PALETTE_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ? TRUE : FALSE;
- return TRUE;
-
- case WGL_SWAP_METHOD_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_SWAP_COPY ? WGL_SWAP_COPY_ARB : WGL_SWAP_UNDEFINED_ARB;
- return TRUE;
-
- case WGL_SWAP_LAYER_BUFFERS_ARB:
- *pvalue = FALSE;
- return TRUE;
-
- case WGL_NUMBER_OVERLAYS_ARB:
- *pvalue = 0;
- return TRUE;
-
- case WGL_NUMBER_UNDERLAYS_ARB:
- *pvalue = 0;
- return TRUE;
- }
-
- if (iLayerPlane != 0)
- return FALSE;
-
- switch (attrib) {
- case WGL_ACCELERATION_ARB:
- *pvalue = WGL_FULL_ACCELERATION_ARB;
- break;
-
- case WGL_TRANSPARENT_ARB:
- *pvalue = FALSE;
- break;
-
- case WGL_TRANSPARENT_RED_VALUE_ARB:
- case WGL_TRANSPARENT_GREEN_VALUE_ARB:
- case WGL_TRANSPARENT_BLUE_VALUE_ARB:
- case WGL_TRANSPARENT_ALPHA_VALUE_ARB:
- case WGL_TRANSPARENT_INDEX_VALUE_ARB:
- break;
-
- case WGL_SHARE_DEPTH_ARB:
- case WGL_SHARE_STENCIL_ARB:
- case WGL_SHARE_ACCUM_ARB:
- *pvalue = TRUE;
- break;
-
- case WGL_SUPPORT_GDI_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_SUPPORT_GDI ? TRUE : FALSE;
- break;
-
- case WGL_SUPPORT_OPENGL_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_SUPPORT_OPENGL ? TRUE : FALSE;
- break;
-
- case WGL_DOUBLE_BUFFER_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_DOUBLEBUFFER ? TRUE : FALSE;
- break;
-
- case WGL_STEREO_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_STEREO ? TRUE : FALSE;
- break;
-
- case WGL_PIXEL_TYPE_ARB:
- switch (pfi->pfd.iPixelType) {
- case PFD_TYPE_RGBA:
- *pvalue = WGL_TYPE_RGBA_ARB;
- break;
- case PFD_TYPE_COLORINDEX:
- *pvalue = WGL_TYPE_COLORINDEX_ARB;
- break;
- default:
- return FALSE;
- }
- break;
-
- case WGL_COLOR_BITS_ARB:
- *pvalue = pfi->pfd.cColorBits;
- break;
-
- case WGL_RED_BITS_ARB:
- *pvalue = pfi->pfd.cRedBits;
- break;
-
- case WGL_RED_SHIFT_ARB:
- *pvalue = pfi->pfd.cRedShift;
- break;
-
- case WGL_GREEN_BITS_ARB:
- *pvalue = pfi->pfd.cGreenBits;
- break;
-
- case WGL_GREEN_SHIFT_ARB:
- *pvalue = pfi->pfd.cGreenShift;
- break;
-
- case WGL_BLUE_BITS_ARB:
- *pvalue = pfi->pfd.cBlueBits;
- break;
-
- case WGL_BLUE_SHIFT_ARB:
- *pvalue = pfi->pfd.cBlueShift;
- break;
-
- case WGL_ALPHA_BITS_ARB:
- *pvalue = pfi->pfd.cAlphaBits;
- break;
-
- case WGL_ALPHA_SHIFT_ARB:
- *pvalue = pfi->pfd.cAlphaShift;
- break;
-
- case WGL_ACCUM_BITS_ARB:
- *pvalue = pfi->pfd.cAccumBits;
- break;
-
- case WGL_ACCUM_RED_BITS_ARB:
- *pvalue = pfi->pfd.cAccumRedBits;
- break;
-
- case WGL_ACCUM_GREEN_BITS_ARB:
- *pvalue = pfi->pfd.cAccumGreenBits;
- break;
-
- case WGL_ACCUM_BLUE_BITS_ARB:
- *pvalue = pfi->pfd.cAccumBlueBits;
- break;
-
- case WGL_ACCUM_ALPHA_BITS_ARB:
- *pvalue = pfi->pfd.cAccumAlphaBits;
- break;
-
- case WGL_DEPTH_BITS_ARB:
- *pvalue = pfi->pfd.cDepthBits;
- break;
-
- case WGL_STENCIL_BITS_ARB:
- *pvalue = pfi->pfd.cStencilBits;
- break;
-
- case WGL_AUX_BUFFERS_ARB:
- *pvalue = pfi->pfd.cAuxBuffers;
- break;
-
- case WGL_SAMPLE_BUFFERS_ARB:
- *pvalue = pfi->numSampleBuffers;
- break;
-
- case WGL_SAMPLES_ARB:
- *pvalue = pfi->numSamples;
- break;
-
- default:
- return FALSE;
- }
-
- return TRUE;
-}
-
-struct attrib_match_info
-{
- int attribute;
- int weight;
- BOOL exact;
-};
-
-static const struct attrib_match_info attrib_match[] = {
-
- /* WGL_ARB_pixel_format */
- { WGL_DRAW_TO_WINDOW_ARB, 0, TRUE },
- { WGL_DRAW_TO_BITMAP_ARB, 0, TRUE },
- { WGL_ACCELERATION_ARB, 0, TRUE },
- { WGL_NEED_PALETTE_ARB, 0, TRUE },
- { WGL_NEED_SYSTEM_PALETTE_ARB, 0, TRUE },
- { WGL_SWAP_LAYER_BUFFERS_ARB, 0, TRUE },
- { WGL_SWAP_METHOD_ARB, 0, TRUE },
- { WGL_NUMBER_OVERLAYS_ARB, 4, FALSE },
- { WGL_NUMBER_UNDERLAYS_ARB, 4, FALSE },
- /*{ WGL_SHARE_DEPTH_ARB, 0, TRUE },*/ /* no overlays -- ignore */
- /*{ WGL_SHARE_STENCIL_ARB, 0, TRUE },*/ /* no overlays -- ignore */
- /*{ WGL_SHARE_ACCUM_ARB, 0, TRUE },*/ /* no overlays -- ignore */
- { WGL_SUPPORT_GDI_ARB, 0, TRUE },
- { WGL_SUPPORT_OPENGL_ARB, 0, TRUE },
- { WGL_DOUBLE_BUFFER_ARB, 0, TRUE },
- { WGL_STEREO_ARB, 0, TRUE },
- { WGL_PIXEL_TYPE_ARB, 0, TRUE },
- { WGL_COLOR_BITS_ARB, 1, FALSE },
- { WGL_RED_BITS_ARB, 1, FALSE },
- { WGL_GREEN_BITS_ARB, 1, FALSE },
- { WGL_BLUE_BITS_ARB, 1, FALSE },
- { WGL_ALPHA_BITS_ARB, 1, FALSE },
- { WGL_ACCUM_BITS_ARB, 1, FALSE },
- { WGL_ACCUM_RED_BITS_ARB, 1, FALSE },
- { WGL_ACCUM_GREEN_BITS_ARB, 1, FALSE },
- { WGL_ACCUM_BLUE_BITS_ARB, 1, FALSE },
- { WGL_ACCUM_ALPHA_BITS_ARB, 1, FALSE },
- { WGL_DEPTH_BITS_ARB, 1, FALSE },
- { WGL_STENCIL_BITS_ARB, 1, FALSE },
- { WGL_AUX_BUFFERS_ARB, 2, FALSE },
-
- /* WGL_ARB_multisample */
- { WGL_SAMPLE_BUFFERS_ARB, 2, FALSE },
- { WGL_SAMPLES_ARB, 2, FALSE }
-};
-
-struct stw_pixelformat_score
-{
- int points;
- uint index;
-};
-
-static BOOL
-score_pixelformats(
- struct stw_pixelformat_score *scores,
- uint count,
- int attribute,
- int expected_value )
-{
- uint i;
- const struct attrib_match_info *ami = NULL;
- uint index;
-
- /* Find out if a given attribute should be considered for score calculation.
- */
- for (i = 0; i < sizeof( attrib_match ) / sizeof( attrib_match[0] ); i++) {
- if (attrib_match[i].attribute == attribute) {
- ami = &attrib_match[i];
- break;
- }
- }
- if (ami == NULL)
- return TRUE;
-
- /* Iterate all pixelformats, query the requested attribute and calculate
- * score points.
- */
- for (index = 0; index < count; index++) {
- int actual_value;
-
- if (!stw_query_attrib( index + 1, 0, attribute, &actual_value ))
- return FALSE;
-
- if (ami->exact) {
- /* For an exact match criteria, if the actual and expected values differ,
- * the score is set to 0 points, effectively removing the pixelformat
- * from a list of matching pixelformats.
- */
- if (actual_value != expected_value)
- scores[index].points = 0;
- }
- else {
- /* For a minimum match criteria, if the actual value is smaller than the expected
- * value, the pixelformat is rejected (score set to 0). However, if the actual
- * value is bigger, the pixelformat is given a penalty to favour pixelformats that
- * more closely match the expected values.
- */
- if (actual_value < expected_value)
- scores[index].points = 0;
- else if (actual_value > expected_value)
- scores[index].points -= (actual_value - expected_value) * ami->weight;
- }
- }
-
- return TRUE;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglChoosePixelFormatARB(
- HDC hdc,
- const int *piAttribIList,
- const FLOAT *pfAttribFList,
- UINT nMaxFormats,
- int *piFormats,
- UINT *nNumFormats )
-{
- uint count;
- struct stw_pixelformat_score *scores;
- uint i;
-
- *nNumFormats = 0;
-
- /* Allocate and initialize pixelformat score table -- better matches
- * have higher scores. Start with a high score and take out penalty
- * points for a mismatch when the match does not have to be exact.
- * Set a score to 0 if there is a mismatch for an exact match criteria.
- */
- count = stw_pixelformat_get_extended_count();
- scores = (struct stw_pixelformat_score *) MALLOC( count * sizeof( struct stw_pixelformat_score ) );
- if (scores == NULL)
- return FALSE;
- for (i = 0; i < count; i++) {
- scores[i].points = 0x7fffffff;
- scores[i].index = i;
- }
-
- /* Given the attribute list calculate a score for each pixelformat.
- */
- if (piAttribIList != NULL) {
- while (*piAttribIList != 0) {
- if (!score_pixelformats( scores, count, piAttribIList[0], piAttribIList[1] )) {
- FREE( scores );
- return FALSE;
- }
- piAttribIList += 2;
- }
- }
- if (pfAttribFList != NULL) {
- while (*pfAttribFList != 0) {
- if (!score_pixelformats( scores, count, (int) pfAttribFList[0], (int) pfAttribFList[1] )) {
- FREE( scores );
- return FALSE;
- }
- pfAttribFList += 2;
- }
- }
-
- /* Bubble-sort the resulting scores. Pixelformats with higher scores go first.
- * TODO: Find out if there are any patent issues with it.
- */
- if (count > 1) {
- uint n = count;
- boolean swapped;
-
- do {
- swapped = FALSE;
- for (i = 1; i < n; i++) {
- if (scores[i - 1].points < scores[i].points) {
- struct stw_pixelformat_score score = scores[i - 1];
-
- scores[i - 1] = scores[i];
- scores[i] = score;
- swapped = TRUE;
- }
- }
- n--;
- }
- while (swapped);
- }
-
- /* Return a list of pixelformats that are the best match.
- * Reject pixelformats with non-positive scores.
- */
- for (i = 0; i < count; i++) {
- if (scores[i].points > 0) {
- if (*nNumFormats < nMaxFormats)
- piFormats[*nNumFormats] = scores[i].index + 1;
- (*nNumFormats)++;
- }
- }
-
- FREE( scores );
- return TRUE;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglGetPixelFormatAttribfvARB(
- HDC hdc,
- int iPixelFormat,
- int iLayerPlane,
- UINT nAttributes,
- const int *piAttributes,
- FLOAT *pfValues )
-{
- UINT i;
-
- (void) hdc;
-
- for (i = 0; i < nAttributes; i++) {
- int value;
-
- if (!stw_query_attrib( iPixelFormat, iLayerPlane, piAttributes[i], &value ))
- return FALSE;
- pfValues[i] = (FLOAT) value;
- }
-
- return TRUE;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglGetPixelFormatAttribivARB(
- HDC hdc,
- int iPixelFormat,
- int iLayerPlane,
- UINT nAttributes,
- const int *piAttributes,
- int *piValues )
-{
- UINT i;
-
- (void) hdc;
-
- for (i = 0; i < nAttributes; i++) {
- if (!stw_query_attrib( iPixelFormat, iLayerPlane, piAttributes[i], &piValues[i] ))
- return FALSE;
- }
-
- return TRUE;
-}
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <windows.h>
-
-#include "main/mtypes.h"
-#include "main/context.h"
-#include "pipe/p_compiler.h"
-#include "pipe/p_context.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_public.h"
-
-#ifdef DEBUG
-#include "trace/tr_screen.h"
-#include "trace/tr_context.h"
-#endif
-
-#include "shared/stw_device.h"
-#include "shared/stw_winsys.h"
-#include "shared/stw_framebuffer.h"
-#include "shared/stw_pixelformat.h"
-#include "stw_public.h"
-#include "stw_context.h"
-#include "stw_tls.h"
-
-
-static INLINE struct stw_context *
-stw_context(GLcontext *glctx)
-{
- if(!glctx)
- return NULL;
- assert(glctx->DriverCtx);
- return (struct stw_context *)glctx->DriverCtx;
-}
-
-static INLINE struct stw_context *
-stw_current_context(void)
-{
- /* We must check if multiple threads are being used or GET_CURRENT_CONTEXT
- * might return the current context of the thread first seen. */
- _glapi_check_multithread();
-
- {
- GET_CURRENT_CONTEXT( glctx );
- return stw_context(glctx);
- }
-}
-
-BOOL
-stw_copy_context(
- UINT_PTR hglrcSrc,
- UINT_PTR hglrcDst,
- UINT mask )
-{
- struct stw_context *src;
- struct stw_context *dst;
- BOOL ret = FALSE;
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
-
- src = stw_lookup_context_locked( hglrcSrc );
- dst = stw_lookup_context_locked( hglrcDst );
-
- if (src && dst) {
- /* FIXME */
- assert(0);
- (void) src;
- (void) dst;
- (void) mask;
- }
-
- pipe_mutex_unlock( stw_dev->ctx_mutex );
-
- return ret;
-}
-
-BOOL
-stw_share_lists(
- UINT_PTR hglrc1,
- UINT_PTR hglrc2 )
-{
- struct stw_context *ctx1;
- struct stw_context *ctx2;
- BOOL ret = FALSE;
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
-
- ctx1 = stw_lookup_context_locked( hglrc1 );
- ctx2 = stw_lookup_context_locked( hglrc2 );
-
- if (ctx1 && ctx2 &&
- ctx1->iPixelFormat == ctx2->iPixelFormat) {
- ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx);
- }
-
- pipe_mutex_unlock( stw_dev->ctx_mutex );
-
- return ret;
-}
-
-static void
-stw_viewport(GLcontext * glctx, GLint x, GLint y,
- GLsizei width, GLsizei height)
-{
- struct stw_context *ctx = (struct stw_context *)glctx->DriverCtx;
- struct stw_framebuffer *fb;
-
- fb = stw_framebuffer_from_hdc( ctx->hdc );
- if(fb) {
- stw_framebuffer_update(fb);
- stw_framebuffer_release(fb);
- }
-}
-
-UINT_PTR
-stw_create_layer_context(
- HDC hdc,
- int iLayerPlane )
-{
- int iPixelFormat;
- const struct stw_pixelformat_info *pfi;
- GLvisual visual;
- struct stw_context *ctx = NULL;
- struct pipe_screen *screen = NULL;
- struct pipe_context *pipe = NULL;
-
- if(!stw_dev)
- return 0;
-
- if (iLayerPlane != 0)
- return 0;
-
- iPixelFormat = GetPixelFormat(hdc);
- if(!iPixelFormat)
- return 0;
-
- pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
- stw_pixelformat_visual(&visual, pfi);
-
- ctx = CALLOC_STRUCT( stw_context );
- if (ctx == NULL)
- goto no_ctx;
-
- ctx->hdc = hdc;
- ctx->iPixelFormat = iPixelFormat;
-
- screen = stw_dev->screen;
-
-#ifdef DEBUG
- /* Unwrap screen */
- if(stw_dev->trace_running)
- screen = trace_screen(screen)->screen;
-#endif
-
- pipe = stw_dev->stw_winsys->create_context( screen );
- if (pipe == NULL)
- goto no_pipe;
-
-#ifdef DEBUG
- /* Wrap context */
- if(stw_dev->trace_running)
- pipe = trace_context_create(stw_dev->screen, pipe);
-#endif
-
- /* pass to stw_flush_frontbuffer as context_private */
- assert(!pipe->priv);
- pipe->priv = hdc;
-
- ctx->st = st_create_context( pipe, &visual, NULL );
- if (ctx->st == NULL)
- goto no_st_ctx;
-
- ctx->st->ctx->DriverCtx = ctx;
- ctx->st->ctx->Driver.Viewport = stw_viewport;
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
- ctx->hglrc = handle_table_add(stw_dev->ctx_table, ctx);
- pipe_mutex_unlock( stw_dev->ctx_mutex );
- if (!ctx->hglrc)
- goto no_hglrc;
-
- return ctx->hglrc;
-
-no_hglrc:
- st_destroy_context(ctx->st);
- goto no_pipe; /* st_context_destroy already destroys pipe */
-no_st_ctx:
- pipe->destroy( pipe );
-no_pipe:
- FREE(ctx);
-no_ctx:
- return 0;
-}
-
-BOOL
-stw_delete_context(
- UINT_PTR hglrc )
-{
- struct stw_context *ctx ;
- BOOL ret = FALSE;
-
- if (!stw_dev)
- return FALSE;
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
- ctx = stw_lookup_context_locked(hglrc);
- handle_table_remove(stw_dev->ctx_table, hglrc);
- pipe_mutex_unlock( stw_dev->ctx_mutex );
-
- if (ctx) {
- struct stw_context *curctx = stw_current_context();
-
- /* Unbind current if deleting current context. */
- if (curctx == ctx)
- st_make_current( NULL, NULL, NULL );
-
- st_destroy_context(ctx->st);
- FREE(ctx);
-
- ret = TRUE;
- }
-
- return ret;
-}
-
-BOOL
-stw_release_context(
- UINT_PTR hglrc )
-{
- struct stw_context *ctx;
-
- if (!stw_dev)
- return FALSE;
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
- ctx = stw_lookup_context_locked( hglrc );
- pipe_mutex_unlock( stw_dev->ctx_mutex );
-
- if (!ctx)
- return FALSE;
-
- /* The expectation is that ctx is the same context which is
- * current for this thread. We should check that and return False
- * if not the case.
- */
- if (ctx != stw_current_context())
- return FALSE;
-
- if (stw_make_current( NULL, 0 ) == FALSE)
- return FALSE;
-
- return TRUE;
-}
-
-
-UINT_PTR
-stw_get_current_context( void )
-{
- struct stw_context *ctx;
-
- ctx = stw_current_context();
- if(!ctx)
- return 0;
-
- return ctx->hglrc;
-}
-
-HDC
-stw_get_current_dc( void )
-{
- struct stw_context *ctx;
-
- ctx = stw_current_context();
- if(!ctx)
- return NULL;
-
- return ctx->hdc;
-}
-
-BOOL
-stw_make_current(
- HDC hdc,
- UINT_PTR hglrc )
-{
- struct stw_context *curctx = NULL;
- struct stw_context *ctx = NULL;
- struct stw_framebuffer *fb = NULL;
-
- if (!stw_dev)
- goto fail;
-
- curctx = stw_current_context();
- if (curctx != NULL) {
- if (curctx->hglrc != hglrc)
- st_flush(curctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
-
- /* Return if already current. */
- if (curctx->hglrc == hglrc && curctx->hdc == hdc) {
- ctx = curctx;
- fb = stw_framebuffer_from_hdc( hdc );
- goto success;
- }
- }
-
- if (hdc == NULL || hglrc == 0) {
- return st_make_current( NULL, NULL, NULL );
- }
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
- ctx = stw_lookup_context_locked( hglrc );
- pipe_mutex_unlock( stw_dev->ctx_mutex );
- if(!ctx)
- goto fail;
-
- fb = stw_framebuffer_from_hdc( hdc );
- if(!fb) {
- /* Applications should call SetPixelFormat before creating a context,
- * but not all do, and the opengl32 runtime seems to use a default pixel
- * format in some cases, so we must create a framebuffer for those here
- */
- int iPixelFormat = GetPixelFormat(hdc);
- if(iPixelFormat)
- fb = stw_framebuffer_create( hdc, iPixelFormat );
- if(!fb)
- goto fail;
- }
-
- if(fb->iPixelFormat != ctx->iPixelFormat)
- goto fail;
-
- /* Lazy allocation of the frame buffer */
- if(!stw_framebuffer_allocate(fb))
- goto fail;
-
- /* Bind the new framebuffer */
- ctx->hdc = hdc;
-
- /* pass to stw_flush_frontbuffer as context_private */
- ctx->st->pipe->priv = hdc;
-
- if(!st_make_current( ctx->st, fb->stfb, fb->stfb ))
- goto fail;
-
-success:
- assert(fb);
- if(fb) {
- stw_framebuffer_update(fb);
- stw_framebuffer_release(fb);
- }
-
- return TRUE;
-
-fail:
- if(fb)
- stw_framebuffer_release(fb);
- st_make_current( NULL, NULL, NULL );
- return FALSE;
-}
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef STW_CONTEXT_H
-#define STW_CONTEXT_H
-
-#include <windows.h>
-
-struct st_context;
-
-struct stw_context
-{
- struct st_context *st;
- UINT_PTR hglrc;
- int iPixelFormat;
- HDC hdc;
-};
-
-#endif /* STW_CONTEXT_H */
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <windows.h>
-
-#include "glapi/glthread.h"
-#include "util/u_debug.h"
-#include "pipe/p_screen.h"
-#include "state_tracker/st_public.h"
-
-#ifdef DEBUG
-#include "trace/tr_screen.h"
-#include "trace/tr_texture.h"
-#endif
-
-#include "shared/stw_device.h"
-#include "shared/stw_winsys.h"
-#include "shared/stw_pixelformat.h"
-#include "shared/stw_public.h"
-#include "shared/stw_tls.h"
-#include "shared/stw_framebuffer.h"
-
-#ifdef WIN32_THREADS
-extern _glthread_Mutex OneTimeLock;
-extern void FreeAllTSD(void);
-#endif
-
-
-struct stw_device *stw_dev = NULL;
-
-
-/**
- * XXX: Dispatch pipe_screen::flush_front_buffer to our
- * stw_winsys::flush_front_buffer.
- */
-static void
-stw_flush_frontbuffer(struct pipe_screen *screen,
- struct pipe_surface *surface,
- void *context_private )
-{
- const struct stw_winsys *stw_winsys = stw_dev->stw_winsys;
- HDC hdc = (HDC)context_private;
- struct stw_framebuffer *fb;
-
- fb = stw_framebuffer_from_hdc( hdc );
- /* fb can be NULL if window was destroyed already */
- if (fb) {
-#if DEBUG
- {
- struct pipe_surface *surface2;
-
- if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 ))
- assert(0);
- else
- assert(surface2 == surface);
- }
-#endif
-
-#ifdef DEBUG
- if(stw_dev->trace_running) {
- screen = trace_screen(screen)->screen;
- surface = trace_surface(surface)->surface;
- }
-#endif
- }
-
- stw_winsys->flush_frontbuffer(screen, surface, hdc);
-
- if(fb) {
- stw_framebuffer_update(fb);
- stw_framebuffer_release(fb);
- }
-}
-
-
-boolean
-stw_init(const struct stw_winsys *stw_winsys)
-{
- static struct stw_device stw_dev_storage;
- struct pipe_screen *screen;
-
- debug_printf("%s\n", __FUNCTION__);
-
- assert(!stw_dev);
-
- stw_tls_init();
-
- stw_dev = &stw_dev_storage;
- memset(stw_dev, 0, sizeof(*stw_dev));
-
-#ifdef DEBUG
- stw_dev->memdbg_no = debug_memory_begin();
-#endif
-
- stw_dev->stw_winsys = stw_winsys;
-
-#ifdef WIN32_THREADS
- _glthread_INIT_MUTEX(OneTimeLock);
-#endif
-
- screen = stw_winsys->create_screen();
- if(!screen)
- goto error1;
-
-#ifdef DEBUG
- stw_dev->screen = trace_screen_create(screen);
- stw_dev->trace_running = stw_dev->screen != screen ? TRUE : FALSE;
-#else
- stw_dev->screen = screen;
-#endif
-
- stw_dev->screen->flush_frontbuffer = &stw_flush_frontbuffer;
-
- pipe_mutex_init( stw_dev->ctx_mutex );
- pipe_mutex_init( stw_dev->fb_mutex );
-
- stw_dev->ctx_table = handle_table_create();
- if (!stw_dev->ctx_table) {
- goto error1;
- }
-
- stw_pixelformat_init();
-
- return TRUE;
-
-error1:
- stw_dev = NULL;
- return FALSE;
-}
-
-
-boolean
-stw_init_thread(void)
-{
- return stw_tls_init_thread();
-}
-
-
-void
-stw_cleanup_thread(void)
-{
- stw_tls_cleanup_thread();
-}
-
-
-void
-stw_cleanup(void)
-{
- unsigned i;
-
- debug_printf("%s\n", __FUNCTION__);
-
- if (!stw_dev)
- return;
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
- {
- /* Ensure all contexts are destroyed */
- i = handle_table_get_first_handle(stw_dev->ctx_table);
- while (i) {
- stw_delete_context(i);
- i = handle_table_get_next_handle(stw_dev->ctx_table, i);
- }
- handle_table_destroy(stw_dev->ctx_table);
- }
- pipe_mutex_unlock( stw_dev->ctx_mutex );
-
- stw_framebuffer_cleanup();
-
- pipe_mutex_destroy( stw_dev->fb_mutex );
- pipe_mutex_destroy( stw_dev->ctx_mutex );
-
- stw_dev->screen->destroy(stw_dev->screen);
-
-#ifdef WIN32_THREADS
- _glthread_DESTROY_MUTEX(OneTimeLock);
- FreeAllTSD();
-#endif
-
-#ifdef DEBUG
- debug_memory_end(stw_dev->memdbg_no);
-#endif
-
- stw_tls_cleanup();
-
- stw_dev = NULL;
-}
-
-
-struct stw_context *
-stw_lookup_context_locked( UINT_PTR dhglrc )
-{
- if (dhglrc == 0)
- return NULL;
-
- if (stw_dev == NULL)
- return NULL;
-
- return (struct stw_context *) handle_table_get(stw_dev->ctx_table, dhglrc);
-}
-
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef STW_DEVICE_H_
-#define STW_DEVICE_H_
-
-
-#include <windows.h>
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_thread.h"
-#include "util/u_handle_table.h"
-#include "stw_pixelformat.h"
-
-
-#define STW_MAX_PIXELFORMATS 256
-
-
-struct pipe_screen;
-struct stw_framebuffer;
-
-struct stw_device
-{
- const struct stw_winsys *stw_winsys;
-
- struct pipe_screen *screen;
-
-#ifdef DEBUG
- boolean trace_running;
-#endif
-
- struct stw_pixelformat_info pixelformats[STW_MAX_PIXELFORMATS];
- unsigned pixelformat_count;
- unsigned pixelformat_extended_count;
-
- pipe_mutex ctx_mutex;
- struct handle_table *ctx_table;
-
- pipe_mutex fb_mutex;
- struct stw_framebuffer *fb_head;
-
-#ifdef DEBUG
- unsigned long memdbg_no;
-#endif
-};
-
-struct stw_context *
-stw_lookup_context_locked( UINT_PTR hglrc );
-
-extern struct stw_device *stw_dev;
-
-
-#endif /* STW_DEVICE_H_ */
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <windows.h>
-
-#define WGL_WGLEXT_PROTOTYPES
-
-#include <GL/gl.h>
-#include <GL/wglext.h>
-
-
-static const char *stw_extension_string =
- "WGL_ARB_extensions_string "
- "WGL_ARB_multisample "
- "WGL_ARB_pixel_format "
-/* "WGL_EXT_swap_interval " */
- "WGL_EXT_extensions_string";
-
-
-WINGDIAPI const char * APIENTRY
-wglGetExtensionsStringARB(
- HDC hdc )
-{
- (void) hdc;
-
- return stw_extension_string;
-}
-
-
-WINGDIAPI const char * APIENTRY
-wglGetExtensionsStringEXT( void )
-{
- return stw_extension_string;
-}
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "pipe/p_screen.h"
-#include "stw_public.h"
-#include "stw_device.h"
-#include "stw_winsys.h"
-
-#ifdef DEBUG
-#include "trace/tr_screen.h"
-#include "trace/tr_context.h"
-#endif
-
-
-struct pipe_screen * APIENTRY
-wglGetGalliumScreenMESA(void)
-{
- return stw_dev ? stw_dev->screen : NULL;
-}
-
-
-/* XXX: Unify with stw_create_layer_context */
-struct pipe_context * APIENTRY
-wglCreateGalliumContextMESA(void)
-{
- struct pipe_screen *screen = NULL;
- struct pipe_context *pipe = NULL;
-
- if(!stw_dev)
- return NULL;
-
- screen = stw_dev->screen;
-
-#ifdef DEBUG
- /* Unwrap screen */
- if(stw_dev->trace_running)
- screen = trace_screen(screen)->screen;
-#endif
-
- pipe = stw_dev->stw_winsys->create_context( screen );
- if (pipe == NULL)
- goto no_pipe;
-
-#ifdef DEBUG
- /* Wrap context */
- if(stw_dev->trace_running)
- pipe = trace_context_create(stw_dev->screen, pipe);
-#endif
-
- return pipe;
-
-no_pipe:
- return NULL;
-}
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef STW_EXTGALLIUM_H_
-#define STW_EXTGALLIUM_H_
-
-
-#include <windows.h>
-
-
-struct pipe_screen;
-struct pipe_context;
-
-
-struct pipe_screen * APIENTRY
-wglGetGalliumScreenMESA(void);
-
-
-struct pipe_context * APIENTRY
-wglCreateGalliumContextMESA(void);
-
-
-#endif /* STW_EXTGALLIUM_H_ */
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <windows.h>
-
-#define WGL_WGLEXT_PROTOTYPES
-
-#include <GL/gl.h>
-#include <GL/wglext.h>
-#include "util/u_debug.h"
-
-/* A dummy implementation of this extension.
- *
- * Required as some applications retrieve and call these functions
- * regardless of the fact that we don't advertise the extension and
- * further more the results of wglGetProcAddress are NULL.
- */
-WINGDIAPI BOOL APIENTRY
-wglSwapIntervalEXT(int interval)
-{
- (void) interval;
- debug_printf("%s: %d\n", __FUNCTION__, interval);
- return TRUE;
-}
-
-WINGDIAPI int APIENTRY
-wglGetSwapIntervalEXT(void)
-{
- return 0;
-}
-
-
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <windows.h>
-
-#include "main/context.h"
-#include "pipe/p_format.h"
-#include "pipe/p_screen.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_public.h"
-
-#ifdef DEBUG
-#include "trace/tr_screen.h"
-#include "trace/tr_texture.h"
-#endif
-
-#include "stw_framebuffer.h"
-#include "stw_device.h"
-#include "stw_public.h"
-#include "stw_winsys.h"
-#include "stw_tls.h"
-
-
-/**
- * Search the framebuffer with the matching HWND while holding the
- * stw_dev::fb_mutex global lock.
- */
-static INLINE struct stw_framebuffer *
-stw_framebuffer_from_hwnd_locked(
- HWND hwnd )
-{
- struct stw_framebuffer *fb;
-
- for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
- if (fb->hWnd == hwnd) {
- pipe_mutex_lock(fb->mutex);
- break;
- }
-
- return fb;
-}
-
-
-/**
- * Destroy this framebuffer. Both stw_dev::fb_mutex and stw_framebuffer::mutex
- * must be held, by this order. Obviously no further access to fb can be done
- * after this.
- */
-static INLINE void
-stw_framebuffer_destroy_locked(
- struct stw_framebuffer *fb )
-{
- struct stw_framebuffer **link;
-
- link = &stw_dev->fb_head;
- while (*link != fb)
- link = &(*link)->next;
- assert(*link);
- *link = fb->next;
- fb->next = NULL;
-
- st_unreference_framebuffer(fb->stfb);
-
- pipe_mutex_unlock( fb->mutex );
-
- pipe_mutex_destroy( fb->mutex );
-
- FREE( fb );
-}
-
-
-void
-stw_framebuffer_release(
- struct stw_framebuffer *fb)
-{
- assert(fb);
- pipe_mutex_unlock( fb->mutex );
-}
-
-
-static INLINE void
-stw_framebuffer_get_size( struct stw_framebuffer *fb )
-{
- unsigned width, height;
- RECT rect;
-
- assert(fb->hWnd);
-
- GetClientRect( fb->hWnd, &rect );
- width = rect.right - rect.left;
- height = rect.bottom - rect.top;
-
- if(width < 1)
- width = 1;
- if(height < 1)
- height = 1;
-
- if(width != fb->width || height != fb->height) {
- fb->must_resize = TRUE;
- fb->width = width;
- fb->height = height;
- }
-}
-
-
-/**
- * @sa http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx
- * @sa http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx
- */
-LRESULT CALLBACK
-stw_call_window_proc(
- int nCode,
- WPARAM wParam,
- LPARAM lParam )
-{
- struct stw_tls_data *tls_data;
- PCWPSTRUCT pParams = (PCWPSTRUCT)lParam;
- struct stw_framebuffer *fb;
-
- tls_data = stw_tls_get_data();
- if(!tls_data)
- return 0;
-
- if (nCode < 0)
- return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam);
-
- if (pParams->message == WM_WINDOWPOSCHANGED) {
- /* We handle WM_WINDOWPOSCHANGED instead of WM_SIZE because according to
- * http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx
- * WM_SIZE is generated from WM_WINDOWPOSCHANGED by DefWindowProc so it
- * can be masked out by the application. */
- LPWINDOWPOS lpWindowPos = (LPWINDOWPOS)pParams->lParam;
- if((lpWindowPos->flags & SWP_SHOWWINDOW) ||
- !(lpWindowPos->flags & SWP_NOSIZE)) {
- fb = stw_framebuffer_from_hwnd( pParams->hwnd );
- if(fb) {
- /* Size in WINDOWPOS includes the window frame, so get the size
- * of the client area via GetClientRect. */
- stw_framebuffer_get_size(fb);
- stw_framebuffer_release(fb);
- }
- }
- }
- else if (pParams->message == WM_DESTROY) {
- pipe_mutex_lock( stw_dev->fb_mutex );
- fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd );
- if(fb)
- stw_framebuffer_destroy_locked(fb);
- pipe_mutex_unlock( stw_dev->fb_mutex );
- }
-
- return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam);
-}
-
-
-struct stw_framebuffer *
-stw_framebuffer_create(
- HDC hdc,
- int iPixelFormat )
-{
- HWND hWnd;
- struct stw_framebuffer *fb;
- const struct stw_pixelformat_info *pfi;
-
- /* We only support drawing to a window. */
- hWnd = WindowFromDC( hdc );
- if(!hWnd)
- return NULL;
-
- fb = CALLOC_STRUCT( stw_framebuffer );
- if (fb == NULL)
- return NULL;
-
- fb->hDC = hdc;
- fb->hWnd = hWnd;
- fb->iPixelFormat = iPixelFormat;
-
- fb->pfi = pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
-
- stw_pixelformat_visual(&fb->visual, pfi);
-
- stw_framebuffer_get_size(fb);
-
- pipe_mutex_init( fb->mutex );
-
- /* This is the only case where we lock the stw_framebuffer::mutex before
- * stw_dev::fb_mutex, since no other thread can know about this framebuffer
- * and we must prevent any other thread from destroying it before we return.
- */
- pipe_mutex_lock( fb->mutex );
-
- pipe_mutex_lock( stw_dev->fb_mutex );
- fb->next = stw_dev->fb_head;
- stw_dev->fb_head = fb;
- pipe_mutex_unlock( stw_dev->fb_mutex );
-
- return fb;
-}
-
-
-BOOL
-stw_framebuffer_allocate(
- struct stw_framebuffer *fb)
-{
- assert(fb);
-
- if(!fb->stfb) {
- const struct stw_pixelformat_info *pfi = fb->pfi;
- enum pipe_format colorFormat, depthFormat, stencilFormat;
-
- colorFormat = pfi->color_format;
-
- assert(pf_layout( pfi->depth_stencil_format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
-
- if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_Z ))
- depthFormat = pfi->depth_stencil_format;
- else
- depthFormat = PIPE_FORMAT_NONE;
-
- if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_S ))
- stencilFormat = pfi->depth_stencil_format;
- else
- stencilFormat = PIPE_FORMAT_NONE;
-
- assert(fb->must_resize);
- assert(fb->width);
- assert(fb->height);
-
- fb->stfb = st_create_framebuffer(
- &fb->visual,
- colorFormat,
- depthFormat,
- stencilFormat,
- fb->width,
- fb->height,
- (void *) fb );
-
- // to notify the context
- fb->must_resize = TRUE;
- }
-
- return fb->stfb ? TRUE : FALSE;
-}
-
-
-/**
- * Update the framebuffer's size if necessary.
- */
-void
-stw_framebuffer_update(
- struct stw_framebuffer *fb)
-{
- assert(fb->stfb);
- assert(fb->height);
- assert(fb->width);
-
- /* XXX: It would be nice to avoid checking the size again -- in theory
- * stw_call_window_proc would have cought the resize and stored the right
- * size already, but unfortunately threads created before the DllMain is
- * called don't get a DLL_THREAD_ATTACH notification, and there is no way
- * to know of their existing without using the not very portable PSAPI.
- */
- stw_framebuffer_get_size(fb);
-
- if(fb->must_resize) {
- st_resize_framebuffer(fb->stfb, fb->width, fb->height);
- fb->must_resize = FALSE;
- }
-}
-
-
-void
-stw_framebuffer_cleanup( void )
-{
- struct stw_framebuffer *fb;
- struct stw_framebuffer *next;
-
- pipe_mutex_lock( stw_dev->fb_mutex );
-
- fb = stw_dev->fb_head;
- while (fb) {
- next = fb->next;
-
- pipe_mutex_lock(fb->mutex);
- stw_framebuffer_destroy_locked(fb);
-
- fb = next;
- }
- stw_dev->fb_head = NULL;
-
- pipe_mutex_unlock( stw_dev->fb_mutex );
-}
-
-
-/**
- * Given an hdc, return the corresponding stw_framebuffer.
- */
-static INLINE struct stw_framebuffer *
-stw_framebuffer_from_hdc_locked(
- HDC hdc )
-{
- HWND hwnd;
- struct stw_framebuffer *fb;
-
- /*
- * Some applications create and use several HDCs for the same window, so
- * looking up the framebuffer by the HDC is not reliable. Use HWND whenever
- * possible.
- */
- hwnd = WindowFromDC(hdc);
- if(hwnd)
- return stw_framebuffer_from_hwnd_locked(hwnd);
-
- for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
- if (fb->hDC == hdc) {
- pipe_mutex_lock(fb->mutex);
- break;
- }
-
- return fb;
-}
-
-
-/**
- * Given an hdc, return the corresponding stw_framebuffer.
- */
-struct stw_framebuffer *
-stw_framebuffer_from_hdc(
- HDC hdc )
-{
- struct stw_framebuffer *fb;
-
- pipe_mutex_lock( stw_dev->fb_mutex );
- fb = stw_framebuffer_from_hdc_locked(hdc);
- pipe_mutex_unlock( stw_dev->fb_mutex );
-
- return fb;
-}
-
-
-/**
- * Given an hdc, return the corresponding stw_framebuffer.
- */
-struct stw_framebuffer *
-stw_framebuffer_from_hwnd(
- HWND hwnd )
-{
- struct stw_framebuffer *fb;
-
- pipe_mutex_lock( stw_dev->fb_mutex );
- fb = stw_framebuffer_from_hwnd_locked(hwnd);
- pipe_mutex_unlock( stw_dev->fb_mutex );
-
- return fb;
-}
-
-
-BOOL
-stw_pixelformat_set(
- HDC hdc,
- int iPixelFormat )
-{
- uint count;
- uint index;
- struct stw_framebuffer *fb;
-
- index = (uint) iPixelFormat - 1;
- count = stw_pixelformat_get_extended_count();
- if (index >= count)
- return FALSE;
-
- fb = stw_framebuffer_from_hdc_locked(hdc);
- if(fb) {
- /* SetPixelFormat must be called only once */
- stw_framebuffer_release( fb );
- return FALSE;
- }
-
- fb = stw_framebuffer_create(hdc, iPixelFormat);
- if(!fb) {
- return FALSE;
- }
-
- stw_framebuffer_release( fb );
-
- /* Some applications mistakenly use the undocumented wglSetPixelFormat
- * function instead of SetPixelFormat, so we call SetPixelFormat here to
- * avoid opengl32.dll's wglCreateContext to fail */
- if (GetPixelFormat(hdc) == 0) {
- SetPixelFormat(hdc, iPixelFormat, NULL);
- }
-
- return TRUE;
-}
-
-
-int
-stw_pixelformat_get(
- HDC hdc )
-{
- int iPixelFormat = 0;
- struct stw_framebuffer *fb;
-
- fb = stw_framebuffer_from_hdc(hdc);
- if(fb) {
- iPixelFormat = fb->iPixelFormat;
- stw_framebuffer_release(fb);
- }
-
- return iPixelFormat;
-}
-
-
-BOOL
-stw_swap_buffers(
- HDC hdc )
-{
- struct stw_framebuffer *fb;
- struct pipe_screen *screen;
- struct pipe_surface *surface;
-
- fb = stw_framebuffer_from_hdc( hdc );
- if (fb == NULL)
- return FALSE;
-
- if (!(fb->pfi->pfd.dwFlags & PFD_DOUBLEBUFFER)) {
- stw_framebuffer_release(fb);
- return TRUE;
- }
-
- /* If we're swapping the buffer associated with the current context
- * we have to flush any pending rendering commands first.
- */
- st_notify_swapbuffers( fb->stfb );
-
- screen = stw_dev->screen;
-
- if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surface )) {
- /* FIXME: this shouldn't happen, but does on glean */
- stw_framebuffer_release(fb);
- return FALSE;
- }
-
-#ifdef DEBUG
- if(stw_dev->trace_running) {
- screen = trace_screen(screen)->screen;
- surface = trace_surface(surface)->surface;
- }
-#endif
-
- stw_dev->stw_winsys->flush_frontbuffer( screen, surface, hdc );
-
- stw_framebuffer_update(fb);
- stw_framebuffer_release(fb);
-
- return TRUE;
-}
-
-
-BOOL
-stw_swap_layer_buffers(
- HDC hdc,
- UINT fuPlanes )
-{
- if(fuPlanes & WGL_SWAP_MAIN_PLANE)
- return stw_swap_buffers(hdc);
-
- return FALSE;
-}
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef STW_FRAMEBUFFER_H
-#define STW_FRAMEBUFFER_H
-
-#include <windows.h>
-
-#include "main/mtypes.h"
-
-#include "pipe/p_thread.h"
-
-struct stw_pixelformat_info;
-
-/**
- * Windows framebuffer, derived from gl_framebuffer.
- */
-struct stw_framebuffer
-{
- /**
- * This mutex has two purposes:
- * - protect the access to the mutable data members below
- * - prevent the the framebuffer from being deleted while being accessed.
- *
- * It is OK to lock this mutex while holding the stw_device::fb_mutex lock,
- * but the opposite must never happen.
- */
- pipe_mutex mutex;
-
- /*
- * Immutable members.
- *
- * Note that even access to immutable members implies acquiring the mutex
- * above, to prevent the framebuffer from being destroyed.
- */
-
- HDC hDC;
- HWND hWnd;
-
- int iPixelFormat;
- const struct stw_pixelformat_info *pfi;
- GLvisual visual;
-
- /*
- * Mutable members.
- */
-
- struct st_framebuffer *stfb;
-
- /* FIXME: Make this work for multiple contexts bound to the same framebuffer */
- boolean must_resize;
- unsigned width;
- unsigned height;
-
- /**
- * This is protected by stw_device::fb_mutex, not the mutex above.
- *
- * Deletions must be done by first acquiring stw_device::fb_mutex, and then
- * acquiring the stw_framebuffer::mutex of the framebuffer to be deleted.
- * This ensures that nobody else is reading/writing to the.
- *
- * It is not necessary to aquire the mutex above to navigate the linked list
- * given that deletions are done with stw_device::fb_mutex held, so no other
- * thread can delete.
- */
- struct stw_framebuffer *next;
-};
-
-
-/**
- * Create a new framebuffer object which will correspond to the given HDC.
- *
- * This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
- * must be called when done
- */
-struct stw_framebuffer *
-stw_framebuffer_create(
- HDC hdc,
- int iPixelFormat );
-
-/**
- * Search a framebuffer with a matching HWND.
- *
- * This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
- * must be called when done
- */
-struct stw_framebuffer *
-stw_framebuffer_from_hwnd(
- HWND hwnd );
-
-/**
- * Search a framebuffer with a matching HDC.
- *
- * This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
- * must be called when done
- */
-struct stw_framebuffer *
-stw_framebuffer_from_hdc(
- HDC hdc );
-
-BOOL
-stw_framebuffer_allocate(
- struct stw_framebuffer *fb );
-
-void
-stw_framebuffer_update(
- struct stw_framebuffer *fb);
-
-/**
- * Release stw_framebuffer::mutex lock. This framebuffer must not be accessed
- * after calling this function, as it may have been deleted by another thread
- * in the meanwhile.
- */
-void
-stw_framebuffer_release(
- struct stw_framebuffer *fb);
-
-/**
- * Cleanup any existing framebuffers when exiting application.
- */
-void
-stw_framebuffer_cleanup(void);
-
-#endif /* STW_FRAMEBUFFER_H */
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <windows.h>
-
-#define WGL_WGLEXT_PROTOTYPES
-
-#include <GL/gl.h>
-#include <GL/wglext.h>
-
-#include "glapi/glapi.h"
-#include "stw_public.h"
-#include "stw_extgallium.h"
-
-struct stw_extension_entry
-{
- const char *name;
- PROC proc;
-};
-
-#define STW_EXTENSION_ENTRY(P) { #P, (PROC) P }
-
-static const struct stw_extension_entry stw_extension_entries[] = {
-
- /* WGL_ARB_extensions_string */
- STW_EXTENSION_ENTRY( wglGetExtensionsStringARB ),
-
- /* WGL_ARB_pixel_format */
- STW_EXTENSION_ENTRY( wglChoosePixelFormatARB ),
- STW_EXTENSION_ENTRY( wglGetPixelFormatAttribfvARB ),
- STW_EXTENSION_ENTRY( wglGetPixelFormatAttribivARB ),
-
- /* WGL_EXT_extensions_string */
- STW_EXTENSION_ENTRY( wglGetExtensionsStringEXT ),
-
- /* WGL_EXT_swap_interval */
- STW_EXTENSION_ENTRY( wglGetSwapIntervalEXT ),
- STW_EXTENSION_ENTRY( wglSwapIntervalEXT ),
-
- /* WGL_EXT_gallium ? */
- STW_EXTENSION_ENTRY( wglGetGalliumScreenMESA ),
- STW_EXTENSION_ENTRY( wglCreateGalliumContextMESA ),
-
- { NULL, NULL }
-};
-
-PROC
-stw_get_proc_address(
- LPCSTR lpszProc )
-{
- const struct stw_extension_entry *entry;
-
- if (lpszProc[0] == 'w' && lpszProc[1] == 'g' && lpszProc[2] == 'l')
- for (entry = stw_extension_entries; entry->name; entry++)
- if (strcmp( lpszProc, entry->name ) == 0)
- return entry->proc;
-
- if (lpszProc[0] == 'g' && lpszProc[1] == 'l')
- return (PROC) _glapi_get_proc_address( lpszProc );
-
- return NULL;
-}
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "main/mtypes.h"
-#include "main/context.h"
-
-#include "pipe/p_format.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_screen.h"
-
-#include "util/u_debug.h"
-
-#include "stw_device.h"
-#include "stw_pixelformat.h"
-#include "stw_public.h"
-#include "stw_tls.h"
-
-
-struct stw_pf_color_info
-{
- enum pipe_format format;
- struct {
- unsigned char red;
- unsigned char green;
- unsigned char blue;
- unsigned char alpha;
- } bits;
- struct {
- unsigned char red;
- unsigned char green;
- unsigned char blue;
- unsigned char alpha;
- } shift;
-};
-
-struct stw_pf_depth_info
-{
- enum pipe_format format;
- struct {
- unsigned char depth;
- unsigned char stencil;
- } bits;
-};
-
-
-/* NOTE: order matters, since in otherwise equal circumstances the first
- * format listed will get chosen */
-
-static const struct stw_pf_color_info
-stw_pf_color[] = {
- /* no-alpha */
- { PIPE_FORMAT_X8R8G8B8_UNORM, { 8, 8, 8, 0}, {16, 8, 0, 0} },
- { PIPE_FORMAT_B8G8R8X8_UNORM, { 8, 8, 8, 0}, { 8, 16, 24, 0} },
- { PIPE_FORMAT_R5G6B5_UNORM, { 5, 6, 5, 0}, {11, 5, 0, 0} },
- /* alpha */
- { PIPE_FORMAT_A8R8G8B8_UNORM, { 8, 8, 8, 8}, {16, 8, 0, 24} },
- { PIPE_FORMAT_B8G8R8A8_UNORM, { 8, 8, 8, 8}, { 8, 16, 24, 0} },
-#if 0
- { PIPE_FORMAT_A2B10G10R10_UNORM, {10, 10, 10, 2}, { 0, 10, 20, 30} },
-#endif
- { PIPE_FORMAT_A1R5G5B5_UNORM, { 5, 5, 5, 1}, {10, 5, 0, 15} },
- { PIPE_FORMAT_A4R4G4B4_UNORM, { 4, 4, 4, 4}, {16, 4, 0, 12} }
-};
-
-
-static const struct stw_pf_depth_info
-stw_pf_depth_stencil[] = {
- /* pure depth */
- { PIPE_FORMAT_Z32_UNORM, {32, 0} },
- { PIPE_FORMAT_Z24X8_UNORM, {24, 0} },
- { PIPE_FORMAT_X8Z24_UNORM, {24, 0} },
- { PIPE_FORMAT_Z16_UNORM, {16, 0} },
- /* pure stencil */
- { PIPE_FORMAT_S8_UNORM, { 0, 8} },
- /* combined depth-stencil */
- { PIPE_FORMAT_S8Z24_UNORM, {24, 8} },
- { PIPE_FORMAT_Z24S8_UNORM, {24, 8} }
-};
-
-
-static const boolean
-stw_pf_doublebuffer[] = {
- FALSE,
- TRUE,
-};
-
-
-const unsigned
-stw_pf_multisample[] = {
- 0,
- 4
-};
-
-
-static void
-stw_pixelformat_add(
- struct stw_device *stw_dev,
- const struct stw_pf_color_info *color,
- const struct stw_pf_depth_info *depth,
- unsigned accum,
- boolean doublebuffer,
- unsigned samples )
-{
- boolean extended = FALSE;
- struct stw_pixelformat_info *pfi;
-
- assert(stw_dev->pixelformat_extended_count < STW_MAX_PIXELFORMATS);
- if(stw_dev->pixelformat_extended_count >= STW_MAX_PIXELFORMATS)
- return;
-
- assert(pf_layout( color->format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
- assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_R ) == color->bits.red );
- assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_G ) == color->bits.green );
- assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_B ) == color->bits.blue );
- assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_A ) == color->bits.alpha );
- assert(pf_layout( depth->format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
- assert(pf_get_component_bits( depth->format, PIPE_FORMAT_COMP_Z ) == depth->bits.depth );
- assert(pf_get_component_bits( depth->format, PIPE_FORMAT_COMP_S ) == depth->bits.stencil );
-
- pfi = &stw_dev->pixelformats[stw_dev->pixelformat_extended_count];
-
- memset(pfi, 0, sizeof *pfi);
-
- pfi->color_format = color->format;
- pfi->depth_stencil_format = depth->format;
-
- pfi->pfd.nSize = sizeof pfi->pfd;
- pfi->pfd.nVersion = 1;
-
- pfi->pfd.dwFlags = PFD_SUPPORT_OPENGL;
-
- /* TODO: also support non-native pixel formats */
- pfi->pfd.dwFlags |= PFD_DRAW_TO_WINDOW ;
-
- if (doublebuffer)
- pfi->pfd.dwFlags |= PFD_DOUBLEBUFFER | PFD_SWAP_COPY;
-
- pfi->pfd.iPixelType = PFD_TYPE_RGBA;
-
- pfi->pfd.cColorBits = color->bits.red + color->bits.green + color->bits.blue + color->bits.alpha;
- pfi->pfd.cRedBits = color->bits.red;
- pfi->pfd.cRedShift = color->shift.red;
- pfi->pfd.cGreenBits = color->bits.green;
- pfi->pfd.cGreenShift = color->shift.green;
- pfi->pfd.cBlueBits = color->bits.blue;
- pfi->pfd.cBlueShift = color->shift.blue;
- pfi->pfd.cAlphaBits = color->bits.alpha;
- pfi->pfd.cAlphaShift = color->shift.alpha;
- pfi->pfd.cAccumBits = 4*accum;
- pfi->pfd.cAccumRedBits = accum;
- pfi->pfd.cAccumGreenBits = accum;
- pfi->pfd.cAccumBlueBits = accum;
- pfi->pfd.cAccumAlphaBits = accum;
- pfi->pfd.cDepthBits = depth->bits.depth;
- pfi->pfd.cStencilBits = depth->bits.stencil;
- pfi->pfd.cAuxBuffers = 0;
- pfi->pfd.iLayerType = 0;
- pfi->pfd.bReserved = 0;
- pfi->pfd.dwLayerMask = 0;
- pfi->pfd.dwVisibleMask = 0;
- pfi->pfd.dwDamageMask = 0;
-
- if(samples) {
- pfi->numSampleBuffers = 1;
- pfi->numSamples = samples;
- extended = TRUE;
- }
-
- ++stw_dev->pixelformat_extended_count;
-
- if(!extended) {
- ++stw_dev->pixelformat_count;
- assert(stw_dev->pixelformat_count == stw_dev->pixelformat_extended_count);
- }
-}
-
-void
-stw_pixelformat_init( void )
-{
- struct pipe_screen *screen = stw_dev->screen;
- unsigned i, j, k, l;
-
- assert( !stw_dev->pixelformat_count );
- assert( !stw_dev->pixelformat_extended_count );
-
- for(i = 0; i < Elements(stw_pf_multisample); ++i) {
- unsigned samples = stw_pf_multisample[i];
-
- /* FIXME: re-enabled MSAA when we can query it */
- if(samples)
- continue;
-
- for(j = 0; j < Elements(stw_pf_color); ++j) {
- const struct stw_pf_color_info *color = &stw_pf_color[j];
-
- if(!screen->is_format_supported(screen, color->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0))
- continue;
-
- for(k = 0; k < Elements(stw_pf_doublebuffer); ++k) {
- unsigned doublebuffer = stw_pf_doublebuffer[k];
-
- for(l = 0; l < Elements(stw_pf_depth_stencil); ++l) {
- const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[l];
-
- if(!screen->is_format_supported(screen, depth->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0))
- continue;
-
- stw_pixelformat_add( stw_dev, color, depth, 0, doublebuffer, samples );
- stw_pixelformat_add( stw_dev, color, depth, 16, doublebuffer, samples );
- }
- }
- }
- }
-
- assert( stw_dev->pixelformat_count <= stw_dev->pixelformat_extended_count );
- assert( stw_dev->pixelformat_extended_count <= STW_MAX_PIXELFORMATS );
-}
-
-uint
-stw_pixelformat_get_count( void )
-{
- return stw_dev->pixelformat_count;
-}
-
-uint
-stw_pixelformat_get_extended_count( void )
-{
- return stw_dev->pixelformat_extended_count;
-}
-
-const struct stw_pixelformat_info *
-stw_pixelformat_get_info( uint index )
-{
- assert( index < stw_dev->pixelformat_extended_count );
-
- return &stw_dev->pixelformats[index];
-}
-
-
-void
-stw_pixelformat_visual(GLvisual *visual,
- const struct stw_pixelformat_info *pfi )
-{
- memset(visual, 0, sizeof *visual);
- _mesa_initialize_visual(
- visual,
- (pfi->pfd.iPixelType == PFD_TYPE_RGBA) ? GL_TRUE : GL_FALSE,
- (pfi->pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE,
- (pfi->pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE,
- pfi->pfd.cRedBits,
- pfi->pfd.cGreenBits,
- pfi->pfd.cBlueBits,
- pfi->pfd.cAlphaBits,
- (pfi->pfd.iPixelType == PFD_TYPE_COLORINDEX) ? pfi->pfd.cColorBits : 0,
- pfi->pfd.cDepthBits,
- pfi->pfd.cStencilBits,
- pfi->pfd.cAccumRedBits,
- pfi->pfd.cAccumGreenBits,
- pfi->pfd.cAccumBlueBits,
- pfi->pfd.cAccumAlphaBits,
- pfi->numSamples );
-}
-
-
-int
-stw_pixelformat_describe(
- HDC hdc,
- int iPixelFormat,
- UINT nBytes,
- LPPIXELFORMATDESCRIPTOR ppfd )
-{
- uint count;
- uint index;
- const struct stw_pixelformat_info *pfi;
-
- (void) hdc;
-
- count = stw_pixelformat_get_extended_count();
- index = (uint) iPixelFormat - 1;
-
- if (ppfd == NULL)
- return count;
- if (index >= count || nBytes != sizeof( PIXELFORMATDESCRIPTOR ))
- return 0;
-
- pfi = stw_pixelformat_get_info( index );
-
- memcpy(ppfd, &pfi->pfd, sizeof( PIXELFORMATDESCRIPTOR ));
-
- return count;
-}
-
-/* Only used by the wgl code, but have it here to avoid exporting the
- * pixelformat.h functionality.
- */
-int stw_pixelformat_choose( HDC hdc,
- CONST PIXELFORMATDESCRIPTOR *ppfd )
-{
- uint count;
- uint index;
- uint bestindex;
- uint bestdelta;
-
- (void) hdc;
-
- count = stw_pixelformat_get_count();
- bestindex = count;
- bestdelta = ~0U;
-
- for (index = 0; index < count; index++) {
- uint delta = 0;
- const struct stw_pixelformat_info *pfi = stw_pixelformat_get_info( index );
-
- if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
- !!(ppfd->dwFlags & PFD_DOUBLEBUFFER) !=
- !!(pfi->pfd.dwFlags & PFD_DOUBLEBUFFER))
- continue;
-
- /* FIXME: Take in account individual channel bits */
- if (ppfd->cColorBits != pfi->pfd.cColorBits)
- delta += 8;
-
- if (ppfd->cDepthBits != pfi->pfd.cDepthBits)
- delta += 4;
-
- if (ppfd->cStencilBits != pfi->pfd.cStencilBits)
- delta += 2;
-
- if (ppfd->cAlphaBits != pfi->pfd.cAlphaBits)
- delta++;
-
- if (delta < bestdelta) {
- bestindex = index;
- bestdelta = delta;
- if (bestdelta == 0)
- break;
- }
- }
-
- if (bestindex == count)
- return 0;
-
- return bestindex + 1;
-}
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef STW_PIXELFORMAT_H
-#define STW_PIXELFORMAT_H
-
-#include <windows.h>
-
-#include "main/mtypes.h"
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_format.h"
-
-struct stw_pixelformat_info
-{
- enum pipe_format color_format;
- enum pipe_format depth_stencil_format;
-
- PIXELFORMATDESCRIPTOR pfd;
-
- unsigned numSampleBuffers;
- unsigned numSamples;
-};
-
-void
-stw_pixelformat_init( void );
-
-uint
-stw_pixelformat_get_count( void );
-
-uint
-stw_pixelformat_get_extended_count( void );
-
-const struct stw_pixelformat_info *
-stw_pixelformat_get_info( uint index );
-
-void
-stw_pixelformat_visual(GLvisual *visual,
- const struct stw_pixelformat_info *pfi );
-
-#endif /* STW_PIXELFORMAT_H */
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef STW_PUBLIC_H
-#define STW_PUBLIC_H
-
-#include <windows.h>
-
-BOOL stw_copy_context( UINT_PTR hglrcSrc,
- UINT_PTR hglrcDst,
- UINT mask );
-
-UINT_PTR stw_create_layer_context( HDC hdc,
- int iLayerPlane );
-
-BOOL stw_share_lists( UINT_PTR hglrc1, UINT_PTR hglrc2 );
-
-BOOL stw_delete_context( UINT_PTR hglrc );
-
-BOOL
-stw_release_context( UINT_PTR dhglrc );
-
-UINT_PTR stw_get_current_context( void );
-
-HDC stw_get_current_dc( void );
-
-BOOL stw_make_current( HDC hdc, UINT_PTR hglrc );
-
-BOOL stw_swap_buffers( HDC hdc );
-
-BOOL
-stw_swap_layer_buffers( HDC hdc, UINT fuPlanes );
-
-PROC stw_get_proc_address( LPCSTR lpszProc );
-
-int stw_pixelformat_describe( HDC hdc,
- int iPixelFormat,
- UINT nBytes,
- LPPIXELFORMATDESCRIPTOR ppfd );
-
-int stw_pixelformat_get( HDC hdc );
-
-BOOL stw_pixelformat_set( HDC hdc,
- int iPixelFormat );
-
-int stw_pixelformat_choose( HDC hdc,
- CONST PIXELFORMATDESCRIPTOR *ppfd );
-
-#endif
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <windows.h>
-
-#include "pipe/p_compiler.h"
-#include "util/u_memory.h"
-#include "stw_tls.h"
-
-static DWORD tlsIndex = TLS_OUT_OF_INDEXES;
-
-boolean
-stw_tls_init(void)
-{
- tlsIndex = TlsAlloc();
- if (tlsIndex == TLS_OUT_OF_INDEXES) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-static INLINE struct stw_tls_data *
-stw_tls_data_create()
-{
- struct stw_tls_data *data;
-
- data = CALLOC_STRUCT(stw_tls_data);
- if (!data)
- goto no_data;
-
- data->hCallWndProcHook = SetWindowsHookEx(WH_CALLWNDPROC,
- stw_call_window_proc,
- NULL,
- GetCurrentThreadId());
- if(data->hCallWndProcHook == NULL)
- goto no_hook;
-
- TlsSetValue(tlsIndex, data);
-
- return data;
-
-no_hook:
- FREE(data);
-no_data:
- return NULL;
-}
-
-boolean
-stw_tls_init_thread(void)
-{
- struct stw_tls_data *data;
-
- if (tlsIndex == TLS_OUT_OF_INDEXES) {
- return FALSE;
- }
-
- data = stw_tls_data_create();
- if(!data)
- return FALSE;
-
- return TRUE;
-}
-
-void
-stw_tls_cleanup_thread(void)
-{
- struct stw_tls_data *data;
-
- if (tlsIndex == TLS_OUT_OF_INDEXES) {
- return;
- }
-
- data = (struct stw_tls_data *) TlsGetValue(tlsIndex);
- if(data) {
- TlsSetValue(tlsIndex, NULL);
-
- if(data->hCallWndProcHook) {
- UnhookWindowsHookEx(data->hCallWndProcHook);
- data->hCallWndProcHook = NULL;
- }
-
- FREE(data);
- }
-}
-
-void
-stw_tls_cleanup(void)
-{
- if (tlsIndex != TLS_OUT_OF_INDEXES) {
- TlsFree(tlsIndex);
- tlsIndex = TLS_OUT_OF_INDEXES;
- }
-}
-
-struct stw_tls_data *
-stw_tls_get_data(void)
-{
- struct stw_tls_data *data;
-
- if (tlsIndex == TLS_OUT_OF_INDEXES) {
- return NULL;
- }
-
- data = (struct stw_tls_data *) TlsGetValue(tlsIndex);
- if(!data) {
- /* DllMain is called with DLL_THREAD_ATTACH only by threads created after
- * the DLL is loaded by the process */
- data = stw_tls_data_create();
- if(!data)
- return NULL;
- }
-
- return data;
-}
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef STW_TLS_H
-#define STW_TLS_H
-
-#include <windows.h>
-
-struct stw_tls_data
-{
- HHOOK hCallWndProcHook;
-};
-
-boolean
-stw_tls_init(void);
-
-boolean
-stw_tls_init_thread(void);
-
-void
-stw_tls_cleanup_thread(void);
-
-void
-stw_tls_cleanup(void);
-
-struct stw_tls_data *
-stw_tls_get_data(void);
-
-LRESULT CALLBACK
-stw_call_window_proc(
- int nCode,
- WPARAM wParam,
- LPARAM lParam );
-
-#endif /* STW_TLS_H */
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef STW_WINSYS_H
-#define STW_WINSYS_H
-
-#include <windows.h> /* for HDC */
-
-#include "pipe/p_compiler.h"
-
-struct pipe_screen;
-struct pipe_context;
-struct pipe_surface;
-
-struct stw_winsys
-{
- struct pipe_screen *
- (*create_screen)( void );
-
- struct pipe_context *
- (*create_context)( struct pipe_screen *screen );
-
- void
- (*flush_frontbuffer)( struct pipe_screen *screen,
- struct pipe_surface *surf,
- HDC hDC );
-};
-
-boolean
-stw_init(const struct stw_winsys *stw_winsys);
-
-boolean
-stw_init_thread(void);
-
-void
-stw_cleanup_thread(void);
-
-void
-stw_cleanup(void);
-
-#endif /* STW_WINSYS_H */
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <windows.h>
+
+#include "main/mtypes.h"
+#include "main/context.h"
+#include "pipe/p_compiler.h"
+#include "pipe/p_context.h"
+#include "state_tracker/st_context.h"
+#include "state_tracker/st_public.h"
+
+#ifdef DEBUG
+#include "trace/tr_screen.h"
+#include "trace/tr_context.h"
+#endif
+
+#include "stw_device.h"
+#include "stw_winsys.h"
+#include "stw_framebuffer.h"
+#include "stw_pixelformat.h"
+#include "stw_public.h"
+#include "stw_context.h"
+#include "stw_tls.h"
+
+
+static INLINE struct stw_context *
+stw_context(GLcontext *glctx)
+{
+ if(!glctx)
+ return NULL;
+ assert(glctx->DriverCtx);
+ return (struct stw_context *)glctx->DriverCtx;
+}
+
+static INLINE struct stw_context *
+stw_current_context(void)
+{
+ /* We must check if multiple threads are being used or GET_CURRENT_CONTEXT
+ * might return the current context of the thread first seen. */
+ _glapi_check_multithread();
+
+ {
+ GET_CURRENT_CONTEXT( glctx );
+ return stw_context(glctx);
+ }
+}
+
+BOOL
+stw_copy_context(
+ UINT_PTR hglrcSrc,
+ UINT_PTR hglrcDst,
+ UINT mask )
+{
+ struct stw_context *src;
+ struct stw_context *dst;
+ BOOL ret = FALSE;
+
+ pipe_mutex_lock( stw_dev->ctx_mutex );
+
+ src = stw_lookup_context_locked( hglrcSrc );
+ dst = stw_lookup_context_locked( hglrcDst );
+
+ if (src && dst) {
+ /* FIXME */
+ assert(0);
+ (void) src;
+ (void) dst;
+ (void) mask;
+ }
+
+ pipe_mutex_unlock( stw_dev->ctx_mutex );
+
+ return ret;
+}
+
+BOOL
+stw_share_lists(
+ UINT_PTR hglrc1,
+ UINT_PTR hglrc2 )
+{
+ struct stw_context *ctx1;
+ struct stw_context *ctx2;
+ BOOL ret = FALSE;
+
+ pipe_mutex_lock( stw_dev->ctx_mutex );
+
+ ctx1 = stw_lookup_context_locked( hglrc1 );
+ ctx2 = stw_lookup_context_locked( hglrc2 );
+
+ if (ctx1 && ctx2 &&
+ ctx1->iPixelFormat == ctx2->iPixelFormat) {
+ ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx);
+ }
+
+ pipe_mutex_unlock( stw_dev->ctx_mutex );
+
+ return ret;
+}
+
+static void
+stw_viewport(GLcontext * glctx, GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ struct stw_context *ctx = (struct stw_context *)glctx->DriverCtx;
+ struct stw_framebuffer *fb;
+
+ fb = stw_framebuffer_from_hdc( ctx->hdc );
+ if(fb) {
+ stw_framebuffer_update(fb);
+ stw_framebuffer_release(fb);
+ }
+}
+
+UINT_PTR
+stw_create_layer_context(
+ HDC hdc,
+ int iLayerPlane )
+{
+ int iPixelFormat;
+ const struct stw_pixelformat_info *pfi;
+ GLvisual visual;
+ struct stw_context *ctx = NULL;
+ struct pipe_screen *screen = NULL;
+ struct pipe_context *pipe = NULL;
+
+ if(!stw_dev)
+ return 0;
+
+ if (iLayerPlane != 0)
+ return 0;
+
+ iPixelFormat = GetPixelFormat(hdc);
+ if(!iPixelFormat)
+ return 0;
+
+ pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
+ stw_pixelformat_visual(&visual, pfi);
+
+ ctx = CALLOC_STRUCT( stw_context );
+ if (ctx == NULL)
+ goto no_ctx;
+
+ ctx->hdc = hdc;
+ ctx->iPixelFormat = iPixelFormat;
+
+ screen = stw_dev->screen;
+
+#ifdef DEBUG
+ /* Unwrap screen */
+ if(stw_dev->trace_running)
+ screen = trace_screen(screen)->screen;
+#endif
+
+ pipe = stw_dev->stw_winsys->create_context( screen );
+ if (pipe == NULL)
+ goto no_pipe;
+
+#ifdef DEBUG
+ /* Wrap context */
+ if(stw_dev->trace_running)
+ pipe = trace_context_create(stw_dev->screen, pipe);
+#endif
+
+ /* pass to stw_flush_frontbuffer as context_private */
+ assert(!pipe->priv);
+ pipe->priv = hdc;
+
+ ctx->st = st_create_context( pipe, &visual, NULL );
+ if (ctx->st == NULL)
+ goto no_st_ctx;
+
+ ctx->st->ctx->DriverCtx = ctx;
+ ctx->st->ctx->Driver.Viewport = stw_viewport;
+
+ pipe_mutex_lock( stw_dev->ctx_mutex );
+ ctx->hglrc = handle_table_add(stw_dev->ctx_table, ctx);
+ pipe_mutex_unlock( stw_dev->ctx_mutex );
+ if (!ctx->hglrc)
+ goto no_hglrc;
+
+ return ctx->hglrc;
+
+no_hglrc:
+ st_destroy_context(ctx->st);
+ goto no_pipe; /* st_context_destroy already destroys pipe */
+no_st_ctx:
+ pipe->destroy( pipe );
+no_pipe:
+ FREE(ctx);
+no_ctx:
+ return 0;
+}
+
+BOOL
+stw_delete_context(
+ UINT_PTR hglrc )
+{
+ struct stw_context *ctx ;
+ BOOL ret = FALSE;
+
+ if (!stw_dev)
+ return FALSE;
+
+ pipe_mutex_lock( stw_dev->ctx_mutex );
+ ctx = stw_lookup_context_locked(hglrc);
+ handle_table_remove(stw_dev->ctx_table, hglrc);
+ pipe_mutex_unlock( stw_dev->ctx_mutex );
+
+ if (ctx) {
+ struct stw_context *curctx = stw_current_context();
+
+ /* Unbind current if deleting current context. */
+ if (curctx == ctx)
+ st_make_current( NULL, NULL, NULL );
+
+ st_destroy_context(ctx->st);
+ FREE(ctx);
+
+ ret = TRUE;
+ }
+
+ return ret;
+}
+
+BOOL
+stw_release_context(
+ UINT_PTR hglrc )
+{
+ struct stw_context *ctx;
+
+ if (!stw_dev)
+ return FALSE;
+
+ pipe_mutex_lock( stw_dev->ctx_mutex );
+ ctx = stw_lookup_context_locked( hglrc );
+ pipe_mutex_unlock( stw_dev->ctx_mutex );
+
+ if (!ctx)
+ return FALSE;
+
+ /* The expectation is that ctx is the same context which is
+ * current for this thread. We should check that and return False
+ * if not the case.
+ */
+ if (ctx != stw_current_context())
+ return FALSE;
+
+ if (stw_make_current( NULL, 0 ) == FALSE)
+ return FALSE;
+
+ return TRUE;
+}
+
+
+UINT_PTR
+stw_get_current_context( void )
+{
+ struct stw_context *ctx;
+
+ ctx = stw_current_context();
+ if(!ctx)
+ return 0;
+
+ return ctx->hglrc;
+}
+
+HDC
+stw_get_current_dc( void )
+{
+ struct stw_context *ctx;
+
+ ctx = stw_current_context();
+ if(!ctx)
+ return NULL;
+
+ return ctx->hdc;
+}
+
+BOOL
+stw_make_current(
+ HDC hdc,
+ UINT_PTR hglrc )
+{
+ struct stw_context *curctx = NULL;
+ struct stw_context *ctx = NULL;
+ struct stw_framebuffer *fb = NULL;
+
+ if (!stw_dev)
+ goto fail;
+
+ curctx = stw_current_context();
+ if (curctx != NULL) {
+ if (curctx->hglrc != hglrc)
+ st_flush(curctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+ /* Return if already current. */
+ if (curctx->hglrc == hglrc && curctx->hdc == hdc) {
+ ctx = curctx;
+ fb = stw_framebuffer_from_hdc( hdc );
+ goto success;
+ }
+ }
+
+ if (hdc == NULL || hglrc == 0) {
+ return st_make_current( NULL, NULL, NULL );
+ }
+
+ pipe_mutex_lock( stw_dev->ctx_mutex );
+ ctx = stw_lookup_context_locked( hglrc );
+ pipe_mutex_unlock( stw_dev->ctx_mutex );
+ if(!ctx)
+ goto fail;
+
+ fb = stw_framebuffer_from_hdc( hdc );
+ if(!fb) {
+ /* Applications should call SetPixelFormat before creating a context,
+ * but not all do, and the opengl32 runtime seems to use a default pixel
+ * format in some cases, so we must create a framebuffer for those here
+ */
+ int iPixelFormat = GetPixelFormat(hdc);
+ if(iPixelFormat)
+ fb = stw_framebuffer_create( hdc, iPixelFormat );
+ if(!fb)
+ goto fail;
+ }
+
+ if(fb->iPixelFormat != ctx->iPixelFormat)
+ goto fail;
+
+ /* Lazy allocation of the frame buffer */
+ if(!stw_framebuffer_allocate(fb))
+ goto fail;
+
+ /* Bind the new framebuffer */
+ ctx->hdc = hdc;
+
+ /* pass to stw_flush_frontbuffer as context_private */
+ ctx->st->pipe->priv = hdc;
+
+ if(!st_make_current( ctx->st, fb->stfb, fb->stfb ))
+ goto fail;
+
+success:
+ assert(fb);
+ if(fb) {
+ stw_framebuffer_update(fb);
+ stw_framebuffer_release(fb);
+ }
+
+ return TRUE;
+
+fail:
+ if(fb)
+ stw_framebuffer_release(fb);
+ st_make_current( NULL, NULL, NULL );
+ return FALSE;
+}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef STW_CONTEXT_H
+#define STW_CONTEXT_H
+
+#include <windows.h>
+
+struct st_context;
+
+struct stw_context
+{
+ struct st_context *st;
+ UINT_PTR hglrc;
+ int iPixelFormat;
+ HDC hdc;
+};
+
+#endif /* STW_CONTEXT_H */
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <windows.h>
+
+#include "glapi/glthread.h"
+#include "util/u_debug.h"
+#include "pipe/p_screen.h"
+#include "state_tracker/st_public.h"
+
+#ifdef DEBUG
+#include "trace/tr_screen.h"
+#include "trace/tr_texture.h"
+#endif
+
+#include "stw_device.h"
+#include "stw_winsys.h"
+#include "stw_pixelformat.h"
+#include "stw_public.h"
+#include "stw_tls.h"
+#include "stw_framebuffer.h"
+
+#ifdef WIN32_THREADS
+extern _glthread_Mutex OneTimeLock;
+extern void FreeAllTSD(void);
+#endif
+
+
+struct stw_device *stw_dev = NULL;
+
+
+/**
+ * XXX: Dispatch pipe_screen::flush_front_buffer to our
+ * stw_winsys::flush_front_buffer.
+ */
+static void
+stw_flush_frontbuffer(struct pipe_screen *screen,
+ struct pipe_surface *surface,
+ void *context_private )
+{
+ const struct stw_winsys *stw_winsys = stw_dev->stw_winsys;
+ HDC hdc = (HDC)context_private;
+ struct stw_framebuffer *fb;
+
+ fb = stw_framebuffer_from_hdc( hdc );
+ /* fb can be NULL if window was destroyed already */
+ if (fb) {
+#if DEBUG
+ {
+ struct pipe_surface *surface2;
+
+ if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 ))
+ assert(0);
+ else
+ assert(surface2 == surface);
+ }
+#endif
+
+#ifdef DEBUG
+ if(stw_dev->trace_running) {
+ screen = trace_screen(screen)->screen;
+ surface = trace_surface(surface)->surface;
+ }
+#endif
+ }
+
+ stw_winsys->flush_frontbuffer(screen, surface, hdc);
+
+ if(fb) {
+ stw_framebuffer_update(fb);
+ stw_framebuffer_release(fb);
+ }
+}
+
+
+boolean
+stw_init(const struct stw_winsys *stw_winsys)
+{
+ static struct stw_device stw_dev_storage;
+ struct pipe_screen *screen;
+
+ debug_printf("%s\n", __FUNCTION__);
+
+ assert(!stw_dev);
+
+ stw_tls_init();
+
+ stw_dev = &stw_dev_storage;
+ memset(stw_dev, 0, sizeof(*stw_dev));
+
+#ifdef DEBUG
+ stw_dev->memdbg_no = debug_memory_begin();
+#endif
+
+ stw_dev->stw_winsys = stw_winsys;
+
+#ifdef WIN32_THREADS
+ _glthread_INIT_MUTEX(OneTimeLock);
+#endif
+
+ screen = stw_winsys->create_screen();
+ if(!screen)
+ goto error1;
+
+#ifdef DEBUG
+ stw_dev->screen = trace_screen_create(screen);
+ stw_dev->trace_running = stw_dev->screen != screen ? TRUE : FALSE;
+#else
+ stw_dev->screen = screen;
+#endif
+
+ stw_dev->screen->flush_frontbuffer = &stw_flush_frontbuffer;
+
+ pipe_mutex_init( stw_dev->ctx_mutex );
+ pipe_mutex_init( stw_dev->fb_mutex );
+
+ stw_dev->ctx_table = handle_table_create();
+ if (!stw_dev->ctx_table) {
+ goto error1;
+ }
+
+ stw_pixelformat_init();
+
+ return TRUE;
+
+error1:
+ stw_dev = NULL;
+ return FALSE;
+}
+
+
+boolean
+stw_init_thread(void)
+{
+ return stw_tls_init_thread();
+}
+
+
+void
+stw_cleanup_thread(void)
+{
+ stw_tls_cleanup_thread();
+}
+
+
+void
+stw_cleanup(void)
+{
+ unsigned i;
+
+ debug_printf("%s\n", __FUNCTION__);
+
+ if (!stw_dev)
+ return;
+
+ pipe_mutex_lock( stw_dev->ctx_mutex );
+ {
+ /* Ensure all contexts are destroyed */
+ i = handle_table_get_first_handle(stw_dev->ctx_table);
+ while (i) {
+ stw_delete_context(i);
+ i = handle_table_get_next_handle(stw_dev->ctx_table, i);
+ }
+ handle_table_destroy(stw_dev->ctx_table);
+ }
+ pipe_mutex_unlock( stw_dev->ctx_mutex );
+
+ stw_framebuffer_cleanup();
+
+ pipe_mutex_destroy( stw_dev->fb_mutex );
+ pipe_mutex_destroy( stw_dev->ctx_mutex );
+
+ stw_dev->screen->destroy(stw_dev->screen);
+
+#ifdef WIN32_THREADS
+ _glthread_DESTROY_MUTEX(OneTimeLock);
+ FreeAllTSD();
+#endif
+
+#ifdef DEBUG
+ debug_memory_end(stw_dev->memdbg_no);
+#endif
+
+ stw_tls_cleanup();
+
+ stw_dev = NULL;
+}
+
+
+struct stw_context *
+stw_lookup_context_locked( UINT_PTR dhglrc )
+{
+ if (dhglrc == 0)
+ return NULL;
+
+ if (stw_dev == NULL)
+ return NULL;
+
+ return (struct stw_context *) handle_table_get(stw_dev->ctx_table, dhglrc);
+}
+
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef STW_DEVICE_H_
+#define STW_DEVICE_H_
+
+
+#include <windows.h>
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_thread.h"
+#include "util/u_handle_table.h"
+#include "stw_pixelformat.h"
+
+
+#define STW_MAX_PIXELFORMATS 256
+
+
+struct pipe_screen;
+struct stw_framebuffer;
+
+struct stw_device
+{
+ const struct stw_winsys *stw_winsys;
+
+ struct pipe_screen *screen;
+
+#ifdef DEBUG
+ boolean trace_running;
+#endif
+
+ struct stw_pixelformat_info pixelformats[STW_MAX_PIXELFORMATS];
+ unsigned pixelformat_count;
+ unsigned pixelformat_extended_count;
+
+ pipe_mutex ctx_mutex;
+ struct handle_table *ctx_table;
+
+ pipe_mutex fb_mutex;
+ struct stw_framebuffer *fb_head;
+
+#ifdef DEBUG
+ unsigned long memdbg_no;
+#endif
+};
+
+struct stw_context *
+stw_lookup_context_locked( UINT_PTR hglrc );
+
+extern struct stw_device *stw_dev;
+
+
+#endif /* STW_DEVICE_H_ */
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <windows.h>
+
+#define WGL_WGLEXT_PROTOTYPES
+
+#include <GL/gl.h>
+#include <GL/wglext.h>
+
+
+static const char *stw_extension_string =
+ "WGL_ARB_extensions_string "
+ "WGL_ARB_multisample "
+ "WGL_ARB_pixel_format "
+/* "WGL_EXT_swap_interval " */
+ "WGL_EXT_extensions_string";
+
+
+WINGDIAPI const char * APIENTRY
+wglGetExtensionsStringARB(
+ HDC hdc )
+{
+ (void) hdc;
+
+ return stw_extension_string;
+}
+
+
+WINGDIAPI const char * APIENTRY
+wglGetExtensionsStringEXT( void )
+{
+ return stw_extension_string;
+}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "pipe/p_screen.h"
+#include "stw_public.h"
+#include "stw_device.h"
+#include "stw_winsys.h"
+#include "stw_ext_gallium.h"
+
+#ifdef DEBUG
+#include "trace/tr_screen.h"
+#include "trace/tr_context.h"
+#endif
+
+
+struct pipe_screen * APIENTRY
+wglGetGalliumScreenMESA(void)
+{
+ return stw_dev ? stw_dev->screen : NULL;
+}
+
+
+/* XXX: Unify with stw_create_layer_context */
+struct pipe_context * APIENTRY
+wglCreateGalliumContextMESA(void)
+{
+ struct pipe_screen *screen = NULL;
+ struct pipe_context *pipe = NULL;
+
+ if(!stw_dev)
+ return NULL;
+
+ screen = stw_dev->screen;
+
+#ifdef DEBUG
+ /* Unwrap screen */
+ if(stw_dev->trace_running)
+ screen = trace_screen(screen)->screen;
+#endif
+
+ pipe = stw_dev->stw_winsys->create_context( screen );
+ if (pipe == NULL)
+ goto no_pipe;
+
+#ifdef DEBUG
+ /* Wrap context */
+ if(stw_dev->trace_running)
+ pipe = trace_context_create(stw_dev->screen, pipe);
+#endif
+
+ return pipe;
+
+no_pipe:
+ return NULL;
+}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef STW_EXTGALLIUM_H_
+#define STW_EXTGALLIUM_H_
+
+
+#include <windows.h>
+
+
+struct pipe_screen;
+struct pipe_context;
+
+
+struct pipe_screen * APIENTRY
+wglGetGalliumScreenMESA(void);
+
+
+struct pipe_context * APIENTRY
+wglCreateGalliumContextMESA(void);
+
+
+#endif /* STW_EXTGALLIUM_H_ */
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ *
+ * WGL_ARB_pixel_format extension implementation.
+ *
+ * @sa http://www.opengl.org/registry/specs/ARB/wgl_pixel_format.txt
+ */
+
+
+#include <windows.h>
+
+#define WGL_WGLEXT_PROTOTYPES
+
+#include <GL/gl.h>
+#include <GL/wglext.h>
+
+#include "pipe/p_compiler.h"
+#include "util/u_memory.h"
+#include "stw_public.h"
+#include "stw_pixelformat.h"
+
+
+static boolean
+stw_query_attrib(
+ int iPixelFormat,
+ int iLayerPlane,
+ int attrib,
+ int *pvalue )
+{
+ uint count;
+ uint index;
+ const struct stw_pixelformat_info *pfi;
+
+ count = stw_pixelformat_get_extended_count();
+
+ if (attrib == WGL_NUMBER_PIXEL_FORMATS_ARB) {
+ *pvalue = (int) count;
+ return TRUE;
+ }
+
+ index = (uint) iPixelFormat - 1;
+ if (index >= count)
+ return FALSE;
+
+ pfi = stw_pixelformat_get_info( index );
+
+ switch (attrib) {
+ case WGL_DRAW_TO_WINDOW_ARB:
+ *pvalue = pfi->pfd.dwFlags & PFD_DRAW_TO_WINDOW ? TRUE : FALSE;
+ return TRUE;
+
+ case WGL_DRAW_TO_BITMAP_ARB:
+ *pvalue = pfi->pfd.dwFlags & PFD_DRAW_TO_BITMAP ? TRUE : FALSE;
+ return TRUE;
+
+ case WGL_NEED_PALETTE_ARB:
+ *pvalue = pfi->pfd.dwFlags & PFD_NEED_PALETTE ? TRUE : FALSE;
+ return TRUE;
+
+ case WGL_NEED_SYSTEM_PALETTE_ARB:
+ *pvalue = pfi->pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ? TRUE : FALSE;
+ return TRUE;
+
+ case WGL_SWAP_METHOD_ARB:
+ *pvalue = pfi->pfd.dwFlags & PFD_SWAP_COPY ? WGL_SWAP_COPY_ARB : WGL_SWAP_UNDEFINED_ARB;
+ return TRUE;
+
+ case WGL_SWAP_LAYER_BUFFERS_ARB:
+ *pvalue = FALSE;
+ return TRUE;
+
+ case WGL_NUMBER_OVERLAYS_ARB:
+ *pvalue = 0;
+ return TRUE;
+
+ case WGL_NUMBER_UNDERLAYS_ARB:
+ *pvalue = 0;
+ return TRUE;
+ }
+
+ if (iLayerPlane != 0)
+ return FALSE;
+
+ switch (attrib) {
+ case WGL_ACCELERATION_ARB:
+ *pvalue = WGL_FULL_ACCELERATION_ARB;
+ break;
+
+ case WGL_TRANSPARENT_ARB:
+ *pvalue = FALSE;
+ break;
+
+ case WGL_TRANSPARENT_RED_VALUE_ARB:
+ case WGL_TRANSPARENT_GREEN_VALUE_ARB:
+ case WGL_TRANSPARENT_BLUE_VALUE_ARB:
+ case WGL_TRANSPARENT_ALPHA_VALUE_ARB:
+ case WGL_TRANSPARENT_INDEX_VALUE_ARB:
+ break;
+
+ case WGL_SHARE_DEPTH_ARB:
+ case WGL_SHARE_STENCIL_ARB:
+ case WGL_SHARE_ACCUM_ARB:
+ *pvalue = TRUE;
+ break;
+
+ case WGL_SUPPORT_GDI_ARB:
+ *pvalue = pfi->pfd.dwFlags & PFD_SUPPORT_GDI ? TRUE : FALSE;
+ break;
+
+ case WGL_SUPPORT_OPENGL_ARB:
+ *pvalue = pfi->pfd.dwFlags & PFD_SUPPORT_OPENGL ? TRUE : FALSE;
+ break;
+
+ case WGL_DOUBLE_BUFFER_ARB:
+ *pvalue = pfi->pfd.dwFlags & PFD_DOUBLEBUFFER ? TRUE : FALSE;
+ break;
+
+ case WGL_STEREO_ARB:
+ *pvalue = pfi->pfd.dwFlags & PFD_STEREO ? TRUE : FALSE;
+ break;
+
+ case WGL_PIXEL_TYPE_ARB:
+ switch (pfi->pfd.iPixelType) {
+ case PFD_TYPE_RGBA:
+ *pvalue = WGL_TYPE_RGBA_ARB;
+ break;
+ case PFD_TYPE_COLORINDEX:
+ *pvalue = WGL_TYPE_COLORINDEX_ARB;
+ break;
+ default:
+ return FALSE;
+ }
+ break;
+
+ case WGL_COLOR_BITS_ARB:
+ *pvalue = pfi->pfd.cColorBits;
+ break;
+
+ case WGL_RED_BITS_ARB:
+ *pvalue = pfi->pfd.cRedBits;
+ break;
+
+ case WGL_RED_SHIFT_ARB:
+ *pvalue = pfi->pfd.cRedShift;
+ break;
+
+ case WGL_GREEN_BITS_ARB:
+ *pvalue = pfi->pfd.cGreenBits;
+ break;
+
+ case WGL_GREEN_SHIFT_ARB:
+ *pvalue = pfi->pfd.cGreenShift;
+ break;
+
+ case WGL_BLUE_BITS_ARB:
+ *pvalue = pfi->pfd.cBlueBits;
+ break;
+
+ case WGL_BLUE_SHIFT_ARB:
+ *pvalue = pfi->pfd.cBlueShift;
+ break;
+
+ case WGL_ALPHA_BITS_ARB:
+ *pvalue = pfi->pfd.cAlphaBits;
+ break;
+
+ case WGL_ALPHA_SHIFT_ARB:
+ *pvalue = pfi->pfd.cAlphaShift;
+ break;
+
+ case WGL_ACCUM_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumBits;
+ break;
+
+ case WGL_ACCUM_RED_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumRedBits;
+ break;
+
+ case WGL_ACCUM_GREEN_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumGreenBits;
+ break;
+
+ case WGL_ACCUM_BLUE_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumBlueBits;
+ break;
+
+ case WGL_ACCUM_ALPHA_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumAlphaBits;
+ break;
+
+ case WGL_DEPTH_BITS_ARB:
+ *pvalue = pfi->pfd.cDepthBits;
+ break;
+
+ case WGL_STENCIL_BITS_ARB:
+ *pvalue = pfi->pfd.cStencilBits;
+ break;
+
+ case WGL_AUX_BUFFERS_ARB:
+ *pvalue = pfi->pfd.cAuxBuffers;
+ break;
+
+ case WGL_SAMPLE_BUFFERS_ARB:
+ *pvalue = pfi->numSampleBuffers;
+ break;
+
+ case WGL_SAMPLES_ARB:
+ *pvalue = pfi->numSamples;
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+struct attrib_match_info
+{
+ int attribute;
+ int weight;
+ BOOL exact;
+};
+
+static const struct attrib_match_info attrib_match[] = {
+
+ /* WGL_ARB_pixel_format */
+ { WGL_DRAW_TO_WINDOW_ARB, 0, TRUE },
+ { WGL_DRAW_TO_BITMAP_ARB, 0, TRUE },
+ { WGL_ACCELERATION_ARB, 0, TRUE },
+ { WGL_NEED_PALETTE_ARB, 0, TRUE },
+ { WGL_NEED_SYSTEM_PALETTE_ARB, 0, TRUE },
+ { WGL_SWAP_LAYER_BUFFERS_ARB, 0, TRUE },
+ { WGL_SWAP_METHOD_ARB, 0, TRUE },
+ { WGL_NUMBER_OVERLAYS_ARB, 4, FALSE },
+ { WGL_NUMBER_UNDERLAYS_ARB, 4, FALSE },
+ /*{ WGL_SHARE_DEPTH_ARB, 0, TRUE },*/ /* no overlays -- ignore */
+ /*{ WGL_SHARE_STENCIL_ARB, 0, TRUE },*/ /* no overlays -- ignore */
+ /*{ WGL_SHARE_ACCUM_ARB, 0, TRUE },*/ /* no overlays -- ignore */
+ { WGL_SUPPORT_GDI_ARB, 0, TRUE },
+ { WGL_SUPPORT_OPENGL_ARB, 0, TRUE },
+ { WGL_DOUBLE_BUFFER_ARB, 0, TRUE },
+ { WGL_STEREO_ARB, 0, TRUE },
+ { WGL_PIXEL_TYPE_ARB, 0, TRUE },
+ { WGL_COLOR_BITS_ARB, 1, FALSE },
+ { WGL_RED_BITS_ARB, 1, FALSE },
+ { WGL_GREEN_BITS_ARB, 1, FALSE },
+ { WGL_BLUE_BITS_ARB, 1, FALSE },
+ { WGL_ALPHA_BITS_ARB, 1, FALSE },
+ { WGL_ACCUM_BITS_ARB, 1, FALSE },
+ { WGL_ACCUM_RED_BITS_ARB, 1, FALSE },
+ { WGL_ACCUM_GREEN_BITS_ARB, 1, FALSE },
+ { WGL_ACCUM_BLUE_BITS_ARB, 1, FALSE },
+ { WGL_ACCUM_ALPHA_BITS_ARB, 1, FALSE },
+ { WGL_DEPTH_BITS_ARB, 1, FALSE },
+ { WGL_STENCIL_BITS_ARB, 1, FALSE },
+ { WGL_AUX_BUFFERS_ARB, 2, FALSE },
+
+ /* WGL_ARB_multisample */
+ { WGL_SAMPLE_BUFFERS_ARB, 2, FALSE },
+ { WGL_SAMPLES_ARB, 2, FALSE }
+};
+
+struct stw_pixelformat_score
+{
+ int points;
+ uint index;
+};
+
+static BOOL
+score_pixelformats(
+ struct stw_pixelformat_score *scores,
+ uint count,
+ int attribute,
+ int expected_value )
+{
+ uint i;
+ const struct attrib_match_info *ami = NULL;
+ uint index;
+
+ /* Find out if a given attribute should be considered for score calculation.
+ */
+ for (i = 0; i < sizeof( attrib_match ) / sizeof( attrib_match[0] ); i++) {
+ if (attrib_match[i].attribute == attribute) {
+ ami = &attrib_match[i];
+ break;
+ }
+ }
+ if (ami == NULL)
+ return TRUE;
+
+ /* Iterate all pixelformats, query the requested attribute and calculate
+ * score points.
+ */
+ for (index = 0; index < count; index++) {
+ int actual_value;
+
+ if (!stw_query_attrib( index + 1, 0, attribute, &actual_value ))
+ return FALSE;
+
+ if (ami->exact) {
+ /* For an exact match criteria, if the actual and expected values differ,
+ * the score is set to 0 points, effectively removing the pixelformat
+ * from a list of matching pixelformats.
+ */
+ if (actual_value != expected_value)
+ scores[index].points = 0;
+ }
+ else {
+ /* For a minimum match criteria, if the actual value is smaller than the expected
+ * value, the pixelformat is rejected (score set to 0). However, if the actual
+ * value is bigger, the pixelformat is given a penalty to favour pixelformats that
+ * more closely match the expected values.
+ */
+ if (actual_value < expected_value)
+ scores[index].points = 0;
+ else if (actual_value > expected_value)
+ scores[index].points -= (actual_value - expected_value) * ami->weight;
+ }
+ }
+
+ return TRUE;
+}
+
+WINGDIAPI BOOL APIENTRY
+wglChoosePixelFormatARB(
+ HDC hdc,
+ const int *piAttribIList,
+ const FLOAT *pfAttribFList,
+ UINT nMaxFormats,
+ int *piFormats,
+ UINT *nNumFormats )
+{
+ uint count;
+ struct stw_pixelformat_score *scores;
+ uint i;
+
+ *nNumFormats = 0;
+
+ /* Allocate and initialize pixelformat score table -- better matches
+ * have higher scores. Start with a high score and take out penalty
+ * points for a mismatch when the match does not have to be exact.
+ * Set a score to 0 if there is a mismatch for an exact match criteria.
+ */
+ count = stw_pixelformat_get_extended_count();
+ scores = (struct stw_pixelformat_score *) MALLOC( count * sizeof( struct stw_pixelformat_score ) );
+ if (scores == NULL)
+ return FALSE;
+ for (i = 0; i < count; i++) {
+ scores[i].points = 0x7fffffff;
+ scores[i].index = i;
+ }
+
+ /* Given the attribute list calculate a score for each pixelformat.
+ */
+ if (piAttribIList != NULL) {
+ while (*piAttribIList != 0) {
+ if (!score_pixelformats( scores, count, piAttribIList[0], piAttribIList[1] )) {
+ FREE( scores );
+ return FALSE;
+ }
+ piAttribIList += 2;
+ }
+ }
+ if (pfAttribFList != NULL) {
+ while (*pfAttribFList != 0) {
+ if (!score_pixelformats( scores, count, (int) pfAttribFList[0], (int) pfAttribFList[1] )) {
+ FREE( scores );
+ return FALSE;
+ }
+ pfAttribFList += 2;
+ }
+ }
+
+ /* Bubble-sort the resulting scores. Pixelformats with higher scores go first.
+ * TODO: Find out if there are any patent issues with it.
+ */
+ if (count > 1) {
+ uint n = count;
+ boolean swapped;
+
+ do {
+ swapped = FALSE;
+ for (i = 1; i < n; i++) {
+ if (scores[i - 1].points < scores[i].points) {
+ struct stw_pixelformat_score score = scores[i - 1];
+
+ scores[i - 1] = scores[i];
+ scores[i] = score;
+ swapped = TRUE;
+ }
+ }
+ n--;
+ }
+ while (swapped);
+ }
+
+ /* Return a list of pixelformats that are the best match.
+ * Reject pixelformats with non-positive scores.
+ */
+ for (i = 0; i < count; i++) {
+ if (scores[i].points > 0) {
+ if (*nNumFormats < nMaxFormats)
+ piFormats[*nNumFormats] = scores[i].index + 1;
+ (*nNumFormats)++;
+ }
+ }
+
+ FREE( scores );
+ return TRUE;
+}
+
+WINGDIAPI BOOL APIENTRY
+wglGetPixelFormatAttribfvARB(
+ HDC hdc,
+ int iPixelFormat,
+ int iLayerPlane,
+ UINT nAttributes,
+ const int *piAttributes,
+ FLOAT *pfValues )
+{
+ UINT i;
+
+ (void) hdc;
+
+ for (i = 0; i < nAttributes; i++) {
+ int value;
+
+ if (!stw_query_attrib( iPixelFormat, iLayerPlane, piAttributes[i], &value ))
+ return FALSE;
+ pfValues[i] = (FLOAT) value;
+ }
+
+ return TRUE;
+}
+
+WINGDIAPI BOOL APIENTRY
+wglGetPixelFormatAttribivARB(
+ HDC hdc,
+ int iPixelFormat,
+ int iLayerPlane,
+ UINT nAttributes,
+ const int *piAttributes,
+ int *piValues )
+{
+ UINT i;
+
+ (void) hdc;
+
+ for (i = 0; i < nAttributes; i++) {
+ if (!stw_query_attrib( iPixelFormat, iLayerPlane, piAttributes[i], &piValues[i] ))
+ return FALSE;
+ }
+
+ return TRUE;
+}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <windows.h>
+
+#define WGL_WGLEXT_PROTOTYPES
+
+#include <GL/gl.h>
+#include <GL/wglext.h>
+#include "util/u_debug.h"
+
+/* A dummy implementation of this extension.
+ *
+ * Required as some applications retrieve and call these functions
+ * regardless of the fact that we don't advertise the extension and
+ * further more the results of wglGetProcAddress are NULL.
+ */
+WINGDIAPI BOOL APIENTRY
+wglSwapIntervalEXT(int interval)
+{
+ (void) interval;
+ debug_printf("%s: %d\n", __FUNCTION__, interval);
+ return TRUE;
+}
+
+WINGDIAPI int APIENTRY
+wglGetSwapIntervalEXT(void)
+{
+ return 0;
+}
+
+
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <windows.h>
+
+#include "main/context.h"
+#include "pipe/p_format.h"
+#include "pipe/p_screen.h"
+#include "state_tracker/st_context.h"
+#include "state_tracker/st_public.h"
+
+#ifdef DEBUG
+#include "trace/tr_screen.h"
+#include "trace/tr_texture.h"
+#endif
+
+#include "stw_framebuffer.h"
+#include "stw_device.h"
+#include "stw_public.h"
+#include "stw_winsys.h"
+#include "stw_tls.h"
+
+
+/**
+ * Search the framebuffer with the matching HWND while holding the
+ * stw_dev::fb_mutex global lock.
+ */
+static INLINE struct stw_framebuffer *
+stw_framebuffer_from_hwnd_locked(
+ HWND hwnd )
+{
+ struct stw_framebuffer *fb;
+
+ for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
+ if (fb->hWnd == hwnd) {
+ pipe_mutex_lock(fb->mutex);
+ break;
+ }
+
+ return fb;
+}
+
+
+/**
+ * Destroy this framebuffer. Both stw_dev::fb_mutex and stw_framebuffer::mutex
+ * must be held, by this order. Obviously no further access to fb can be done
+ * after this.
+ */
+static INLINE void
+stw_framebuffer_destroy_locked(
+ struct stw_framebuffer *fb )
+{
+ struct stw_framebuffer **link;
+
+ link = &stw_dev->fb_head;
+ while (*link != fb)
+ link = &(*link)->next;
+ assert(*link);
+ *link = fb->next;
+ fb->next = NULL;
+
+ st_unreference_framebuffer(fb->stfb);
+
+ pipe_mutex_unlock( fb->mutex );
+
+ pipe_mutex_destroy( fb->mutex );
+
+ FREE( fb );
+}
+
+
+void
+stw_framebuffer_release(
+ struct stw_framebuffer *fb)
+{
+ assert(fb);
+ pipe_mutex_unlock( fb->mutex );
+}
+
+
+static INLINE void
+stw_framebuffer_get_size( struct stw_framebuffer *fb )
+{
+ unsigned width, height;
+ RECT rect;
+
+ assert(fb->hWnd);
+
+ GetClientRect( fb->hWnd, &rect );
+ width = rect.right - rect.left;
+ height = rect.bottom - rect.top;
+
+ if(width < 1)
+ width = 1;
+ if(height < 1)
+ height = 1;
+
+ if(width != fb->width || height != fb->height) {
+ fb->must_resize = TRUE;
+ fb->width = width;
+ fb->height = height;
+ }
+}
+
+
+/**
+ * @sa http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx
+ * @sa http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx
+ */
+LRESULT CALLBACK
+stw_call_window_proc(
+ int nCode,
+ WPARAM wParam,
+ LPARAM lParam )
+{
+ struct stw_tls_data *tls_data;
+ PCWPSTRUCT pParams = (PCWPSTRUCT)lParam;
+ struct stw_framebuffer *fb;
+
+ tls_data = stw_tls_get_data();
+ if(!tls_data)
+ return 0;
+
+ if (nCode < 0)
+ return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam);
+
+ if (pParams->message == WM_WINDOWPOSCHANGED) {
+ /* We handle WM_WINDOWPOSCHANGED instead of WM_SIZE because according to
+ * http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx
+ * WM_SIZE is generated from WM_WINDOWPOSCHANGED by DefWindowProc so it
+ * can be masked out by the application. */
+ LPWINDOWPOS lpWindowPos = (LPWINDOWPOS)pParams->lParam;
+ if((lpWindowPos->flags & SWP_SHOWWINDOW) ||
+ !(lpWindowPos->flags & SWP_NOSIZE)) {
+ fb = stw_framebuffer_from_hwnd( pParams->hwnd );
+ if(fb) {
+ /* Size in WINDOWPOS includes the window frame, so get the size
+ * of the client area via GetClientRect. */
+ stw_framebuffer_get_size(fb);
+ stw_framebuffer_release(fb);
+ }
+ }
+ }
+ else if (pParams->message == WM_DESTROY) {
+ pipe_mutex_lock( stw_dev->fb_mutex );
+ fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd );
+ if(fb)
+ stw_framebuffer_destroy_locked(fb);
+ pipe_mutex_unlock( stw_dev->fb_mutex );
+ }
+
+ return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam);
+}
+
+
+struct stw_framebuffer *
+stw_framebuffer_create(
+ HDC hdc,
+ int iPixelFormat )
+{
+ HWND hWnd;
+ struct stw_framebuffer *fb;
+ const struct stw_pixelformat_info *pfi;
+
+ /* We only support drawing to a window. */
+ hWnd = WindowFromDC( hdc );
+ if(!hWnd)
+ return NULL;
+
+ fb = CALLOC_STRUCT( stw_framebuffer );
+ if (fb == NULL)
+ return NULL;
+
+ fb->hDC = hdc;
+ fb->hWnd = hWnd;
+ fb->iPixelFormat = iPixelFormat;
+
+ fb->pfi = pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
+
+ stw_pixelformat_visual(&fb->visual, pfi);
+
+ stw_framebuffer_get_size(fb);
+
+ pipe_mutex_init( fb->mutex );
+
+ /* This is the only case where we lock the stw_framebuffer::mutex before
+ * stw_dev::fb_mutex, since no other thread can know about this framebuffer
+ * and we must prevent any other thread from destroying it before we return.
+ */
+ pipe_mutex_lock( fb->mutex );
+
+ pipe_mutex_lock( stw_dev->fb_mutex );
+ fb->next = stw_dev->fb_head;
+ stw_dev->fb_head = fb;
+ pipe_mutex_unlock( stw_dev->fb_mutex );
+
+ return fb;
+}
+
+
+BOOL
+stw_framebuffer_allocate(
+ struct stw_framebuffer *fb)
+{
+ assert(fb);
+
+ if(!fb->stfb) {
+ const struct stw_pixelformat_info *pfi = fb->pfi;
+ enum pipe_format colorFormat, depthFormat, stencilFormat;
+
+ colorFormat = pfi->color_format;
+
+ assert(pf_layout( pfi->depth_stencil_format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
+
+ if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_Z ))
+ depthFormat = pfi->depth_stencil_format;
+ else
+ depthFormat = PIPE_FORMAT_NONE;
+
+ if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_S ))
+ stencilFormat = pfi->depth_stencil_format;
+ else
+ stencilFormat = PIPE_FORMAT_NONE;
+
+ assert(fb->must_resize);
+ assert(fb->width);
+ assert(fb->height);
+
+ fb->stfb = st_create_framebuffer(
+ &fb->visual,
+ colorFormat,
+ depthFormat,
+ stencilFormat,
+ fb->width,
+ fb->height,
+ (void *) fb );
+
+ // to notify the context
+ fb->must_resize = TRUE;
+ }
+
+ return fb->stfb ? TRUE : FALSE;
+}
+
+
+/**
+ * Update the framebuffer's size if necessary.
+ */
+void
+stw_framebuffer_update(
+ struct stw_framebuffer *fb)
+{
+ assert(fb->stfb);
+ assert(fb->height);
+ assert(fb->width);
+
+ /* XXX: It would be nice to avoid checking the size again -- in theory
+ * stw_call_window_proc would have cought the resize and stored the right
+ * size already, but unfortunately threads created before the DllMain is
+ * called don't get a DLL_THREAD_ATTACH notification, and there is no way
+ * to know of their existing without using the not very portable PSAPI.
+ */
+ stw_framebuffer_get_size(fb);
+
+ if(fb->must_resize) {
+ st_resize_framebuffer(fb->stfb, fb->width, fb->height);
+ fb->must_resize = FALSE;
+ }
+}
+
+
+void
+stw_framebuffer_cleanup( void )
+{
+ struct stw_framebuffer *fb;
+ struct stw_framebuffer *next;
+
+ pipe_mutex_lock( stw_dev->fb_mutex );
+
+ fb = stw_dev->fb_head;
+ while (fb) {
+ next = fb->next;
+
+ pipe_mutex_lock(fb->mutex);
+ stw_framebuffer_destroy_locked(fb);
+
+ fb = next;
+ }
+ stw_dev->fb_head = NULL;
+
+ pipe_mutex_unlock( stw_dev->fb_mutex );
+}
+
+
+/**
+ * Given an hdc, return the corresponding stw_framebuffer.
+ */
+static INLINE struct stw_framebuffer *
+stw_framebuffer_from_hdc_locked(
+ HDC hdc )
+{
+ HWND hwnd;
+ struct stw_framebuffer *fb;
+
+ /*
+ * Some applications create and use several HDCs for the same window, so
+ * looking up the framebuffer by the HDC is not reliable. Use HWND whenever
+ * possible.
+ */
+ hwnd = WindowFromDC(hdc);
+ if(hwnd)
+ return stw_framebuffer_from_hwnd_locked(hwnd);
+
+ for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
+ if (fb->hDC == hdc) {
+ pipe_mutex_lock(fb->mutex);
+ break;
+ }
+
+ return fb;
+}
+
+
+/**
+ * Given an hdc, return the corresponding stw_framebuffer.
+ */
+struct stw_framebuffer *
+stw_framebuffer_from_hdc(
+ HDC hdc )
+{
+ struct stw_framebuffer *fb;
+
+ pipe_mutex_lock( stw_dev->fb_mutex );
+ fb = stw_framebuffer_from_hdc_locked(hdc);
+ pipe_mutex_unlock( stw_dev->fb_mutex );
+
+ return fb;
+}
+
+
+/**
+ * Given an hdc, return the corresponding stw_framebuffer.
+ */
+struct stw_framebuffer *
+stw_framebuffer_from_hwnd(
+ HWND hwnd )
+{
+ struct stw_framebuffer *fb;
+
+ pipe_mutex_lock( stw_dev->fb_mutex );
+ fb = stw_framebuffer_from_hwnd_locked(hwnd);
+ pipe_mutex_unlock( stw_dev->fb_mutex );
+
+ return fb;
+}
+
+
+BOOL
+stw_pixelformat_set(
+ HDC hdc,
+ int iPixelFormat )
+{
+ uint count;
+ uint index;
+ struct stw_framebuffer *fb;
+
+ index = (uint) iPixelFormat - 1;
+ count = stw_pixelformat_get_extended_count();
+ if (index >= count)
+ return FALSE;
+
+ fb = stw_framebuffer_from_hdc_locked(hdc);
+ if(fb) {
+ /* SetPixelFormat must be called only once */
+ stw_framebuffer_release( fb );
+ return FALSE;
+ }
+
+ fb = stw_framebuffer_create(hdc, iPixelFormat);
+ if(!fb) {
+ return FALSE;
+ }
+
+ stw_framebuffer_release( fb );
+
+ /* Some applications mistakenly use the undocumented wglSetPixelFormat
+ * function instead of SetPixelFormat, so we call SetPixelFormat here to
+ * avoid opengl32.dll's wglCreateContext to fail */
+ if (GetPixelFormat(hdc) == 0) {
+ SetPixelFormat(hdc, iPixelFormat, NULL);
+ }
+
+ return TRUE;
+}
+
+
+int
+stw_pixelformat_get(
+ HDC hdc )
+{
+ int iPixelFormat = 0;
+ struct stw_framebuffer *fb;
+
+ fb = stw_framebuffer_from_hdc(hdc);
+ if(fb) {
+ iPixelFormat = fb->iPixelFormat;
+ stw_framebuffer_release(fb);
+ }
+
+ return iPixelFormat;
+}
+
+
+BOOL
+stw_swap_buffers(
+ HDC hdc )
+{
+ struct stw_framebuffer *fb;
+ struct pipe_screen *screen;
+ struct pipe_surface *surface;
+
+ fb = stw_framebuffer_from_hdc( hdc );
+ if (fb == NULL)
+ return FALSE;
+
+ if (!(fb->pfi->pfd.dwFlags & PFD_DOUBLEBUFFER)) {
+ stw_framebuffer_release(fb);
+ return TRUE;
+ }
+
+ /* If we're swapping the buffer associated with the current context
+ * we have to flush any pending rendering commands first.
+ */
+ st_notify_swapbuffers( fb->stfb );
+
+ screen = stw_dev->screen;
+
+ if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surface )) {
+ /* FIXME: this shouldn't happen, but does on glean */
+ stw_framebuffer_release(fb);
+ return FALSE;
+ }
+
+#ifdef DEBUG
+ if(stw_dev->trace_running) {
+ screen = trace_screen(screen)->screen;
+ surface = trace_surface(surface)->surface;
+ }
+#endif
+
+ stw_dev->stw_winsys->flush_frontbuffer( screen, surface, hdc );
+
+ stw_framebuffer_update(fb);
+ stw_framebuffer_release(fb);
+
+ return TRUE;
+}
+
+
+BOOL
+stw_swap_layer_buffers(
+ HDC hdc,
+ UINT fuPlanes )
+{
+ if(fuPlanes & WGL_SWAP_MAIN_PLANE)
+ return stw_swap_buffers(hdc);
+
+ return FALSE;
+}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef STW_FRAMEBUFFER_H
+#define STW_FRAMEBUFFER_H
+
+#include <windows.h>
+
+#include "main/mtypes.h"
+
+#include "pipe/p_thread.h"
+
+struct stw_pixelformat_info;
+
+/**
+ * Windows framebuffer, derived from gl_framebuffer.
+ */
+struct stw_framebuffer
+{
+ /**
+ * This mutex has two purposes:
+ * - protect the access to the mutable data members below
+ * - prevent the the framebuffer from being deleted while being accessed.
+ *
+ * It is OK to lock this mutex while holding the stw_device::fb_mutex lock,
+ * but the opposite must never happen.
+ */
+ pipe_mutex mutex;
+
+ /*
+ * Immutable members.
+ *
+ * Note that even access to immutable members implies acquiring the mutex
+ * above, to prevent the framebuffer from being destroyed.
+ */
+
+ HDC hDC;
+ HWND hWnd;
+
+ int iPixelFormat;
+ const struct stw_pixelformat_info *pfi;
+ GLvisual visual;
+
+ /*
+ * Mutable members.
+ */
+
+ struct st_framebuffer *stfb;
+
+ /* FIXME: Make this work for multiple contexts bound to the same framebuffer */
+ boolean must_resize;
+ unsigned width;
+ unsigned height;
+
+ /**
+ * This is protected by stw_device::fb_mutex, not the mutex above.
+ *
+ * Deletions must be done by first acquiring stw_device::fb_mutex, and then
+ * acquiring the stw_framebuffer::mutex of the framebuffer to be deleted.
+ * This ensures that nobody else is reading/writing to the.
+ *
+ * It is not necessary to aquire the mutex above to navigate the linked list
+ * given that deletions are done with stw_device::fb_mutex held, so no other
+ * thread can delete.
+ */
+ struct stw_framebuffer *next;
+};
+
+
+/**
+ * Create a new framebuffer object which will correspond to the given HDC.
+ *
+ * This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
+ * must be called when done
+ */
+struct stw_framebuffer *
+stw_framebuffer_create(
+ HDC hdc,
+ int iPixelFormat );
+
+/**
+ * Search a framebuffer with a matching HWND.
+ *
+ * This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
+ * must be called when done
+ */
+struct stw_framebuffer *
+stw_framebuffer_from_hwnd(
+ HWND hwnd );
+
+/**
+ * Search a framebuffer with a matching HDC.
+ *
+ * This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
+ * must be called when done
+ */
+struct stw_framebuffer *
+stw_framebuffer_from_hdc(
+ HDC hdc );
+
+BOOL
+stw_framebuffer_allocate(
+ struct stw_framebuffer *fb );
+
+void
+stw_framebuffer_update(
+ struct stw_framebuffer *fb);
+
+/**
+ * Release stw_framebuffer::mutex lock. This framebuffer must not be accessed
+ * after calling this function, as it may have been deleted by another thread
+ * in the meanwhile.
+ */
+void
+stw_framebuffer_release(
+ struct stw_framebuffer *fb);
+
+/**
+ * Cleanup any existing framebuffers when exiting application.
+ */
+void
+stw_framebuffer_cleanup(void);
+
+#endif /* STW_FRAMEBUFFER_H */
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <windows.h>
+
+#define WGL_WGLEXT_PROTOTYPES
+
+#include <GL/gl.h>
+#include <GL/wglext.h>
+
+#include "glapi/glapi.h"
+#include "stw_public.h"
+#include "stw_ext_gallium.h"
+
+struct stw_extension_entry
+{
+ const char *name;
+ PROC proc;
+};
+
+#define STW_EXTENSION_ENTRY(P) { #P, (PROC) P }
+
+static const struct stw_extension_entry stw_extension_entries[] = {
+
+ /* WGL_ARB_extensions_string */
+ STW_EXTENSION_ENTRY( wglGetExtensionsStringARB ),
+
+ /* WGL_ARB_pixel_format */
+ STW_EXTENSION_ENTRY( wglChoosePixelFormatARB ),
+ STW_EXTENSION_ENTRY( wglGetPixelFormatAttribfvARB ),
+ STW_EXTENSION_ENTRY( wglGetPixelFormatAttribivARB ),
+
+ /* WGL_EXT_extensions_string */
+ STW_EXTENSION_ENTRY( wglGetExtensionsStringEXT ),
+
+ /* WGL_EXT_swap_interval */
+ STW_EXTENSION_ENTRY( wglGetSwapIntervalEXT ),
+ STW_EXTENSION_ENTRY( wglSwapIntervalEXT ),
+
+ /* WGL_EXT_gallium ? */
+ STW_EXTENSION_ENTRY( wglGetGalliumScreenMESA ),
+ STW_EXTENSION_ENTRY( wglCreateGalliumContextMESA ),
+
+ { NULL, NULL }
+};
+
+PROC
+stw_get_proc_address(
+ LPCSTR lpszProc )
+{
+ const struct stw_extension_entry *entry;
+
+ if (lpszProc[0] == 'w' && lpszProc[1] == 'g' && lpszProc[2] == 'l')
+ for (entry = stw_extension_entries; entry->name; entry++)
+ if (strcmp( lpszProc, entry->name ) == 0)
+ return entry->proc;
+
+ if (lpszProc[0] == 'g' && lpszProc[1] == 'l')
+ return (PROC) _glapi_get_proc_address( lpszProc );
+
+ return NULL;
+}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <windows.h>
+#include <stdio.h>
+
+#include "GL/gl.h"
+
+#include "util/u_debug.h"
+#include "pipe/p_thread.h"
+
+#include "stw_public.h"
+#include "stw_icd.h"
+
+#define DBG 0
+
+
+BOOL APIENTRY
+DrvCopyContext(
+ DHGLRC dhrcSource,
+ DHGLRC dhrcDest,
+ UINT fuMask )
+{
+ return stw_copy_context(dhrcSource, dhrcDest, fuMask);
+}
+
+
+DHGLRC APIENTRY
+DrvCreateLayerContext(
+ HDC hdc,
+ INT iLayerPlane )
+{
+ DHGLRC r;
+
+ r = stw_create_layer_context( hdc, iLayerPlane );
+
+ if (DBG)
+ debug_printf( "%s( %p, %i ) = %lu\n",
+ __FUNCTION__, hdc, iLayerPlane, r );
+
+ return r;
+}
+
+DHGLRC APIENTRY
+DrvCreateContext(
+ HDC hdc )
+{
+ return DrvCreateLayerContext( hdc, 0 );
+}
+
+BOOL APIENTRY
+DrvDeleteContext(
+ DHGLRC dhglrc )
+{
+ BOOL r;
+
+ r = stw_delete_context( dhglrc );
+
+ if (DBG)
+ debug_printf( "%s( %lu ) = %u\n",
+ __FUNCTION__, dhglrc, r );
+
+ return r;
+}
+
+BOOL APIENTRY
+DrvDescribeLayerPlane(
+ HDC hdc,
+ INT iPixelFormat,
+ INT iLayerPlane,
+ UINT nBytes,
+ LPLAYERPLANEDESCRIPTOR plpd )
+{
+ if (DBG)
+ debug_printf( "%s\n", __FUNCTION__ );
+
+ return FALSE;
+}
+
+LONG APIENTRY
+DrvDescribePixelFormat(
+ HDC hdc,
+ INT iPixelFormat,
+ ULONG cjpfd,
+ PIXELFORMATDESCRIPTOR *ppfd )
+{
+ LONG r;
+
+ r = stw_pixelformat_describe( hdc, iPixelFormat, cjpfd, ppfd );
+
+ if (DBG)
+ debug_printf( "%s( %p, %i, %lu, %p ) = %li\n",
+ __FUNCTION__, hdc, iPixelFormat, cjpfd, ppfd, r );
+
+ return r;
+}
+
+int APIENTRY
+DrvGetLayerPaletteEntries(
+ HDC hdc,
+ INT iLayerPlane,
+ INT iStart,
+ INT cEntries,
+ COLORREF *pcr )
+{
+ if (DBG)
+ debug_printf( "%s\n", __FUNCTION__ );
+
+ return 0;
+}
+
+PROC APIENTRY
+DrvGetProcAddress(
+ LPCSTR lpszProc )
+{
+ PROC r;
+
+ r = stw_get_proc_address( lpszProc );
+
+ if (DBG)
+ debug_printf( "%s( \"%s\" ) = %p\n", __FUNCTION__, lpszProc, r );
+
+ return r;
+}
+
+BOOL APIENTRY
+DrvRealizeLayerPalette(
+ HDC hdc,
+ INT iLayerPlane,
+ BOOL bRealize )
+{
+ if (DBG)
+ debug_printf( "%s\n", __FUNCTION__ );
+
+ return FALSE;
+}
+
+BOOL APIENTRY
+DrvReleaseContext(
+ DHGLRC dhglrc )
+{
+ return stw_release_context(dhglrc);
+}
+
+void APIENTRY
+DrvSetCallbackProcs(
+ INT nProcs,
+ PROC *pProcs )
+{
+ if (DBG)
+ debug_printf( "%s( %d, %p )\n", __FUNCTION__, nProcs, pProcs );
+
+ return;
+}
+
+
+/**
+ * Although WGL allows different dispatch entrypoints per context
+ */
+static const GLCLTPROCTABLE cpt =
+{
+ OPENGL_VERSION_110_ENTRIES,
+ {
+ &glNewList,
+ &glEndList,
+ &glCallList,
+ &glCallLists,
+ &glDeleteLists,
+ &glGenLists,
+ &glListBase,
+ &glBegin,
+ &glBitmap,
+ &glColor3b,
+ &glColor3bv,
+ &glColor3d,
+ &glColor3dv,
+ &glColor3f,
+ &glColor3fv,
+ &glColor3i,
+ &glColor3iv,
+ &glColor3s,
+ &glColor3sv,
+ &glColor3ub,
+ &glColor3ubv,
+ &glColor3ui,
+ &glColor3uiv,
+ &glColor3us,
+ &glColor3usv,
+ &glColor4b,
+ &glColor4bv,
+ &glColor4d,
+ &glColor4dv,
+ &glColor4f,
+ &glColor4fv,
+ &glColor4i,
+ &glColor4iv,
+ &glColor4s,
+ &glColor4sv,
+ &glColor4ub,
+ &glColor4ubv,
+ &glColor4ui,
+ &glColor4uiv,
+ &glColor4us,
+ &glColor4usv,
+ &glEdgeFlag,
+ &glEdgeFlagv,
+ &glEnd,
+ &glIndexd,
+ &glIndexdv,
+ &glIndexf,
+ &glIndexfv,
+ &glIndexi,
+ &glIndexiv,
+ &glIndexs,
+ &glIndexsv,
+ &glNormal3b,
+ &glNormal3bv,
+ &glNormal3d,
+ &glNormal3dv,
+ &glNormal3f,
+ &glNormal3fv,
+ &glNormal3i,
+ &glNormal3iv,
+ &glNormal3s,
+ &glNormal3sv,
+ &glRasterPos2d,
+ &glRasterPos2dv,
+ &glRasterPos2f,
+ &glRasterPos2fv,
+ &glRasterPos2i,
+ &glRasterPos2iv,
+ &glRasterPos2s,
+ &glRasterPos2sv,
+ &glRasterPos3d,
+ &glRasterPos3dv,
+ &glRasterPos3f,
+ &glRasterPos3fv,
+ &glRasterPos3i,
+ &glRasterPos3iv,
+ &glRasterPos3s,
+ &glRasterPos3sv,
+ &glRasterPos4d,
+ &glRasterPos4dv,
+ &glRasterPos4f,
+ &glRasterPos4fv,
+ &glRasterPos4i,
+ &glRasterPos4iv,
+ &glRasterPos4s,
+ &glRasterPos4sv,
+ &glRectd,
+ &glRectdv,
+ &glRectf,
+ &glRectfv,
+ &glRecti,
+ &glRectiv,
+ &glRects,
+ &glRectsv,
+ &glTexCoord1d,
+ &glTexCoord1dv,
+ &glTexCoord1f,
+ &glTexCoord1fv,
+ &glTexCoord1i,
+ &glTexCoord1iv,
+ &glTexCoord1s,
+ &glTexCoord1sv,
+ &glTexCoord2d,
+ &glTexCoord2dv,
+ &glTexCoord2f,
+ &glTexCoord2fv,
+ &glTexCoord2i,
+ &glTexCoord2iv,
+ &glTexCoord2s,
+ &glTexCoord2sv,
+ &glTexCoord3d,
+ &glTexCoord3dv,
+ &glTexCoord3f,
+ &glTexCoord3fv,
+ &glTexCoord3i,
+ &glTexCoord3iv,
+ &glTexCoord3s,
+ &glTexCoord3sv,
+ &glTexCoord4d,
+ &glTexCoord4dv,
+ &glTexCoord4f,
+ &glTexCoord4fv,
+ &glTexCoord4i,
+ &glTexCoord4iv,
+ &glTexCoord4s,
+ &glTexCoord4sv,
+ &glVertex2d,
+ &glVertex2dv,
+ &glVertex2f,
+ &glVertex2fv,
+ &glVertex2i,
+ &glVertex2iv,
+ &glVertex2s,
+ &glVertex2sv,
+ &glVertex3d,
+ &glVertex3dv,
+ &glVertex3f,
+ &glVertex3fv,
+ &glVertex3i,
+ &glVertex3iv,
+ &glVertex3s,
+ &glVertex3sv,
+ &glVertex4d,
+ &glVertex4dv,
+ &glVertex4f,
+ &glVertex4fv,
+ &glVertex4i,
+ &glVertex4iv,
+ &glVertex4s,
+ &glVertex4sv,
+ &glClipPlane,
+ &glColorMaterial,
+ &glCullFace,
+ &glFogf,
+ &glFogfv,
+ &glFogi,
+ &glFogiv,
+ &glFrontFace,
+ &glHint,
+ &glLightf,
+ &glLightfv,
+ &glLighti,
+ &glLightiv,
+ &glLightModelf,
+ &glLightModelfv,
+ &glLightModeli,
+ &glLightModeliv,
+ &glLineStipple,
+ &glLineWidth,
+ &glMaterialf,
+ &glMaterialfv,
+ &glMateriali,
+ &glMaterialiv,
+ &glPointSize,
+ &glPolygonMode,
+ &glPolygonStipple,
+ &glScissor,
+ &glShadeModel,
+ &glTexParameterf,
+ &glTexParameterfv,
+ &glTexParameteri,
+ &glTexParameteriv,
+ &glTexImage1D,
+ &glTexImage2D,
+ &glTexEnvf,
+ &glTexEnvfv,
+ &glTexEnvi,
+ &glTexEnviv,
+ &glTexGend,
+ &glTexGendv,
+ &glTexGenf,
+ &glTexGenfv,
+ &glTexGeni,
+ &glTexGeniv,
+ &glFeedbackBuffer,
+ &glSelectBuffer,
+ &glRenderMode,
+ &glInitNames,
+ &glLoadName,
+ &glPassThrough,
+ &glPopName,
+ &glPushName,
+ &glDrawBuffer,
+ &glClear,
+ &glClearAccum,
+ &glClearIndex,
+ &glClearColor,
+ &glClearStencil,
+ &glClearDepth,
+ &glStencilMask,
+ &glColorMask,
+ &glDepthMask,
+ &glIndexMask,
+ &glAccum,
+ &glDisable,
+ &glEnable,
+ &glFinish,
+ &glFlush,
+ &glPopAttrib,
+ &glPushAttrib,
+ &glMap1d,
+ &glMap1f,
+ &glMap2d,
+ &glMap2f,
+ &glMapGrid1d,
+ &glMapGrid1f,
+ &glMapGrid2d,
+ &glMapGrid2f,
+ &glEvalCoord1d,
+ &glEvalCoord1dv,
+ &glEvalCoord1f,
+ &glEvalCoord1fv,
+ &glEvalCoord2d,
+ &glEvalCoord2dv,
+ &glEvalCoord2f,
+ &glEvalCoord2fv,
+ &glEvalMesh1,
+ &glEvalPoint1,
+ &glEvalMesh2,
+ &glEvalPoint2,
+ &glAlphaFunc,
+ &glBlendFunc,
+ &glLogicOp,
+ &glStencilFunc,
+ &glStencilOp,
+ &glDepthFunc,
+ &glPixelZoom,
+ &glPixelTransferf,
+ &glPixelTransferi,
+ &glPixelStoref,
+ &glPixelStorei,
+ &glPixelMapfv,
+ &glPixelMapuiv,
+ &glPixelMapusv,
+ &glReadBuffer,
+ &glCopyPixels,
+ &glReadPixels,
+ &glDrawPixels,
+ &glGetBooleanv,
+ &glGetClipPlane,
+ &glGetDoublev,
+ &glGetError,
+ &glGetFloatv,
+ &glGetIntegerv,
+ &glGetLightfv,
+ &glGetLightiv,
+ &glGetMapdv,
+ &glGetMapfv,
+ &glGetMapiv,
+ &glGetMaterialfv,
+ &glGetMaterialiv,
+ &glGetPixelMapfv,
+ &glGetPixelMapuiv,
+ &glGetPixelMapusv,
+ &glGetPolygonStipple,
+ &glGetString,
+ &glGetTexEnvfv,
+ &glGetTexEnviv,
+ &glGetTexGendv,
+ &glGetTexGenfv,
+ &glGetTexGeniv,
+ &glGetTexImage,
+ &glGetTexParameterfv,
+ &glGetTexParameteriv,
+ &glGetTexLevelParameterfv,
+ &glGetTexLevelParameteriv,
+ &glIsEnabled,
+ &glIsList,
+ &glDepthRange,
+ &glFrustum,
+ &glLoadIdentity,
+ &glLoadMatrixf,
+ &glLoadMatrixd,
+ &glMatrixMode,
+ &glMultMatrixf,
+ &glMultMatrixd,
+ &glOrtho,
+ &glPopMatrix,
+ &glPushMatrix,
+ &glRotated,
+ &glRotatef,
+ &glScaled,
+ &glScalef,
+ &glTranslated,
+ &glTranslatef,
+ &glViewport,
+ &glArrayElement,
+ &glBindTexture,
+ &glColorPointer,
+ &glDisableClientState,
+ &glDrawArrays,
+ &glDrawElements,
+ &glEdgeFlagPointer,
+ &glEnableClientState,
+ &glIndexPointer,
+ &glIndexub,
+ &glIndexubv,
+ &glInterleavedArrays,
+ &glNormalPointer,
+ &glPolygonOffset,
+ &glTexCoordPointer,
+ &glVertexPointer,
+ &glAreTexturesResident,
+ &glCopyTexImage1D,
+ &glCopyTexImage2D,
+ &glCopyTexSubImage1D,
+ &glCopyTexSubImage2D,
+ &glDeleteTextures,
+ &glGenTextures,
+ &glGetPointerv,
+ &glIsTexture,
+ &glPrioritizeTextures,
+ &glTexSubImage1D,
+ &glTexSubImage2D,
+ &glPopClientAttrib,
+ &glPushClientAttrib
+ }
+};
+
+
+PGLCLTPROCTABLE APIENTRY
+DrvSetContext(
+ HDC hdc,
+ DHGLRC dhglrc,
+ PFN_SETPROCTABLE pfnSetProcTable )
+{
+ PGLCLTPROCTABLE r = (PGLCLTPROCTABLE)&cpt;
+
+ if (!stw_make_current( hdc, dhglrc ))
+ r = NULL;
+
+ if (DBG)
+ debug_printf( "%s( 0x%p, %lu, 0x%p ) = %p\n",
+ __FUNCTION__, hdc, dhglrc, pfnSetProcTable, r );
+
+ return r;
+}
+
+int APIENTRY
+DrvSetLayerPaletteEntries(
+ HDC hdc,
+ INT iLayerPlane,
+ INT iStart,
+ INT cEntries,
+ CONST COLORREF *pcr )
+{
+ if (DBG)
+ debug_printf( "%s\n", __FUNCTION__ );
+
+ return 0;
+}
+
+BOOL APIENTRY
+DrvSetPixelFormat(
+ HDC hdc,
+ LONG iPixelFormat )
+{
+ BOOL r;
+
+ r = stw_pixelformat_set( hdc, iPixelFormat );
+
+ if (DBG)
+ debug_printf( "%s( %p, %li ) = %s\n", __FUNCTION__, hdc, iPixelFormat, r ? "TRUE" : "FALSE" );
+
+ return r;
+}
+
+BOOL APIENTRY
+DrvShareLists(
+ DHGLRC dhglrc1,
+ DHGLRC dhglrc2 )
+{
+ if (DBG)
+ debug_printf( "%s\n", __FUNCTION__ );
+
+ return stw_share_lists(dhglrc1, dhglrc2);
+}
+
+BOOL APIENTRY
+DrvSwapBuffers(
+ HDC hdc )
+{
+ if (DBG)
+ debug_printf( "%s( %p )\n", __FUNCTION__, hdc );
+
+ return stw_swap_buffers( hdc );
+}
+
+BOOL APIENTRY
+DrvSwapLayerBuffers(
+ HDC hdc,
+ UINT fuPlanes )
+{
+ if (DBG)
+ debug_printf( "%s\n", __FUNCTION__ );
+
+ return stw_swap_layer_buffers( hdc, fuPlanes );
+}
+
+BOOL APIENTRY
+DrvValidateVersion(
+ ULONG ulVersion )
+{
+ if (DBG)
+ debug_printf( "%s( %lu )\n", __FUNCTION__, ulVersion );
+
+ /* TODO: get the expected version from the winsys */
+
+ return ulVersion == 1;
+}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef STW_ICD_H
+#define STW_ICD_H
+
+
+#include <windows.h>
+
+#include "GL/gl.h"
+
+
+typedef ULONG DHGLRC;
+
+#define OPENGL_VERSION_110_ENTRIES 336
+
+struct __GLdispatchTableRec
+{
+ void (GLAPIENTRY * NewList)(GLuint, GLenum);
+ void (GLAPIENTRY * EndList)(void);
+ void (GLAPIENTRY * CallList)(GLuint);
+ void (GLAPIENTRY * CallLists)(GLsizei, GLenum, const GLvoid *);
+ void (GLAPIENTRY * DeleteLists)(GLuint, GLsizei);
+ GLuint (GLAPIENTRY * GenLists)(GLsizei);
+ void (GLAPIENTRY * ListBase)(GLuint);
+ void (GLAPIENTRY * Begin)(GLenum);
+ void (GLAPIENTRY * Bitmap)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *);
+ void (GLAPIENTRY * Color3b)(GLbyte, GLbyte, GLbyte);
+ void (GLAPIENTRY * Color3bv)(const GLbyte *);
+ void (GLAPIENTRY * Color3d)(GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * Color3dv)(const GLdouble *);
+ void (GLAPIENTRY * Color3f)(GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * Color3fv)(const GLfloat *);
+ void (GLAPIENTRY * Color3i)(GLint, GLint, GLint);
+ void (GLAPIENTRY * Color3iv)(const GLint *);
+ void (GLAPIENTRY * Color3s)(GLshort, GLshort, GLshort);
+ void (GLAPIENTRY * Color3sv)(const GLshort *);
+ void (GLAPIENTRY * Color3ub)(GLubyte, GLubyte, GLubyte);
+ void (GLAPIENTRY * Color3ubv)(const GLubyte *);
+ void (GLAPIENTRY * Color3ui)(GLuint, GLuint, GLuint);
+ void (GLAPIENTRY * Color3uiv)(const GLuint *);
+ void (GLAPIENTRY * Color3us)(GLushort, GLushort, GLushort);
+ void (GLAPIENTRY * Color3usv)(const GLushort *);
+ void (GLAPIENTRY * Color4b)(GLbyte, GLbyte, GLbyte, GLbyte);
+ void (GLAPIENTRY * Color4bv)(const GLbyte *);
+ void (GLAPIENTRY * Color4d)(GLdouble, GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * Color4dv)(const GLdouble *);
+ void (GLAPIENTRY * Color4f)(GLfloat, GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * Color4fv)(const GLfloat *);
+ void (GLAPIENTRY * Color4i)(GLint, GLint, GLint, GLint);
+ void (GLAPIENTRY * Color4iv)(const GLint *);
+ void (GLAPIENTRY * Color4s)(GLshort, GLshort, GLshort, GLshort);
+ void (GLAPIENTRY * Color4sv)(const GLshort *);
+ void (GLAPIENTRY * Color4ub)(GLubyte, GLubyte, GLubyte, GLubyte);
+ void (GLAPIENTRY * Color4ubv)(const GLubyte *);
+ void (GLAPIENTRY * Color4ui)(GLuint, GLuint, GLuint, GLuint);
+ void (GLAPIENTRY * Color4uiv)(const GLuint *);
+ void (GLAPIENTRY * Color4us)(GLushort, GLushort, GLushort, GLushort);
+ void (GLAPIENTRY * Color4usv)(const GLushort *);
+ void (GLAPIENTRY * EdgeFlag)(GLboolean);
+ void (GLAPIENTRY * EdgeFlagv)(const GLboolean *);
+ void (GLAPIENTRY * End)(void);
+ void (GLAPIENTRY * Indexd)(GLdouble);
+ void (GLAPIENTRY * Indexdv)(const GLdouble *);
+ void (GLAPIENTRY * Indexf)(GLfloat);
+ void (GLAPIENTRY * Indexfv)(const GLfloat *);
+ void (GLAPIENTRY * Indexi)(GLint);
+ void (GLAPIENTRY * Indexiv)(const GLint *);
+ void (GLAPIENTRY * Indexs)(GLshort);
+ void (GLAPIENTRY * Indexsv)(const GLshort *);
+ void (GLAPIENTRY * Normal3b)(GLbyte, GLbyte, GLbyte);
+ void (GLAPIENTRY * Normal3bv)(const GLbyte *);
+ void (GLAPIENTRY * Normal3d)(GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * Normal3dv)(const GLdouble *);
+ void (GLAPIENTRY * Normal3f)(GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * Normal3fv)(const GLfloat *);
+ void (GLAPIENTRY * Normal3i)(GLint, GLint, GLint);
+ void (GLAPIENTRY * Normal3iv)(const GLint *);
+ void (GLAPIENTRY * Normal3s)(GLshort, GLshort, GLshort);
+ void (GLAPIENTRY * Normal3sv)(const GLshort *);
+ void (GLAPIENTRY * RasterPos2d)(GLdouble, GLdouble);
+ void (GLAPIENTRY * RasterPos2dv)(const GLdouble *);
+ void (GLAPIENTRY * RasterPos2f)(GLfloat, GLfloat);
+ void (GLAPIENTRY * RasterPos2fv)(const GLfloat *);
+ void (GLAPIENTRY * RasterPos2i)(GLint, GLint);
+ void (GLAPIENTRY * RasterPos2iv)(const GLint *);
+ void (GLAPIENTRY * RasterPos2s)(GLshort, GLshort);
+ void (GLAPIENTRY * RasterPos2sv)(const GLshort *);
+ void (GLAPIENTRY * RasterPos3d)(GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * RasterPos3dv)(const GLdouble *);
+ void (GLAPIENTRY * RasterPos3f)(GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * RasterPos3fv)(const GLfloat *);
+ void (GLAPIENTRY * RasterPos3i)(GLint, GLint, GLint);
+ void (GLAPIENTRY * RasterPos3iv)(const GLint *);
+ void (GLAPIENTRY * RasterPos3s)(GLshort, GLshort, GLshort);
+ void (GLAPIENTRY * RasterPos3sv)(const GLshort *);
+ void (GLAPIENTRY * RasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * RasterPos4dv)(const GLdouble *);
+ void (GLAPIENTRY * RasterPos4f)(GLfloat, GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * RasterPos4fv)(const GLfloat *);
+ void (GLAPIENTRY * RasterPos4i)(GLint, GLint, GLint, GLint);
+ void (GLAPIENTRY * RasterPos4iv)(const GLint *);
+ void (GLAPIENTRY * RasterPos4s)(GLshort, GLshort, GLshort, GLshort);
+ void (GLAPIENTRY * RasterPos4sv)(const GLshort *);
+ void (GLAPIENTRY * Rectd)(GLdouble, GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * Rectdv)(const GLdouble *, const GLdouble *);
+ void (GLAPIENTRY * Rectf)(GLfloat, GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * Rectfv)(const GLfloat *, const GLfloat *);
+ void (GLAPIENTRY * Recti)(GLint, GLint, GLint, GLint);
+ void (GLAPIENTRY * Rectiv)(const GLint *, const GLint *);
+ void (GLAPIENTRY * Rects)(GLshort, GLshort, GLshort, GLshort);
+ void (GLAPIENTRY * Rectsv)(const GLshort *, const GLshort *);
+ void (GLAPIENTRY * TexCoord1d)(GLdouble);
+ void (GLAPIENTRY * TexCoord1dv)(const GLdouble *);
+ void (GLAPIENTRY * TexCoord1f)(GLfloat);
+ void (GLAPIENTRY * TexCoord1fv)(const GLfloat *);
+ void (GLAPIENTRY * TexCoord1i)(GLint);
+ void (GLAPIENTRY * TexCoord1iv)(const GLint *);
+ void (GLAPIENTRY * TexCoord1s)(GLshort);
+ void (GLAPIENTRY * TexCoord1sv)(const GLshort *);
+ void (GLAPIENTRY * TexCoord2d)(GLdouble, GLdouble);
+ void (GLAPIENTRY * TexCoord2dv)(const GLdouble *);
+ void (GLAPIENTRY * TexCoord2f)(GLfloat, GLfloat);
+ void (GLAPIENTRY * TexCoord2fv)(const GLfloat *);
+ void (GLAPIENTRY * TexCoord2i)(GLint, GLint);
+ void (GLAPIENTRY * TexCoord2iv)(const GLint *);
+ void (GLAPIENTRY * TexCoord2s)(GLshort, GLshort);
+ void (GLAPIENTRY * TexCoord2sv)(const GLshort *);
+ void (GLAPIENTRY * TexCoord3d)(GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * TexCoord3dv)(const GLdouble *);
+ void (GLAPIENTRY * TexCoord3f)(GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * TexCoord3fv)(const GLfloat *);
+ void (GLAPIENTRY * TexCoord3i)(GLint, GLint, GLint);
+ void (GLAPIENTRY * TexCoord3iv)(const GLint *);
+ void (GLAPIENTRY * TexCoord3s)(GLshort, GLshort, GLshort);
+ void (GLAPIENTRY * TexCoord3sv)(const GLshort *);
+ void (GLAPIENTRY * TexCoord4d)(GLdouble, GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * TexCoord4dv)(const GLdouble *);
+ void (GLAPIENTRY * TexCoord4f)(GLfloat, GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * TexCoord4fv)(const GLfloat *);
+ void (GLAPIENTRY * TexCoord4i)(GLint, GLint, GLint, GLint);
+ void (GLAPIENTRY * TexCoord4iv)(const GLint *);
+ void (GLAPIENTRY * TexCoord4s)(GLshort, GLshort, GLshort, GLshort);
+ void (GLAPIENTRY * TexCoord4sv)(const GLshort *);
+ void (GLAPIENTRY * Vertex2d)(GLdouble, GLdouble);
+ void (GLAPIENTRY * Vertex2dv)(const GLdouble *);
+ void (GLAPIENTRY * Vertex2f)(GLfloat, GLfloat);
+ void (GLAPIENTRY * Vertex2fv)(const GLfloat *);
+ void (GLAPIENTRY * Vertex2i)(GLint, GLint);
+ void (GLAPIENTRY * Vertex2iv)(const GLint *);
+ void (GLAPIENTRY * Vertex2s)(GLshort, GLshort);
+ void (GLAPIENTRY * Vertex2sv)(const GLshort *);
+ void (GLAPIENTRY * Vertex3d)(GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * Vertex3dv)(const GLdouble *);
+ void (GLAPIENTRY * Vertex3f)(GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * Vertex3fv)(const GLfloat *);
+ void (GLAPIENTRY * Vertex3i)(GLint, GLint, GLint);
+ void (GLAPIENTRY * Vertex3iv)(const GLint *);
+ void (GLAPIENTRY * Vertex3s)(GLshort, GLshort, GLshort);
+ void (GLAPIENTRY * Vertex3sv)(const GLshort *);
+ void (GLAPIENTRY * Vertex4d)(GLdouble, GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * Vertex4dv)(const GLdouble *);
+ void (GLAPIENTRY * Vertex4f)(GLfloat, GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * Vertex4fv)(const GLfloat *);
+ void (GLAPIENTRY * Vertex4i)(GLint, GLint, GLint, GLint);
+ void (GLAPIENTRY * Vertex4iv)(const GLint *);
+ void (GLAPIENTRY * Vertex4s)(GLshort, GLshort, GLshort, GLshort);
+ void (GLAPIENTRY * Vertex4sv)(const GLshort *);
+ void (GLAPIENTRY * ClipPlane)(GLenum, const GLdouble *);
+ void (GLAPIENTRY * ColorMaterial)(GLenum, GLenum);
+ void (GLAPIENTRY * CullFace)(GLenum);
+ void (GLAPIENTRY * Fogf)(GLenum, GLfloat);
+ void (GLAPIENTRY * Fogfv)(GLenum, const GLfloat *);
+ void (GLAPIENTRY * Fogi)(GLenum, GLint);
+ void (GLAPIENTRY * Fogiv)(GLenum, const GLint *);
+ void (GLAPIENTRY * FrontFace)(GLenum);
+ void (GLAPIENTRY * Hint)(GLenum, GLenum);
+ void (GLAPIENTRY * Lightf)(GLenum, GLenum, GLfloat);
+ void (GLAPIENTRY * Lightfv)(GLenum, GLenum, const GLfloat *);
+ void (GLAPIENTRY * Lighti)(GLenum, GLenum, GLint);
+ void (GLAPIENTRY * Lightiv)(GLenum, GLenum, const GLint *);
+ void (GLAPIENTRY * LightModelf)(GLenum, GLfloat);
+ void (GLAPIENTRY * LightModelfv)(GLenum, const GLfloat *);
+ void (GLAPIENTRY * LightModeli)(GLenum, GLint);
+ void (GLAPIENTRY * LightModeliv)(GLenum, const GLint *);
+ void (GLAPIENTRY * LineStipple)(GLint, GLushort);
+ void (GLAPIENTRY * LineWidth)(GLfloat);
+ void (GLAPIENTRY * Materialf)(GLenum, GLenum, GLfloat);
+ void (GLAPIENTRY * Materialfv)(GLenum, GLenum, const GLfloat *);
+ void (GLAPIENTRY * Materiali)(GLenum, GLenum, GLint);
+ void (GLAPIENTRY * Materialiv)(GLenum, GLenum, const GLint *);
+ void (GLAPIENTRY * PointSize)(GLfloat);
+ void (GLAPIENTRY * PolygonMode)(GLenum, GLenum);
+ void (GLAPIENTRY * PolygonStipple)(const GLubyte *);
+ void (GLAPIENTRY * Scissor)(GLint, GLint, GLsizei, GLsizei);
+ void (GLAPIENTRY * ShadeModel)(GLenum);
+ void (GLAPIENTRY * TexParameterf)(GLenum, GLenum, GLfloat);
+ void (GLAPIENTRY * TexParameterfv)(GLenum, GLenum, const GLfloat *);
+ void (GLAPIENTRY * TexParameteri)(GLenum, GLenum, GLint);
+ void (GLAPIENTRY * TexParameteriv)(GLenum, GLenum, const GLint *);
+ void (GLAPIENTRY * TexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+ void (GLAPIENTRY * TexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+ void (GLAPIENTRY * TexEnvf)(GLenum, GLenum, GLfloat);
+ void (GLAPIENTRY * TexEnvfv)(GLenum, GLenum, const GLfloat *);
+ void (GLAPIENTRY * TexEnvi)(GLenum, GLenum, GLint);
+ void (GLAPIENTRY * TexEnviv)(GLenum, GLenum, const GLint *);
+ void (GLAPIENTRY * TexGend)(GLenum, GLenum, GLdouble);
+ void (GLAPIENTRY * TexGendv)(GLenum, GLenum, const GLdouble *);
+ void (GLAPIENTRY * TexGenf)(GLenum, GLenum, GLfloat);
+ void (GLAPIENTRY * TexGenfv)(GLenum, GLenum, const GLfloat *);
+ void (GLAPIENTRY * TexGeni)(GLenum, GLenum, GLint);
+ void (GLAPIENTRY * TexGeniv)(GLenum, GLenum, const GLint *);
+ void (GLAPIENTRY * FeedbackBuffer)(GLsizei, GLenum, GLfloat *);
+ void (GLAPIENTRY * SelectBuffer)(GLsizei, GLuint *);
+ GLint (GLAPIENTRY * RenderMode)(GLenum);
+ void (GLAPIENTRY * InitNames)(void);
+ void (GLAPIENTRY * LoadName)(GLuint);
+ void (GLAPIENTRY * PassThrough)(GLfloat);
+ void (GLAPIENTRY * PopName)(void);
+ void (GLAPIENTRY * PushName)(GLuint);
+ void (GLAPIENTRY * DrawBuffer)(GLenum);
+ void (GLAPIENTRY * Clear)(GLbitfield);
+ void (GLAPIENTRY * ClearAccum)(GLfloat, GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * ClearIndex)(GLfloat);
+ void (GLAPIENTRY * ClearColor)(GLclampf, GLclampf, GLclampf, GLclampf);
+ void (GLAPIENTRY * ClearStencil)(GLint);
+ void (GLAPIENTRY * ClearDepth)(GLclampd);
+ void (GLAPIENTRY * StencilMask)(GLuint);
+ void (GLAPIENTRY * ColorMask)(GLboolean, GLboolean, GLboolean, GLboolean);
+ void (GLAPIENTRY * DepthMask)(GLboolean);
+ void (GLAPIENTRY * IndexMask)(GLuint);
+ void (GLAPIENTRY * Accum)(GLenum, GLfloat);
+ void (GLAPIENTRY * Disable)(GLenum);
+ void (GLAPIENTRY * Enable)(GLenum);
+ void (GLAPIENTRY * Finish)(void);
+ void (GLAPIENTRY * Flush)(void);
+ void (GLAPIENTRY * PopAttrib)(void);
+ void (GLAPIENTRY * PushAttrib)(GLbitfield);
+ void (GLAPIENTRY * Map1d)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *);
+ void (GLAPIENTRY * Map1f)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *);
+ void (GLAPIENTRY * Map2d)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *);
+ void (GLAPIENTRY * Map2f)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *);
+ void (GLAPIENTRY * MapGrid1d)(GLint, GLdouble, GLdouble);
+ void (GLAPIENTRY * MapGrid1f)(GLint, GLfloat, GLfloat);
+ void (GLAPIENTRY * MapGrid2d)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble);
+ void (GLAPIENTRY * MapGrid2f)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat);
+ void (GLAPIENTRY * EvalCoord1d)(GLdouble);
+ void (GLAPIENTRY * EvalCoord1dv)(const GLdouble *);
+ void (GLAPIENTRY * EvalCoord1f)(GLfloat);
+ void (GLAPIENTRY * EvalCoord1fv)(const GLfloat *);
+ void (GLAPIENTRY * EvalCoord2d)(GLdouble, GLdouble);
+ void (GLAPIENTRY * EvalCoord2dv)(const GLdouble *);
+ void (GLAPIENTRY * EvalCoord2f)(GLfloat, GLfloat);
+ void (GLAPIENTRY * EvalCoord2fv)(const GLfloat *);
+ void (GLAPIENTRY * EvalMesh1)(GLenum, GLint, GLint);
+ void (GLAPIENTRY * EvalPoint1)(GLint);
+ void (GLAPIENTRY * EvalMesh2)(GLenum, GLint, GLint, GLint, GLint);
+ void (GLAPIENTRY * EvalPoint2)(GLint, GLint);
+ void (GLAPIENTRY * AlphaFunc)(GLenum, GLclampf);
+ void (GLAPIENTRY * BlendFunc)(GLenum, GLenum);
+ void (GLAPIENTRY * LogicOp)(GLenum);
+ void (GLAPIENTRY * StencilFunc)(GLenum, GLint, GLuint);
+ void (GLAPIENTRY * StencilOp)(GLenum, GLenum, GLenum);
+ void (GLAPIENTRY * DepthFunc)(GLenum);
+ void (GLAPIENTRY * PixelZoom)(GLfloat, GLfloat);
+ void (GLAPIENTRY * PixelTransferf)(GLenum, GLfloat);
+ void (GLAPIENTRY * PixelTransferi)(GLenum, GLint);
+ void (GLAPIENTRY * PixelStoref)(GLenum, GLfloat);
+ void (GLAPIENTRY * PixelStorei)(GLenum, GLint);
+ void (GLAPIENTRY * PixelMapfv)(GLenum, GLint, const GLfloat *);
+ void (GLAPIENTRY * PixelMapuiv)(GLenum, GLint, const GLuint *);
+ void (GLAPIENTRY * PixelMapusv)(GLenum, GLint, const GLushort *);
+ void (GLAPIENTRY * ReadBuffer)(GLenum);
+ void (GLAPIENTRY * CopyPixels)(GLint, GLint, GLsizei, GLsizei, GLenum);
+ void (GLAPIENTRY * ReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *);
+ void (GLAPIENTRY * DrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+ void (GLAPIENTRY * GetBooleanv)(GLenum, GLboolean *);
+ void (GLAPIENTRY * GetClipPlane)(GLenum, GLdouble *);
+ void (GLAPIENTRY * GetDoublev)(GLenum, GLdouble *);
+ GLenum (GLAPIENTRY * GetError)(void);
+ void (GLAPIENTRY * GetFloatv)(GLenum, GLfloat *);
+ void (GLAPIENTRY * GetIntegerv)(GLenum, GLint *);
+ void (GLAPIENTRY * GetLightfv)(GLenum, GLenum, GLfloat *);
+ void (GLAPIENTRY * GetLightiv)(GLenum, GLenum, GLint *);
+ void (GLAPIENTRY * GetMapdv)(GLenum, GLenum, GLdouble *);
+ void (GLAPIENTRY * GetMapfv)(GLenum, GLenum, GLfloat *);
+ void (GLAPIENTRY * GetMapiv)(GLenum, GLenum, GLint *);
+ void (GLAPIENTRY * GetMaterialfv)(GLenum, GLenum, GLfloat *);
+ void (GLAPIENTRY * GetMaterialiv)(GLenum, GLenum, GLint *);
+ void (GLAPIENTRY * GetPixelMapfv)(GLenum, GLfloat *);
+ void (GLAPIENTRY * GetPixelMapuiv)(GLenum, GLuint *);
+ void (GLAPIENTRY * GetPixelMapusv)(GLenum, GLushort *);
+ void (GLAPIENTRY * GetPolygonStipple)(GLubyte *);
+ const GLubyte * (GLAPIENTRY * GetString)(GLenum);
+ void (GLAPIENTRY * GetTexEnvfv)(GLenum, GLenum, GLfloat *);
+ void (GLAPIENTRY * GetTexEnviv)(GLenum, GLenum, GLint *);
+ void (GLAPIENTRY * GetTexGendv)(GLenum, GLenum, GLdouble *);
+ void (GLAPIENTRY * GetTexGenfv)(GLenum, GLenum, GLfloat *);
+ void (GLAPIENTRY * GetTexGeniv)(GLenum, GLenum, GLint *);
+ void (GLAPIENTRY * GetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *);
+ void (GLAPIENTRY * GetTexParameterfv)(GLenum, GLenum, GLfloat *);
+ void (GLAPIENTRY * GetTexParameteriv)(GLenum, GLenum, GLint *);
+ void (GLAPIENTRY * GetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *);
+ void (GLAPIENTRY * GetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *);
+ GLboolean (GLAPIENTRY * IsEnabled)(GLenum);
+ GLboolean (GLAPIENTRY * IsList)(GLuint);
+ void (GLAPIENTRY * DepthRange)(GLclampd, GLclampd);
+ void (GLAPIENTRY * Frustum)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * LoadIdentity)(void);
+ void (GLAPIENTRY * LoadMatrixf)(const GLfloat *);
+ void (GLAPIENTRY * LoadMatrixd)(const GLdouble *);
+ void (GLAPIENTRY * MatrixMode)(GLenum);
+ void (GLAPIENTRY * MultMatrixf)(const GLfloat *);
+ void (GLAPIENTRY * MultMatrixd)(const GLdouble *);
+ void (GLAPIENTRY * Ortho)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * PopMatrix)(void);
+ void (GLAPIENTRY * PushMatrix)(void);
+ void (GLAPIENTRY * Rotated)(GLdouble, GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * Rotatef)(GLfloat, GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * Scaled)(GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * Scalef)(GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * Translated)(GLdouble, GLdouble, GLdouble);
+ void (GLAPIENTRY * Translatef)(GLfloat, GLfloat, GLfloat);
+ void (GLAPIENTRY * Viewport)(GLint, GLint, GLsizei, GLsizei);
+ void (GLAPIENTRY * ArrayElement)(GLint);
+ void (GLAPIENTRY * BindTexture)(GLenum, GLuint);
+ void (GLAPIENTRY * ColorPointer)(GLint, GLenum, GLsizei, const GLvoid *);
+ void (GLAPIENTRY * DisableClientState)(GLenum);
+ void (GLAPIENTRY * DrawArrays)(GLenum, GLint, GLsizei);
+ void (GLAPIENTRY * DrawElements)(GLenum, GLsizei, GLenum, const GLvoid *);
+ void (GLAPIENTRY * EdgeFlagPointer)(GLsizei, const GLvoid *);
+ void (GLAPIENTRY * EnableClientState)(GLenum);
+ void (GLAPIENTRY * IndexPointer)(GLenum, GLsizei, const GLvoid *);
+ void (GLAPIENTRY * Indexub)(GLubyte);
+ void (GLAPIENTRY * Indexubv)(const GLubyte *);
+ void (GLAPIENTRY * InterleavedArrays)(GLenum, GLsizei, const GLvoid *);
+ void (GLAPIENTRY * NormalPointer)(GLenum, GLsizei, const GLvoid *);
+ void (GLAPIENTRY * PolygonOffset)(GLfloat, GLfloat);
+ void (GLAPIENTRY * TexCoordPointer)(GLint, GLenum, GLsizei, const GLvoid *);
+ void (GLAPIENTRY * VertexPointer)(GLint, GLenum, GLsizei, const GLvoid *);
+ GLboolean (GLAPIENTRY * AreTexturesResident)(GLsizei, const GLuint *, GLboolean *);
+ void (GLAPIENTRY * CopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);
+ void (GLAPIENTRY * CopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
+ void (GLAPIENTRY * CopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei);
+ void (GLAPIENTRY * CopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+ void (GLAPIENTRY * DeleteTextures)(GLsizei, const GLuint *);
+ void (GLAPIENTRY * GenTextures)(GLsizei, GLuint *);
+ void (GLAPIENTRY * GetPointerv)(GLenum, GLvoid **);
+ GLboolean (GLAPIENTRY * IsTexture)(GLuint);
+ void (GLAPIENTRY * PrioritizeTextures)(GLsizei, const GLuint *, const GLclampf *);
+ void (GLAPIENTRY * TexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *);
+ void (GLAPIENTRY * TexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+ void (GLAPIENTRY * PopClientAttrib)(void);
+ void (GLAPIENTRY * PushClientAttrib)(GLbitfield);
+};
+
+typedef struct __GLdispatchTableRec GLDISPATCHTABLE;
+
+typedef struct _GLCLTPROCTABLE
+{
+ int cEntries;
+ GLDISPATCHTABLE glDispatchTable;
+} GLCLTPROCTABLE, * PGLCLTPROCTABLE;
+
+typedef VOID (APIENTRY * PFN_SETPROCTABLE)(PGLCLTPROCTABLE);
+
+BOOL APIENTRY
+DrvCopyContext(
+ DHGLRC dhrcSource,
+ DHGLRC dhrcDest,
+ UINT fuMask );
+
+DHGLRC APIENTRY
+DrvCreateLayerContext(
+ HDC hdc,
+ INT iLayerPlane );
+
+DHGLRC APIENTRY
+DrvCreateContext(
+ HDC hdc );
+
+BOOL APIENTRY
+DrvDeleteContext(
+ DHGLRC dhglrc );
+
+BOOL APIENTRY
+DrvDescribeLayerPlane(
+ HDC hdc,
+ INT iPixelFormat,
+ INT iLayerPlane,
+ UINT nBytes,
+ LPLAYERPLANEDESCRIPTOR plpd );
+
+LONG APIENTRY
+DrvDescribePixelFormat(
+ HDC hdc,
+ INT iPixelFormat,
+ ULONG cjpfd,
+ PIXELFORMATDESCRIPTOR *ppfd );
+
+int APIENTRY
+DrvGetLayerPaletteEntries(
+ HDC hdc,
+ INT iLayerPlane,
+ INT iStart,
+ INT cEntries,
+ COLORREF *pcr );
+
+PROC APIENTRY
+DrvGetProcAddress(
+ LPCSTR lpszProc );
+
+BOOL APIENTRY
+DrvRealizeLayerPalette(
+ HDC hdc,
+ INT iLayerPlane,
+ BOOL bRealize );
+
+BOOL APIENTRY
+DrvReleaseContext(
+ DHGLRC dhglrc );
+
+void APIENTRY
+DrvSetCallbackProcs(
+ INT nProcs,
+ PROC *pProcs );
+
+PGLCLTPROCTABLE APIENTRY
+DrvSetContext(
+ HDC hdc,
+ DHGLRC dhglrc,
+ PFN_SETPROCTABLE pfnSetProcTable );
+
+int APIENTRY
+DrvSetLayerPaletteEntries(
+ HDC hdc,
+ INT iLayerPlane,
+ INT iStart,
+ INT cEntries,
+ CONST COLORREF *pcr );
+
+BOOL APIENTRY
+DrvSetPixelFormat(
+ HDC hdc,
+ LONG iPixelFormat );
+
+BOOL APIENTRY
+DrvShareLists(
+ DHGLRC dhglrc1,
+ DHGLRC dhglrc2 );
+
+BOOL APIENTRY
+DrvSwapBuffers(
+ HDC hdc );
+
+BOOL APIENTRY
+DrvSwapLayerBuffers(
+ HDC hdc,
+ UINT fuPlanes );
+
+BOOL APIENTRY
+DrvValidateVersion(
+ ULONG ulVersion );
+
+#endif /* STW_ICD_H */
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/mtypes.h"
+#include "main/context.h"
+
+#include "pipe/p_format.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_screen.h"
+
+#include "util/u_debug.h"
+
+#include "stw_device.h"
+#include "stw_pixelformat.h"
+#include "stw_public.h"
+#include "stw_tls.h"
+
+
+struct stw_pf_color_info
+{
+ enum pipe_format format;
+ struct {
+ unsigned char red;
+ unsigned char green;
+ unsigned char blue;
+ unsigned char alpha;
+ } bits;
+ struct {
+ unsigned char red;
+ unsigned char green;
+ unsigned char blue;
+ unsigned char alpha;
+ } shift;
+};
+
+struct stw_pf_depth_info
+{
+ enum pipe_format format;
+ struct {
+ unsigned char depth;
+ unsigned char stencil;
+ } bits;
+};
+
+
+/* NOTE: order matters, since in otherwise equal circumstances the first
+ * format listed will get chosen */
+
+static const struct stw_pf_color_info
+stw_pf_color[] = {
+ /* no-alpha */
+ { PIPE_FORMAT_X8R8G8B8_UNORM, { 8, 8, 8, 0}, {16, 8, 0, 0} },
+ { PIPE_FORMAT_B8G8R8X8_UNORM, { 8, 8, 8, 0}, { 8, 16, 24, 0} },
+ { PIPE_FORMAT_R5G6B5_UNORM, { 5, 6, 5, 0}, {11, 5, 0, 0} },
+ /* alpha */
+ { PIPE_FORMAT_A8R8G8B8_UNORM, { 8, 8, 8, 8}, {16, 8, 0, 24} },
+ { PIPE_FORMAT_B8G8R8A8_UNORM, { 8, 8, 8, 8}, { 8, 16, 24, 0} },
+#if 0
+ { PIPE_FORMAT_A2B10G10R10_UNORM, {10, 10, 10, 2}, { 0, 10, 20, 30} },
+#endif
+ { PIPE_FORMAT_A1R5G5B5_UNORM, { 5, 5, 5, 1}, {10, 5, 0, 15} },
+ { PIPE_FORMAT_A4R4G4B4_UNORM, { 4, 4, 4, 4}, {16, 4, 0, 12} }
+};
+
+
+static const struct stw_pf_depth_info
+stw_pf_depth_stencil[] = {
+ /* pure depth */
+ { PIPE_FORMAT_Z32_UNORM, {32, 0} },
+ { PIPE_FORMAT_Z24X8_UNORM, {24, 0} },
+ { PIPE_FORMAT_X8Z24_UNORM, {24, 0} },
+ { PIPE_FORMAT_Z16_UNORM, {16, 0} },
+ /* pure stencil */
+ { PIPE_FORMAT_S8_UNORM, { 0, 8} },
+ /* combined depth-stencil */
+ { PIPE_FORMAT_S8Z24_UNORM, {24, 8} },
+ { PIPE_FORMAT_Z24S8_UNORM, {24, 8} }
+};
+
+
+static const boolean
+stw_pf_doublebuffer[] = {
+ FALSE,
+ TRUE,
+};
+
+
+const unsigned
+stw_pf_multisample[] = {
+ 0,
+ 4
+};
+
+
+static void
+stw_pixelformat_add(
+ struct stw_device *stw_dev,
+ const struct stw_pf_color_info *color,
+ const struct stw_pf_depth_info *depth,
+ unsigned accum,
+ boolean doublebuffer,
+ unsigned samples )
+{
+ boolean extended = FALSE;
+ struct stw_pixelformat_info *pfi;
+
+ assert(stw_dev->pixelformat_extended_count < STW_MAX_PIXELFORMATS);
+ if(stw_dev->pixelformat_extended_count >= STW_MAX_PIXELFORMATS)
+ return;
+
+ assert(pf_layout( color->format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
+ assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_R ) == color->bits.red );
+ assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_G ) == color->bits.green );
+ assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_B ) == color->bits.blue );
+ assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_A ) == color->bits.alpha );
+ assert(pf_layout( depth->format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
+ assert(pf_get_component_bits( depth->format, PIPE_FORMAT_COMP_Z ) == depth->bits.depth );
+ assert(pf_get_component_bits( depth->format, PIPE_FORMAT_COMP_S ) == depth->bits.stencil );
+
+ pfi = &stw_dev->pixelformats[stw_dev->pixelformat_extended_count];
+
+ memset(pfi, 0, sizeof *pfi);
+
+ pfi->color_format = color->format;
+ pfi->depth_stencil_format = depth->format;
+
+ pfi->pfd.nSize = sizeof pfi->pfd;
+ pfi->pfd.nVersion = 1;
+
+ pfi->pfd.dwFlags = PFD_SUPPORT_OPENGL;
+
+ /* TODO: also support non-native pixel formats */
+ pfi->pfd.dwFlags |= PFD_DRAW_TO_WINDOW ;
+
+ if (doublebuffer)
+ pfi->pfd.dwFlags |= PFD_DOUBLEBUFFER | PFD_SWAP_COPY;
+
+ pfi->pfd.iPixelType = PFD_TYPE_RGBA;
+
+ pfi->pfd.cColorBits = color->bits.red + color->bits.green + color->bits.blue + color->bits.alpha;
+ pfi->pfd.cRedBits = color->bits.red;
+ pfi->pfd.cRedShift = color->shift.red;
+ pfi->pfd.cGreenBits = color->bits.green;
+ pfi->pfd.cGreenShift = color->shift.green;
+ pfi->pfd.cBlueBits = color->bits.blue;
+ pfi->pfd.cBlueShift = color->shift.blue;
+ pfi->pfd.cAlphaBits = color->bits.alpha;
+ pfi->pfd.cAlphaShift = color->shift.alpha;
+ pfi->pfd.cAccumBits = 4*accum;
+ pfi->pfd.cAccumRedBits = accum;
+ pfi->pfd.cAccumGreenBits = accum;
+ pfi->pfd.cAccumBlueBits = accum;
+ pfi->pfd.cAccumAlphaBits = accum;
+ pfi->pfd.cDepthBits = depth->bits.depth;
+ pfi->pfd.cStencilBits = depth->bits.stencil;
+ pfi->pfd.cAuxBuffers = 0;
+ pfi->pfd.iLayerType = 0;
+ pfi->pfd.bReserved = 0;
+ pfi->pfd.dwLayerMask = 0;
+ pfi->pfd.dwVisibleMask = 0;
+ pfi->pfd.dwDamageMask = 0;
+
+ if(samples) {
+ pfi->numSampleBuffers = 1;
+ pfi->numSamples = samples;
+ extended = TRUE;
+ }
+
+ ++stw_dev->pixelformat_extended_count;
+
+ if(!extended) {
+ ++stw_dev->pixelformat_count;
+ assert(stw_dev->pixelformat_count == stw_dev->pixelformat_extended_count);
+ }
+}
+
+void
+stw_pixelformat_init( void )
+{
+ struct pipe_screen *screen = stw_dev->screen;
+ unsigned i, j, k, l;
+
+ assert( !stw_dev->pixelformat_count );
+ assert( !stw_dev->pixelformat_extended_count );
+
+ for(i = 0; i < Elements(stw_pf_multisample); ++i) {
+ unsigned samples = stw_pf_multisample[i];
+
+ /* FIXME: re-enabled MSAA when we can query it */
+ if(samples)
+ continue;
+
+ for(j = 0; j < Elements(stw_pf_color); ++j) {
+ const struct stw_pf_color_info *color = &stw_pf_color[j];
+
+ if(!screen->is_format_supported(screen, color->format, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET, 0))
+ continue;
+
+ for(k = 0; k < Elements(stw_pf_doublebuffer); ++k) {
+ unsigned doublebuffer = stw_pf_doublebuffer[k];
+
+ for(l = 0; l < Elements(stw_pf_depth_stencil); ++l) {
+ const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[l];
+
+ if(!screen->is_format_supported(screen, depth->format, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0))
+ continue;
+
+ stw_pixelformat_add( stw_dev, color, depth, 0, doublebuffer, samples );
+ stw_pixelformat_add( stw_dev, color, depth, 16, doublebuffer, samples );
+ }
+ }
+ }
+ }
+
+ assert( stw_dev->pixelformat_count <= stw_dev->pixelformat_extended_count );
+ assert( stw_dev->pixelformat_extended_count <= STW_MAX_PIXELFORMATS );
+}
+
+uint
+stw_pixelformat_get_count( void )
+{
+ return stw_dev->pixelformat_count;
+}
+
+uint
+stw_pixelformat_get_extended_count( void )
+{
+ return stw_dev->pixelformat_extended_count;
+}
+
+const struct stw_pixelformat_info *
+stw_pixelformat_get_info( uint index )
+{
+ assert( index < stw_dev->pixelformat_extended_count );
+
+ return &stw_dev->pixelformats[index];
+}
+
+
+void
+stw_pixelformat_visual(GLvisual *visual,
+ const struct stw_pixelformat_info *pfi )
+{
+ memset(visual, 0, sizeof *visual);
+ _mesa_initialize_visual(
+ visual,
+ (pfi->pfd.iPixelType == PFD_TYPE_RGBA) ? GL_TRUE : GL_FALSE,
+ (pfi->pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE,
+ (pfi->pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE,
+ pfi->pfd.cRedBits,
+ pfi->pfd.cGreenBits,
+ pfi->pfd.cBlueBits,
+ pfi->pfd.cAlphaBits,
+ (pfi->pfd.iPixelType == PFD_TYPE_COLORINDEX) ? pfi->pfd.cColorBits : 0,
+ pfi->pfd.cDepthBits,
+ pfi->pfd.cStencilBits,
+ pfi->pfd.cAccumRedBits,
+ pfi->pfd.cAccumGreenBits,
+ pfi->pfd.cAccumBlueBits,
+ pfi->pfd.cAccumAlphaBits,
+ pfi->numSamples );
+}
+
+
+int
+stw_pixelformat_describe(
+ HDC hdc,
+ int iPixelFormat,
+ UINT nBytes,
+ LPPIXELFORMATDESCRIPTOR ppfd )
+{
+ uint count;
+ uint index;
+ const struct stw_pixelformat_info *pfi;
+
+ (void) hdc;
+
+ count = stw_pixelformat_get_extended_count();
+ index = (uint) iPixelFormat - 1;
+
+ if (ppfd == NULL)
+ return count;
+ if (index >= count || nBytes != sizeof( PIXELFORMATDESCRIPTOR ))
+ return 0;
+
+ pfi = stw_pixelformat_get_info( index );
+
+ memcpy(ppfd, &pfi->pfd, sizeof( PIXELFORMATDESCRIPTOR ));
+
+ return count;
+}
+
+/* Only used by the wgl code, but have it here to avoid exporting the
+ * pixelformat.h functionality.
+ */
+int stw_pixelformat_choose( HDC hdc,
+ CONST PIXELFORMATDESCRIPTOR *ppfd )
+{
+ uint count;
+ uint index;
+ uint bestindex;
+ uint bestdelta;
+
+ (void) hdc;
+
+ count = stw_pixelformat_get_count();
+ bestindex = count;
+ bestdelta = ~0U;
+
+ for (index = 0; index < count; index++) {
+ uint delta = 0;
+ const struct stw_pixelformat_info *pfi = stw_pixelformat_get_info( index );
+
+ if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
+ !!(ppfd->dwFlags & PFD_DOUBLEBUFFER) !=
+ !!(pfi->pfd.dwFlags & PFD_DOUBLEBUFFER))
+ continue;
+
+ /* FIXME: Take in account individual channel bits */
+ if (ppfd->cColorBits != pfi->pfd.cColorBits)
+ delta += 8;
+
+ if (ppfd->cDepthBits != pfi->pfd.cDepthBits)
+ delta += 4;
+
+ if (ppfd->cStencilBits != pfi->pfd.cStencilBits)
+ delta += 2;
+
+ if (ppfd->cAlphaBits != pfi->pfd.cAlphaBits)
+ delta++;
+
+ if (delta < bestdelta) {
+ bestindex = index;
+ bestdelta = delta;
+ if (bestdelta == 0)
+ break;
+ }
+ }
+
+ if (bestindex == count)
+ return 0;
+
+ return bestindex + 1;
+}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef STW_PIXELFORMAT_H
+#define STW_PIXELFORMAT_H
+
+#include <windows.h>
+
+#include "main/mtypes.h"
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+
+struct stw_pixelformat_info
+{
+ enum pipe_format color_format;
+ enum pipe_format depth_stencil_format;
+
+ PIXELFORMATDESCRIPTOR pfd;
+
+ unsigned numSampleBuffers;
+ unsigned numSamples;
+};
+
+void
+stw_pixelformat_init( void );
+
+uint
+stw_pixelformat_get_count( void );
+
+uint
+stw_pixelformat_get_extended_count( void );
+
+const struct stw_pixelformat_info *
+stw_pixelformat_get_info( uint index );
+
+void
+stw_pixelformat_visual(GLvisual *visual,
+ const struct stw_pixelformat_info *pfi );
+
+#endif /* STW_PIXELFORMAT_H */
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef STW_PUBLIC_H
+#define STW_PUBLIC_H
+
+#include <windows.h>
+
+BOOL stw_copy_context( UINT_PTR hglrcSrc,
+ UINT_PTR hglrcDst,
+ UINT mask );
+
+UINT_PTR stw_create_layer_context( HDC hdc,
+ int iLayerPlane );
+
+BOOL stw_share_lists( UINT_PTR hglrc1, UINT_PTR hglrc2 );
+
+BOOL stw_delete_context( UINT_PTR hglrc );
+
+BOOL
+stw_release_context( UINT_PTR dhglrc );
+
+UINT_PTR stw_get_current_context( void );
+
+HDC stw_get_current_dc( void );
+
+BOOL stw_make_current( HDC hdc, UINT_PTR hglrc );
+
+BOOL stw_swap_buffers( HDC hdc );
+
+BOOL
+stw_swap_layer_buffers( HDC hdc, UINT fuPlanes );
+
+PROC stw_get_proc_address( LPCSTR lpszProc );
+
+int stw_pixelformat_describe( HDC hdc,
+ int iPixelFormat,
+ UINT nBytes,
+ LPPIXELFORMATDESCRIPTOR ppfd );
+
+int stw_pixelformat_get( HDC hdc );
+
+BOOL stw_pixelformat_set( HDC hdc,
+ int iPixelFormat );
+
+int stw_pixelformat_choose( HDC hdc,
+ CONST PIXELFORMATDESCRIPTOR *ppfd );
+
+#endif
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <windows.h>
+
+#include "pipe/p_compiler.h"
+#include "util/u_memory.h"
+#include "stw_tls.h"
+
+static DWORD tlsIndex = TLS_OUT_OF_INDEXES;
+
+boolean
+stw_tls_init(void)
+{
+ tlsIndex = TlsAlloc();
+ if (tlsIndex == TLS_OUT_OF_INDEXES) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static INLINE struct stw_tls_data *
+stw_tls_data_create()
+{
+ struct stw_tls_data *data;
+
+ data = CALLOC_STRUCT(stw_tls_data);
+ if (!data)
+ goto no_data;
+
+ data->hCallWndProcHook = SetWindowsHookEx(WH_CALLWNDPROC,
+ stw_call_window_proc,
+ NULL,
+ GetCurrentThreadId());
+ if(data->hCallWndProcHook == NULL)
+ goto no_hook;
+
+ TlsSetValue(tlsIndex, data);
+
+ return data;
+
+no_hook:
+ FREE(data);
+no_data:
+ return NULL;
+}
+
+boolean
+stw_tls_init_thread(void)
+{
+ struct stw_tls_data *data;
+
+ if (tlsIndex == TLS_OUT_OF_INDEXES) {
+ return FALSE;
+ }
+
+ data = stw_tls_data_create();
+ if(!data)
+ return FALSE;
+
+ return TRUE;
+}
+
+void
+stw_tls_cleanup_thread(void)
+{
+ struct stw_tls_data *data;
+
+ if (tlsIndex == TLS_OUT_OF_INDEXES) {
+ return;
+ }
+
+ data = (struct stw_tls_data *) TlsGetValue(tlsIndex);
+ if(data) {
+ TlsSetValue(tlsIndex, NULL);
+
+ if(data->hCallWndProcHook) {
+ UnhookWindowsHookEx(data->hCallWndProcHook);
+ data->hCallWndProcHook = NULL;
+ }
+
+ FREE(data);
+ }
+}
+
+void
+stw_tls_cleanup(void)
+{
+ if (tlsIndex != TLS_OUT_OF_INDEXES) {
+ TlsFree(tlsIndex);
+ tlsIndex = TLS_OUT_OF_INDEXES;
+ }
+}
+
+struct stw_tls_data *
+stw_tls_get_data(void)
+{
+ struct stw_tls_data *data;
+
+ if (tlsIndex == TLS_OUT_OF_INDEXES) {
+ return NULL;
+ }
+
+ data = (struct stw_tls_data *) TlsGetValue(tlsIndex);
+ if(!data) {
+ /* DllMain is called with DLL_THREAD_ATTACH only by threads created after
+ * the DLL is loaded by the process */
+ data = stw_tls_data_create();
+ if(!data)
+ return NULL;
+ }
+
+ return data;
+}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef STW_TLS_H
+#define STW_TLS_H
+
+#include <windows.h>
+
+struct stw_tls_data
+{
+ HHOOK hCallWndProcHook;
+};
+
+boolean
+stw_tls_init(void);
+
+boolean
+stw_tls_init_thread(void);
+
+void
+stw_tls_cleanup_thread(void);
+
+void
+stw_tls_cleanup(void);
+
+struct stw_tls_data *
+stw_tls_get_data(void);
+
+LRESULT CALLBACK
+stw_call_window_proc(
+ int nCode,
+ WPARAM wParam,
+ LPARAM lParam );
+
+#endif /* STW_TLS_H */
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <windows.h>
+
+#include "util/u_debug.h"
+#include "stw_public.h"
+#include "stw_wgl.h"
+
+
+WINGDIAPI BOOL APIENTRY
+wglCopyContext(
+ HGLRC hglrcSrc,
+ HGLRC hglrcDst,
+ UINT mask )
+{
+ return stw_copy_context( (UINT_PTR)hglrcSrc,
+ (UINT_PTR)hglrcDst,
+ mask );
+}
+
+WINGDIAPI HGLRC APIENTRY
+wglCreateContext(
+ HDC hdc )
+{
+ return wglCreateLayerContext(hdc, 0);
+}
+
+WINGDIAPI HGLRC APIENTRY
+wglCreateLayerContext(
+ HDC hdc,
+ int iLayerPlane )
+{
+ return (HGLRC) stw_create_layer_context( hdc, iLayerPlane );
+}
+
+WINGDIAPI BOOL APIENTRY
+wglDeleteContext(
+ HGLRC hglrc )
+{
+ return stw_delete_context( (UINT_PTR)hglrc );
+}
+
+
+WINGDIAPI HGLRC APIENTRY
+wglGetCurrentContext( VOID )
+{
+ return (HGLRC)stw_get_current_context();
+}
+
+WINGDIAPI HDC APIENTRY
+wglGetCurrentDC( VOID )
+{
+ return stw_get_current_dc();
+}
+
+WINGDIAPI BOOL APIENTRY
+wglMakeCurrent(
+ HDC hdc,
+ HGLRC hglrc )
+{
+ return stw_make_current( hdc, (UINT_PTR)hglrc );
+}
+
+
+WINGDIAPI BOOL APIENTRY
+wglSwapBuffers(
+ HDC hdc )
+{
+ return stw_swap_buffers( hdc );
+}
+
+
+WINGDIAPI BOOL APIENTRY
+wglSwapLayerBuffers(
+ HDC hdc,
+ UINT fuPlanes )
+{
+ return stw_swap_layer_buffers( hdc, fuPlanes );
+}
+
+WINGDIAPI PROC APIENTRY
+wglGetProcAddress(
+ LPCSTR lpszProc )
+{
+ return stw_get_proc_address( lpszProc );
+}
+
+
+WINGDIAPI int APIENTRY
+wglChoosePixelFormat(
+ HDC hdc,
+ CONST PIXELFORMATDESCRIPTOR *ppfd )
+{
+ if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
+ return 0;
+ if (ppfd->iPixelType != PFD_TYPE_RGBA)
+ return 0;
+ if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
+ return 0;
+ if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
+ return 0;
+ if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
+ return 0;
+ if (ppfd->dwFlags & PFD_SUPPORT_GDI)
+ return 0;
+ if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
+ return 0;
+
+ return stw_pixelformat_choose( hdc, ppfd );
+}
+
+WINGDIAPI int APIENTRY
+wglDescribePixelFormat(
+ HDC hdc,
+ int iPixelFormat,
+ UINT nBytes,
+ LPPIXELFORMATDESCRIPTOR ppfd )
+{
+ return stw_pixelformat_describe( hdc, iPixelFormat, nBytes, ppfd );
+}
+
+WINGDIAPI int APIENTRY
+wglGetPixelFormat(
+ HDC hdc )
+{
+ return stw_pixelformat_get( hdc );
+}
+
+WINGDIAPI BOOL APIENTRY
+wglSetPixelFormat(
+ HDC hdc,
+ int iPixelFormat,
+ const PIXELFORMATDESCRIPTOR *ppfd )
+{
+ if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
+ return FALSE;
+
+ return stw_pixelformat_set( hdc, iPixelFormat );
+}
+
+
+WINGDIAPI BOOL APIENTRY
+wglUseFontBitmapsA(
+ HDC hdc,
+ DWORD first,
+ DWORD count,
+ DWORD listBase )
+{
+ (void) hdc;
+ (void) first;
+ (void) count;
+ (void) listBase;
+
+ assert( 0 );
+
+ return FALSE;
+}
+
+WINGDIAPI BOOL APIENTRY
+wglShareLists(
+ HGLRC hglrc1,
+ HGLRC hglrc2 )
+{
+ return stw_share_lists( (UINT_PTR)hglrc1, (UINT_PTR)hglrc2);;
+}
+
+WINGDIAPI BOOL APIENTRY
+wglUseFontBitmapsW(
+ HDC hdc,
+ DWORD first,
+ DWORD count,
+ DWORD listBase )
+{
+ (void) hdc;
+ (void) first;
+ (void) count;
+ (void) listBase;
+
+ assert( 0 );
+
+ return FALSE;
+}
+
+WINGDIAPI BOOL APIENTRY
+wglUseFontOutlinesA(
+ HDC hdc,
+ DWORD first,
+ DWORD count,
+ DWORD listBase,
+ FLOAT deviation,
+ FLOAT extrusion,
+ int format,
+ LPGLYPHMETRICSFLOAT lpgmf )
+{
+ (void) hdc;
+ (void) first;
+ (void) count;
+ (void) listBase;
+ (void) deviation;
+ (void) extrusion;
+ (void) format;
+ (void) lpgmf;
+
+ assert( 0 );
+
+ return FALSE;
+}
+
+WINGDIAPI BOOL APIENTRY
+wglUseFontOutlinesW(
+ HDC hdc,
+ DWORD first,
+ DWORD count,
+ DWORD listBase,
+ FLOAT deviation,
+ FLOAT extrusion,
+ int format,
+ LPGLYPHMETRICSFLOAT lpgmf )
+{
+ (void) hdc;
+ (void) first;
+ (void) count;
+ (void) listBase;
+ (void) deviation;
+ (void) extrusion;
+ (void) format;
+ (void) lpgmf;
+
+ assert( 0 );
+
+ return FALSE;
+}
+
+WINGDIAPI BOOL APIENTRY
+wglDescribeLayerPlane(
+ HDC hdc,
+ int iPixelFormat,
+ int iLayerPlane,
+ UINT nBytes,
+ LPLAYERPLANEDESCRIPTOR plpd )
+{
+ (void) hdc;
+ (void) iPixelFormat;
+ (void) iLayerPlane;
+ (void) nBytes;
+ (void) plpd;
+
+ assert( 0 );
+
+ return FALSE;
+}
+
+WINGDIAPI int APIENTRY
+wglSetLayerPaletteEntries(
+ HDC hdc,
+ int iLayerPlane,
+ int iStart,
+ int cEntries,
+ CONST COLORREF *pcr )
+{
+ (void) hdc;
+ (void) iLayerPlane;
+ (void) iStart;
+ (void) cEntries;
+ (void) pcr;
+
+ assert( 0 );
+
+ return 0;
+}
+
+WINGDIAPI int APIENTRY
+wglGetLayerPaletteEntries(
+ HDC hdc,
+ int iLayerPlane,
+ int iStart,
+ int cEntries,
+ COLORREF *pcr )
+{
+ (void) hdc;
+ (void) iLayerPlane;
+ (void) iStart;
+ (void) cEntries;
+ (void) pcr;
+
+ assert( 0 );
+
+ return 0;
+}
+
+WINGDIAPI BOOL APIENTRY
+wglRealizeLayerPalette(
+ HDC hdc,
+ int iLayerPlane,
+ BOOL bRealize )
+{
+ (void) hdc;
+ (void) iLayerPlane;
+ (void) bRealize;
+
+ assert( 0 );
+
+ return FALSE;
+}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef STW_WGL_H_
+#define STW_WGL_H_
+
+
+#include <windows.h>
+
+#include <GL/gl.h>
+
+
+/*
+ * Undeclared APIs exported by opengl32.dll
+ */
+
+WINGDIAPI BOOL WINAPI
+wglSwapBuffers(HDC hdc);
+
+WINGDIAPI int WINAPI
+wglChoosePixelFormat(HDC hdc,
+ CONST PIXELFORMATDESCRIPTOR *ppfd);
+
+WINGDIAPI int WINAPI
+wglDescribePixelFormat(HDC hdc,
+ int iPixelFormat,
+ UINT nBytes,
+ LPPIXELFORMATDESCRIPTOR ppfd);
+
+WINGDIAPI int WINAPI
+wglGetPixelFormat(HDC hdc);
+
+WINGDIAPI BOOL WINAPI
+wglSetPixelFormat(HDC hdc,
+ int iPixelFormat,
+ CONST PIXELFORMATDESCRIPTOR *ppfd);
+
+
+#endif /* STW_WGL_H_ */
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef STW_WINSYS_H
+#define STW_WINSYS_H
+
+#include <windows.h> /* for HDC */
+
+#include "pipe/p_compiler.h"
+
+struct pipe_screen;
+struct pipe_context;
+struct pipe_surface;
+
+struct stw_winsys
+{
+ struct pipe_screen *
+ (*create_screen)( void );
+
+ struct pipe_context *
+ (*create_context)( struct pipe_screen *screen );
+
+ void
+ (*flush_frontbuffer)( struct pipe_screen *screen,
+ struct pipe_surface *surf,
+ HDC hDC );
+};
+
+boolean
+stw_init(const struct stw_winsys *stw_winsys);
+
+boolean
+stw_init_thread(void);
+
+void
+stw_cleanup_thread(void);
+
+void
+stw_cleanup(void);
+
+#endif /* STW_WINSYS_H */
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <windows.h>
-
-#include "util/u_debug.h"
-#include "shared/stw_public.h"
-#include "stw_wgl.h"
-
-
-WINGDIAPI BOOL APIENTRY
-wglCopyContext(
- HGLRC hglrcSrc,
- HGLRC hglrcDst,
- UINT mask )
-{
- return stw_copy_context( (UINT_PTR)hglrcSrc,
- (UINT_PTR)hglrcDst,
- mask );
-}
-
-WINGDIAPI HGLRC APIENTRY
-wglCreateContext(
- HDC hdc )
-{
- return wglCreateLayerContext(hdc, 0);
-}
-
-WINGDIAPI HGLRC APIENTRY
-wglCreateLayerContext(
- HDC hdc,
- int iLayerPlane )
-{
- return (HGLRC) stw_create_layer_context( hdc, iLayerPlane );
-}
-
-WINGDIAPI BOOL APIENTRY
-wglDeleteContext(
- HGLRC hglrc )
-{
- return stw_delete_context( (UINT_PTR)hglrc );
-}
-
-
-WINGDIAPI HGLRC APIENTRY
-wglGetCurrentContext( VOID )
-{
- return (HGLRC)stw_get_current_context();
-}
-
-WINGDIAPI HDC APIENTRY
-wglGetCurrentDC( VOID )
-{
- return stw_get_current_dc();
-}
-
-WINGDIAPI BOOL APIENTRY
-wglMakeCurrent(
- HDC hdc,
- HGLRC hglrc )
-{
- return stw_make_current( hdc, (UINT_PTR)hglrc );
-}
-
-
-WINGDIAPI BOOL APIENTRY
-wglSwapBuffers(
- HDC hdc )
-{
- return stw_swap_buffers( hdc );
-}
-
-
-WINGDIAPI BOOL APIENTRY
-wglSwapLayerBuffers(
- HDC hdc,
- UINT fuPlanes )
-{
- return stw_swap_layer_buffers( hdc, fuPlanes );
-}
-
-WINGDIAPI PROC APIENTRY
-wglGetProcAddress(
- LPCSTR lpszProc )
-{
- return stw_get_proc_address( lpszProc );
-}
-
-
-WINGDIAPI int APIENTRY
-wglChoosePixelFormat(
- HDC hdc,
- CONST PIXELFORMATDESCRIPTOR *ppfd )
-{
- if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
- return 0;
- if (ppfd->iPixelType != PFD_TYPE_RGBA)
- return 0;
- if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
- return 0;
- if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
- return 0;
- if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
- return 0;
- if (ppfd->dwFlags & PFD_SUPPORT_GDI)
- return 0;
- if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
- return 0;
-
- return stw_pixelformat_choose( hdc, ppfd );
-}
-
-WINGDIAPI int APIENTRY
-wglDescribePixelFormat(
- HDC hdc,
- int iPixelFormat,
- UINT nBytes,
- LPPIXELFORMATDESCRIPTOR ppfd )
-{
- return stw_pixelformat_describe( hdc, iPixelFormat, nBytes, ppfd );
-}
-
-WINGDIAPI int APIENTRY
-wglGetPixelFormat(
- HDC hdc )
-{
- return stw_pixelformat_get( hdc );
-}
-
-WINGDIAPI BOOL APIENTRY
-wglSetPixelFormat(
- HDC hdc,
- int iPixelFormat,
- const PIXELFORMATDESCRIPTOR *ppfd )
-{
- if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
- return FALSE;
-
- return stw_pixelformat_set( hdc, iPixelFormat );
-}
-
-
-WINGDIAPI BOOL APIENTRY
-wglUseFontBitmapsA(
- HDC hdc,
- DWORD first,
- DWORD count,
- DWORD listBase )
-{
- (void) hdc;
- (void) first;
- (void) count;
- (void) listBase;
-
- assert( 0 );
-
- return FALSE;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglShareLists(
- HGLRC hglrc1,
- HGLRC hglrc2 )
-{
- return stw_share_lists( (UINT_PTR)hglrc1, (UINT_PTR)hglrc2);;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglUseFontBitmapsW(
- HDC hdc,
- DWORD first,
- DWORD count,
- DWORD listBase )
-{
- (void) hdc;
- (void) first;
- (void) count;
- (void) listBase;
-
- assert( 0 );
-
- return FALSE;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglUseFontOutlinesA(
- HDC hdc,
- DWORD first,
- DWORD count,
- DWORD listBase,
- FLOAT deviation,
- FLOAT extrusion,
- int format,
- LPGLYPHMETRICSFLOAT lpgmf )
-{
- (void) hdc;
- (void) first;
- (void) count;
- (void) listBase;
- (void) deviation;
- (void) extrusion;
- (void) format;
- (void) lpgmf;
-
- assert( 0 );
-
- return FALSE;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglUseFontOutlinesW(
- HDC hdc,
- DWORD first,
- DWORD count,
- DWORD listBase,
- FLOAT deviation,
- FLOAT extrusion,
- int format,
- LPGLYPHMETRICSFLOAT lpgmf )
-{
- (void) hdc;
- (void) first;
- (void) count;
- (void) listBase;
- (void) deviation;
- (void) extrusion;
- (void) format;
- (void) lpgmf;
-
- assert( 0 );
-
- return FALSE;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglDescribeLayerPlane(
- HDC hdc,
- int iPixelFormat,
- int iLayerPlane,
- UINT nBytes,
- LPLAYERPLANEDESCRIPTOR plpd )
-{
- (void) hdc;
- (void) iPixelFormat;
- (void) iLayerPlane;
- (void) nBytes;
- (void) plpd;
-
- assert( 0 );
-
- return FALSE;
-}
-
-WINGDIAPI int APIENTRY
-wglSetLayerPaletteEntries(
- HDC hdc,
- int iLayerPlane,
- int iStart,
- int cEntries,
- CONST COLORREF *pcr )
-{
- (void) hdc;
- (void) iLayerPlane;
- (void) iStart;
- (void) cEntries;
- (void) pcr;
-
- assert( 0 );
-
- return 0;
-}
-
-WINGDIAPI int APIENTRY
-wglGetLayerPaletteEntries(
- HDC hdc,
- int iLayerPlane,
- int iStart,
- int cEntries,
- COLORREF *pcr )
-{
- (void) hdc;
- (void) iLayerPlane;
- (void) iStart;
- (void) cEntries;
- (void) pcr;
-
- assert( 0 );
-
- return 0;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglRealizeLayerPalette(
- HDC hdc,
- int iLayerPlane,
- BOOL bRealize )
-{
- (void) hdc;
- (void) iLayerPlane;
- (void) bRealize;
-
- assert( 0 );
-
- return FALSE;
-}
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef STW_WGL_H_
-#define STW_WGL_H_
-
-
-#include <windows.h>
-
-#include <GL/gl.h>
-
-
-/*
- * Undeclared APIs exported by opengl32.dll
- */
-
-WINGDIAPI BOOL WINAPI
-wglSwapBuffers(HDC hdc);
-
-WINGDIAPI int WINAPI
-wglChoosePixelFormat(HDC hdc,
- CONST PIXELFORMATDESCRIPTOR *ppfd);
-
-WINGDIAPI int WINAPI
-wglDescribePixelFormat(HDC hdc,
- int iPixelFormat,
- UINT nBytes,
- LPPIXELFORMATDESCRIPTOR ppfd);
-
-WINGDIAPI int WINAPI
-wglGetPixelFormat(HDC hdc);
-
-WINGDIAPI BOOL WINAPI
-wglSetPixelFormat(HDC hdc,
- int iPixelFormat,
- CONST PIXELFORMATDESCRIPTOR *ppfd);
-
-
-#endif /* STW_WGL_H_ */