1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 #include "util/u_debug.h"
32 #include "stw_context.h"
33 #include "stw_pixelformat.h"
37 WINGDIAPI BOOL APIENTRY
43 return DrvCopyContext( (DHGLRC)(UINT_PTR)hglrcSrc,
44 (DHGLRC)(UINT_PTR)hglrcDst,
48 WINGDIAPI HGLRC APIENTRY
52 return (HGLRC) DrvCreateContext(hdc);
55 WINGDIAPI HGLRC APIENTRY
56 wglCreateLayerContext(
60 return (HGLRC) DrvCreateLayerContext( hdc, iLayerPlane );
63 WINGDIAPI BOOL APIENTRY
67 return DrvDeleteContext((DHGLRC)(UINT_PTR)hglrc );
71 WINGDIAPI HGLRC APIENTRY
72 wglGetCurrentContext( VOID )
74 return (HGLRC)(UINT_PTR)stw_get_current_context();
77 WINGDIAPI HDC APIENTRY
78 wglGetCurrentDC( VOID )
80 return stw_get_current_dc();
83 WINGDIAPI BOOL APIENTRY
88 return DrvSetContext( hdc, (DHGLRC)(UINT_PTR)hglrc, NULL ) ? TRUE : FALSE;
92 WINGDIAPI BOOL APIENTRY
96 return DrvSwapBuffers( hdc );
100 WINGDIAPI DWORD WINAPI
101 wglSwapMultipleBuffers(UINT n,
106 for (i =0; i < n; ++i)
107 wglSwapBuffers(ps->hdc);
113 WINGDIAPI BOOL APIENTRY
118 return DrvSwapLayerBuffers( hdc, fuPlanes );
121 WINGDIAPI PROC APIENTRY
125 return DrvGetProcAddress( lpszProc );
129 WINGDIAPI int APIENTRY
130 wglChoosePixelFormat(
132 CONST PIXELFORMATDESCRIPTOR *ppfd )
134 if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
136 if (ppfd->iPixelType != PFD_TYPE_RGBA)
138 if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
140 if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
142 if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
144 if (ppfd->dwFlags & PFD_SUPPORT_GDI)
146 if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
149 return stw_pixelformat_choose( hdc, ppfd );
152 WINGDIAPI int APIENTRY
153 wglDescribePixelFormat(
157 LPPIXELFORMATDESCRIPTOR ppfd )
159 return DrvDescribePixelFormat( hdc, iPixelFormat, nBytes, ppfd );
162 WINGDIAPI int APIENTRY
166 return stw_pixelformat_get( hdc );
169 WINGDIAPI BOOL APIENTRY
173 const PIXELFORMATDESCRIPTOR *ppfd )
175 /* SetPixelFormat (hence wglSetPixelFormat) must not touch ppfd, per
176 * http://msdn.microsoft.com/en-us/library/dd369049(v=vs.85).aspx
180 return DrvSetPixelFormat( hdc, iPixelFormat );
184 WINGDIAPI BOOL APIENTRY
201 WINGDIAPI BOOL APIENTRY
206 return DrvShareLists((DHGLRC)(UINT_PTR)hglrc1,
207 (DHGLRC)(UINT_PTR)hglrc2);
210 WINGDIAPI BOOL APIENTRY
227 WINGDIAPI BOOL APIENTRY
236 LPGLYPHMETRICSFLOAT lpgmf )
252 WINGDIAPI BOOL APIENTRY
261 LPGLYPHMETRICSFLOAT lpgmf )
277 WINGDIAPI BOOL APIENTRY
278 wglDescribeLayerPlane(
283 LPLAYERPLANEDESCRIPTOR plpd )
285 return DrvDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
288 WINGDIAPI int APIENTRY
289 wglSetLayerPaletteEntries(
294 CONST COLORREF *pcr )
296 return DrvSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
299 WINGDIAPI int APIENTRY
300 wglGetLayerPaletteEntries(
307 return DrvGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
310 WINGDIAPI BOOL APIENTRY
311 wglRealizeLayerPalette(