1 /**************************************************************************
3 * Copyright 2008 VMware, Inc.
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 VMWARE 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 **************************************************************************/
31 * Fake WGL gallium frontend.
33 * These functions implement the WGL API, on top of the ICD DDI, so that the
34 * resulting DLL can be used as a drop-in replacement for the system's
37 * These functions never get called for ICD drivers, which use exclusively the
38 * ICD DDI, i.e., the Drv* entrypoints.
44 #include "util/u_debug.h"
46 #include "stw_context.h"
47 #include "stw_pixelformat.h"
49 #include "stw_ext_context.h"
51 WINGDIAPI BOOL APIENTRY
57 return DrvCopyContext( (DHGLRC)(UINT_PTR)hglrcSrc,
58 (DHGLRC)(UINT_PTR)hglrcDst,
62 WINGDIAPI HGLRC APIENTRY
66 stw_override_opengl32_entry_points(&wglCreateContext, &wglDeleteContext);
67 return (HGLRC)(UINT_PTR)DrvCreateContext(hdc);
70 WINGDIAPI HGLRC APIENTRY
71 wglCreateLayerContext(
75 stw_override_opengl32_entry_points(&wglCreateContext, &wglDeleteContext);
76 return (HGLRC)(UINT_PTR)DrvCreateLayerContext( hdc, iLayerPlane );
79 WINGDIAPI BOOL APIENTRY
83 return DrvDeleteContext((DHGLRC)(UINT_PTR)hglrc );
87 WINGDIAPI HGLRC APIENTRY
88 wglGetCurrentContext( VOID )
90 return (HGLRC)(UINT_PTR)stw_get_current_context();
93 WINGDIAPI HDC APIENTRY
94 wglGetCurrentDC( VOID )
96 return stw_get_current_dc();
100 WINGDIAPI BOOL APIENTRY
105 return DrvSetContext( hdc, (DHGLRC)(UINT_PTR)hglrc, NULL ) ? TRUE : FALSE;
109 WINGDIAPI BOOL APIENTRY
113 return DrvSwapBuffers( hdc );
117 WINGDIAPI DWORD WINAPI
118 wglSwapMultipleBuffers(UINT n,
123 for (i =0; i < n; ++i)
124 wglSwapBuffers(ps->hdc);
130 WINGDIAPI BOOL APIENTRY
135 return DrvSwapLayerBuffers( hdc, fuPlanes );
138 WINGDIAPI PROC APIENTRY
142 return DrvGetProcAddress( lpszProc );
146 WINGDIAPI int APIENTRY
147 wglChoosePixelFormat(
149 CONST PIXELFORMATDESCRIPTOR *ppfd )
151 if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
153 if (ppfd->iPixelType != PFD_TYPE_RGBA)
155 if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
157 if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
159 if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
161 if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
164 return stw_pixelformat_choose( hdc, ppfd );
167 WINGDIAPI int APIENTRY
168 wglDescribePixelFormat(
172 LPPIXELFORMATDESCRIPTOR ppfd )
174 return DrvDescribePixelFormat( hdc, iPixelFormat, nBytes, ppfd );
177 WINGDIAPI int APIENTRY
181 return stw_pixelformat_get( hdc );
184 WINGDIAPI BOOL APIENTRY
188 const PIXELFORMATDESCRIPTOR *ppfd )
190 /* SetPixelFormat (hence wglSetPixelFormat) must not touch ppfd, per
191 * http://msdn.microsoft.com/en-us/library/dd369049(v=vs.85).aspx
195 return DrvSetPixelFormat( hdc, iPixelFormat );
199 WINGDIAPI BOOL APIENTRY
206 return wglUseFontBitmapsW(hdc, first, count, listBase);
209 WINGDIAPI BOOL APIENTRY
214 return DrvShareLists((DHGLRC)(UINT_PTR)hglrc1,
215 (DHGLRC)(UINT_PTR)hglrc2);
218 WINGDIAPI BOOL APIENTRY
227 FIXED one, minus_one, zero;
233 minus_one.value = -1;
239 tra.eM22 = minus_one;
240 tra.eM12 = tra.eM21 = zero;
242 for (int i = 0; i < count; i++) {
243 DWORD size = GetGlyphOutline(hdc, first + i, GGO_BITMAP, &gm, 0,
246 glNewList(listBase + i, GL_COMPILE);
248 if (size != GDI_ERROR) {
250 glBitmap(0, 0, (GLfloat)-gm.gmptGlyphOrigin.x,
251 (GLfloat)gm.gmptGlyphOrigin.y,
252 (GLfloat)gm.gmCellIncX,
253 (GLfloat)gm.gmCellIncY, NULL);
256 buffer = realloc(buffer, size);
257 size = GetGlyphOutline(hdc, first + i, GGO_BITMAP, &gm,
260 glBitmap(gm.gmBlackBoxX, gm.gmBlackBoxY,
261 -gm.gmptGlyphOrigin.x, gm.gmptGlyphOrigin.y,
262 gm.gmCellIncX, gm.gmCellIncY, buffer);
277 WINGDIAPI BOOL APIENTRY
286 LPGLYPHMETRICSFLOAT lpgmf )
302 WINGDIAPI BOOL APIENTRY
311 LPGLYPHMETRICSFLOAT lpgmf )
327 WINGDIAPI BOOL APIENTRY
328 wglDescribeLayerPlane(
333 LPLAYERPLANEDESCRIPTOR plpd )
335 return DrvDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
338 WINGDIAPI int APIENTRY
339 wglSetLayerPaletteEntries(
344 CONST COLORREF *pcr )
346 return DrvSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
349 WINGDIAPI int APIENTRY
350 wglGetLayerPaletteEntries(
357 return DrvGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
360 WINGDIAPI BOOL APIENTRY
361 wglRealizeLayerPalette(