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 API implementation.
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.
43 #include "util/u_debug.h"
45 #include "stw_context.h"
46 #include "stw_pixelformat.h"
50 WINGDIAPI BOOL APIENTRY
56 return DrvCopyContext( (DHGLRC
)(UINT_PTR
)hglrcSrc
,
57 (DHGLRC
)(UINT_PTR
)hglrcDst
,
61 WINGDIAPI HGLRC APIENTRY
65 return (HGLRC
) DrvCreateContext(hdc
);
68 WINGDIAPI HGLRC APIENTRY
69 wglCreateLayerContext(
73 return (HGLRC
) DrvCreateLayerContext( hdc
, iLayerPlane
);
76 WINGDIAPI BOOL APIENTRY
80 return DrvDeleteContext((DHGLRC
)(UINT_PTR
)hglrc
);
84 WINGDIAPI HGLRC APIENTRY
85 wglGetCurrentContext( VOID
)
87 return (HGLRC
)(UINT_PTR
)stw_get_current_context();
90 WINGDIAPI HDC APIENTRY
91 wglGetCurrentDC( VOID
)
93 return stw_get_current_dc();
96 WINGDIAPI BOOL APIENTRY
101 return DrvSetContext( hdc
, (DHGLRC
)(UINT_PTR
)hglrc
, NULL
) ? TRUE
: FALSE
;
105 WINGDIAPI BOOL APIENTRY
109 return DrvSwapBuffers( hdc
);
113 WINGDIAPI DWORD WINAPI
114 wglSwapMultipleBuffers(UINT n
,
119 for (i
=0; i
< n
; ++i
)
120 wglSwapBuffers(ps
->hdc
);
126 WINGDIAPI BOOL APIENTRY
131 return DrvSwapLayerBuffers( hdc
, fuPlanes
);
134 WINGDIAPI PROC APIENTRY
138 return DrvGetProcAddress( lpszProc
);
142 WINGDIAPI
int APIENTRY
143 wglChoosePixelFormat(
145 CONST PIXELFORMATDESCRIPTOR
*ppfd
)
147 if (ppfd
->nSize
!= sizeof( PIXELFORMATDESCRIPTOR
) || ppfd
->nVersion
!= 1)
149 if (ppfd
->iPixelType
!= PFD_TYPE_RGBA
)
151 if (!(ppfd
->dwFlags
& PFD_DRAW_TO_WINDOW
))
153 if (!(ppfd
->dwFlags
& PFD_SUPPORT_OPENGL
))
155 if (ppfd
->dwFlags
& PFD_DRAW_TO_BITMAP
)
157 if (ppfd
->dwFlags
& PFD_SUPPORT_GDI
)
159 if (!(ppfd
->dwFlags
& PFD_STEREO_DONTCARE
) && (ppfd
->dwFlags
& PFD_STEREO
))
162 return stw_pixelformat_choose( hdc
, ppfd
);
165 WINGDIAPI
int APIENTRY
166 wglDescribePixelFormat(
170 LPPIXELFORMATDESCRIPTOR ppfd
)
172 return DrvDescribePixelFormat( hdc
, iPixelFormat
, nBytes
, ppfd
);
175 WINGDIAPI
int APIENTRY
179 return stw_pixelformat_get( hdc
);
182 WINGDIAPI BOOL APIENTRY
186 const PIXELFORMATDESCRIPTOR
*ppfd
)
188 /* SetPixelFormat (hence wglSetPixelFormat) must not touch ppfd, per
189 * http://msdn.microsoft.com/en-us/library/dd369049(v=vs.85).aspx
193 return DrvSetPixelFormat( hdc
, iPixelFormat
);
197 WINGDIAPI BOOL APIENTRY
214 WINGDIAPI BOOL APIENTRY
219 return DrvShareLists((DHGLRC
)(UINT_PTR
)hglrc1
,
220 (DHGLRC
)(UINT_PTR
)hglrc2
);
223 WINGDIAPI BOOL APIENTRY
240 WINGDIAPI BOOL APIENTRY
249 LPGLYPHMETRICSFLOAT lpgmf
)
265 WINGDIAPI BOOL APIENTRY
274 LPGLYPHMETRICSFLOAT lpgmf
)
290 WINGDIAPI BOOL APIENTRY
291 wglDescribeLayerPlane(
296 LPLAYERPLANEDESCRIPTOR plpd
)
298 return DrvDescribeLayerPlane(hdc
, iPixelFormat
, iLayerPlane
, nBytes
, plpd
);
301 WINGDIAPI
int APIENTRY
302 wglSetLayerPaletteEntries(
307 CONST COLORREF
*pcr
)
309 return DrvSetLayerPaletteEntries(hdc
, iLayerPlane
, iStart
, cEntries
, pcr
);
312 WINGDIAPI
int APIENTRY
313 wglGetLayerPaletteEntries(
320 return DrvGetLayerPaletteEntries(hdc
, iLayerPlane
, iStart
, cEntries
, pcr
);
323 WINGDIAPI BOOL APIENTRY
324 wglRealizeLayerPalette(