blob: 4f05e6bdaeec74d0bb297895a86d451a05f4d5ba [file] [log] [blame]
José Fonseca8fbdd3a2010-11-23 20:55:07 +00001##########################################################################
2#
3# Copyright 2008-2010 VMware, Inc.
4# All Rights Reserved.
5#
6# Permission is hereby granted, free of charge, to any person obtaining a copy
7# of this software and associated documentation files (the "Software"), to deal
8# in the Software without restriction, including without limitation the rights
9# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10# copies of the Software, and to permit persons to whom the Software is
11# furnished to do so, subject to the following conditions:
12#
13# The above copyright notice and this permission notice shall be included in
14# all copies or substantial portions of the Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22# THE SOFTWARE.
23#
24##########################################################################/
25
26
27from glapi import *
28from windows import *
29
30
31wglapi = API("WGL")
32wglapi.add_functions(glapi.functions)
33
34
35HGLRC = Alias("HGLRC", HANDLE)
36PROC = Opaque("PROC")
37
38PFD = Flags(DWORD, [
39 "PFD_DOUBLEBUFFER",
40 "PFD_STEREO",
41 "PFD_DRAW_TO_WINDOW",
42 "PFD_DRAW_TO_BITMAP",
43 "PFD_SUPPORT_GDI",
44 "PFD_SUPPORT_OPENGL",
45 "PFD_GENERIC_FORMAT",
46 "PFD_NEED_PALETTE",
47 "PFD_NEED_SYSTEM_PALETTE",
48 "PFD_SWAP_EXCHANGE",
49 "PFD_SWAP_COPY",
50 "PFD_SWAP_LAYER_BUFFERS",
51 "PFD_GENERIC_ACCELERATED",
52 "PFD_SUPPORT_DIRECTDRAW",
53 "PFD_DEPTH_DONTCARE",
54 "PFD_DOUBLEBUFFER_DONTCARE",
55 "PFD_STEREO_DONTCARE",
56])
57
58PIXELFORMATDESCRIPTOR = Struct("PIXELFORMATDESCRIPTOR", [
59 (WORD, "nSize"),
60 (WORD, "nVersion"),
61 (PFD, "dwFlags"),
62 (BYTE, "iPixelType"),
63 (BYTE, "cColorBits"),
64 (BYTE, "cRedBits"),
65 (BYTE, "cRedShift"),
66 (BYTE, "cGreenBits"),
67 (BYTE, "cGreenShift"),
68 (BYTE, "cBlueBits"),
69 (BYTE, "cBlueShift"),
70 (BYTE, "cAlphaBits"),
71 (BYTE, "cAlphaShift"),
72 (BYTE, "cAccumBits"),
73 (BYTE, "cAccumRedBits"),
74 (BYTE, "cAccumGreenBits"),
75 (BYTE, "cAccumBlueBits"),
76 (BYTE, "cAccumAlphaBits"),
77 (BYTE, "cDepthBits"),
78 (BYTE, "cStencilBits"),
79 (BYTE, "cAuxBuffers"),
80 (BYTE, "iLayerType"),
81 (BYTE, "bReserved"),
82 (DWORD, "dwLayerMask"),
83 (DWORD, "dwVisibleMask"),
84 (DWORD, "dwDamageMask"),
85])
86
87POINTFLOAT = Struct("POINTFLOAT", [
88 (FLOAT, "x"),
89 (FLOAT, "y"),
90])
91
92GLYPHMETRICSFLOAT = Struct("GLYPHMETRICSFLOAT", [
93 (FLOAT, "gmfBlackBoxX"),
94 (FLOAT, "gmfBlackBoxY"),
95 (POINTFLOAT, "gmfptGlyphOrigin"),
96 (FLOAT, "gmfCellIncX"),
97 (FLOAT, "gmfCellIncY"),
98])
99LPGLYPHMETRICSFLOAT = Pointer(GLYPHMETRICSFLOAT)
100
101COLORREF = Alias("COLORREF", DWORD)
102
103
104LAYERPLANEDESCRIPTOR = Struct("LAYERPLANEDESCRIPTOR", [
105 (WORD, "nSize"),
106 (WORD, "nVersion"),
107 (DWORD, "dwFlags"),
108 (BYTE, "iPixelType"),
109 (BYTE, "cColorBits"),
110 (BYTE, "cRedBits"),
111 (BYTE, "cRedShift"),
112 (BYTE, "cGreenBits"),
113 (BYTE, "cGreenShift"),
114 (BYTE, "cBlueBits"),
115 (BYTE, "cBlueShift"),
116 (BYTE, "cAlphaBits"),
117 (BYTE, "cAlphaShift"),
118 (BYTE, "cAccumBits"),
119 (BYTE, "cAccumRedBits"),
120 (BYTE, "cAccumGreenBits"),
121 (BYTE, "cAccumBlueBits"),
122 (BYTE, "cAccumAlphaBits"),
123 (BYTE, "cDepthBits"),
124 (BYTE, "cStencilBits"),
125 (BYTE, "cAuxBuffers"),
126 (BYTE, "iLayerPlane"),
127 (BYTE, "bReserved"),
128 (COLORREF, "crTransparent"),
129])
130LPLAYERPLANEDESCRIPTOR = Pointer(LAYERPLANEDESCRIPTOR)
131
132WGLSWAP = Struct("WGLSWAP", [
133 (HDC, "hdc"),
134 (UINT, "uiFlags"),
135])
136
137attribute = FakeEnum(Int, [
138 "WGL_NUMBER_PIXEL_FORMATS_EXT",
139 "WGL_DRAW_TO_WINDOW_EXT",
140 "WGL_DRAW_TO_BITMAP_EXT",
141 "WGL_ACCELERATION_EXT",
142 "WGL_NEED_PALETTE_EXT",
143 "WGL_NEED_SYSTEM_PALETTE_EXT",
144 "WGL_SWAP_LAYER_BUFFERS_EXT",
145 "WGL_SWAP_METHOD_EXT",
146 "WGL_NUMBER_OVERLAYS_EXT",
147 "WGL_NUMBER_UNDERLAYS_EXT",
148 "WGL_TRANSPARENT_EXT",
149 "WGL_TRANSPARENT_VALUE_EXT",
150 "WGL_SHARE_DEPTH_EXT",
151 "WGL_SHARE_STENCIL_EXT",
152 "WGL_SHARE_ACCUM_EXT",
153 "WGL_SUPPORT_GDI_EXT",
154 "WGL_SUPPORT_OPENGL_EXT",
155 "WGL_DOUBLE_BUFFER_EXT",
156 "WGL_STEREO_EXT",
157 "WGL_PIXEL_TYPE_EXT",
158 "WGL_COLOR_BITS_EXT",
159 "WGL_RED_BITS_EXT",
160 "WGL_RED_SHIFT_EXT",
161 "WGL_GREEN_BITS_EXT",
162 "WGL_GREEN_SHIFT_EXT",
163 "WGL_BLUE_BITS_EXT",
164 "WGL_BLUE_SHIFT_EXT",
165 "WGL_ALPHA_BITS_EXT",
166 "WGL_ALPHA_SHIFT_EXT",
167 "WGL_ACCUM_BITS_EXT",
168 "WGL_ACCUM_RED_BITS_EXT",
169 "WGL_ACCUM_GREEN_BITS_EXT",
170 "WGL_ACCUM_BLUE_BITS_EXT",
171 "WGL_ACCUM_ALPHA_BITS_EXT",
172 "WGL_DEPTH_BITS_EXT",
173 "WGL_STENCIL_BITS_EXT",
174 "WGL_AUX_BUFFERS_EXT",
175 "WGL_NO_ACCELERATION_EXT",
176 "WGL_GENERIC_ACCELERATION_EXT",
177 "WGL_FULL_ACCELERATION_EXT",
178 "WGL_SWAP_EXCHANGE_EXT",
179 "WGL_SWAP_COPY_EXT",
180 "WGL_SWAP_UNDEFINED_EXT",
181 "WGL_TYPE_RGBA_EXT",
182 "WGL_TYPE_COLORINDEX_EXT",
183])
184
185HPBUFFERARB = Alias("HPBUFFERARB", HANDLE)
186
187
188wglapi.add_functions([
189 StdFunction(BOOL, "wglCopyContext", [(HGLRC, "hglrcSrc"), (HGLRC, "hglrcDst"), (UINT, "mask")]),
190 StdFunction(HGLRC, "wglCreateContext", [(HDC, "hdc")]),
191 StdFunction(HGLRC, "wglCreateLayerContext", [(HDC, "hdc"), (Int, "iLayerPlane")]),
192 StdFunction(BOOL, "wglDeleteContext", [(HGLRC, "hglrc")]),
193 StdFunction(HGLRC, "wglGetCurrentContext", [], sideeffects=False),
194 StdFunction(HDC, "wglGetCurrentDC", [], sideeffects=False),
195 StdFunction(PROC, "wglGetDefaultProcAddress", [(LPCSTR, "lpszProc")], sideeffects=False),
196 StdFunction(Int, "wglChoosePixelFormat", [(HDC, "hdc"), (Pointer(Const(PIXELFORMATDESCRIPTOR)), "ppfd")]),
197 StdFunction(Int, "wglDescribePixelFormat", [(HDC, "hdc"), (Int, "iPixelFormat"), (UINT, "nBytes"), Out(Pointer(PIXELFORMATDESCRIPTOR), "ppfd")]),
198 StdFunction(Int, "wglGetPixelFormat", [(HDC, "hdc")], sideeffects=False),
199 StdFunction(BOOL, "wglSetPixelFormat", [(HDC, "hdc"), (Int, "iPixelFormat"), (Pointer(Const(PIXELFORMATDESCRIPTOR)), "ppfd")]),
200 StdFunction(BOOL, "wglMakeCurrent", [(HDC, "hdc"), (HGLRC, "hglrc")]),
201 StdFunction(BOOL, "wglShareLists", [(HGLRC, "hglrc1"), (HGLRC, "hglrc2")]),
202 StdFunction(BOOL, "wglUseFontBitmapsA", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase")]),
203 StdFunction(BOOL, "wglUseFontBitmapsW", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase")]),
204 StdFunction(BOOL, "wglSwapBuffers", [(HDC, "hdc")]),
205 StdFunction(BOOL, "wglUseFontOutlinesA", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase"), (FLOAT, "deviation"), (FLOAT, "extrusion"), (Int, "format"), (LPGLYPHMETRICSFLOAT, "lpgmf")]),
206 StdFunction(BOOL, "wglUseFontOutlinesW", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase"), (FLOAT, "deviation"), (FLOAT, "extrusion"), (Int, "format"), (LPGLYPHMETRICSFLOAT, "lpgmf")]),
207 StdFunction(BOOL , "wglDescribeLayerPlane", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nBytes"), Out(Pointer(LAYERPLANEDESCRIPTOR), "plpd")]),
208 StdFunction(Int , "wglSetLayerPaletteEntries", [(HDC, "hdc"), (Int, "iLayerPlane"), (Int, "iStart"), (Int, "cEntries"), (Array(Const(COLORREF), "cEntries"), "pcr")]),
209 StdFunction(Int , "wglGetLayerPaletteEntries", [(HDC, "hdc"), (Int, "iLayerPlane"), (Int, "iStart"), (Int, "cEntries"), Out(Array(COLORREF, "cEntries"), "pcr")], sideeffects=False),
210 StdFunction(BOOL , "wglRealizeLayerPalette", [(HDC, "hdc"), (Int, "iLayerPlane"), (BOOL, "bRealize")]),
211 StdFunction(BOOL , "wglSwapLayerBuffers", [(HDC, "hdc"), (UINT, "fuPlanes")]),
212 StdFunction(DWORD, "wglSwapMultipleBuffers", [(UINT, "n"), (Array(Const(WGLSWAP), "n"), "ps")]),
213
214 # WGL_ARB_extensions_string
215 StdFunction(Const(String), "wglGetExtensionsStringARB", [(HDC, "hdc")], sideeffects=False),
216
217 # WGL_ARB_pbuffer
218 StdFunction(HPBUFFERARB, "wglCreatePbufferARB", [(HDC, "hDC"), (Int, "iPixelFormat"), (Int, "iWidth"), (Int, "iHeight"), (Pointer(Const(Int)), "piAttribList")]),
219 StdFunction(HDC, "wglGetPbufferDCARB", [(HPBUFFERARB, "hPbuffer")], sideeffects=False),
220 StdFunction(Int, "wglReleasePbufferDCARB", [(HPBUFFERARB, "hPbuffer"), (HDC, "hDC")]),
221 StdFunction(BOOL, "wglDestroyPbufferARB", [(HPBUFFERARB, "hPbuffer")]),
222 StdFunction(BOOL, "wglQueryPbufferARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iAttribute"), Out(Pointer(Int), "piValue")]),
223
224 # WGL_ARB_pixel_format
225 StdFunction(BOOL, "wglGetPixelFormatAttribivARB", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(attribute, "nAttributes"), "piAttributes"), Out(Array(Int, "nAttributes"), "piValues")], sideeffects=False),
226 StdFunction(BOOL, "wglGetPixelFormatAttribfvARB", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(attribute, "nAttributes"), "piAttributes"), Out(Array(FLOAT, "nAttributes"), "pfValues")], sideeffects=False),
227 StdFunction(BOOL, "wglChoosePixelFormatARB", [(HDC, "hdc"), (Pointer(Const(Int)), "piAttribIList"), (Pointer(Const(FLOAT)), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "nMaxFormats"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]),
228
229 # WGL_EXT_extensions_string
230 StdFunction(Const(String), "wglGetExtensionsStringEXT", [], sideeffects=False),
231
232 # WGL_EXT_pixel_format
233 StdFunction(BOOL, "wglGetPixelFormatAttribivEXT", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(attribute, "nAttributes"), "piAttributes"), Out(Array(Int, "nAttributes"), "piValues")], sideeffects=False),
234 StdFunction(BOOL, "wglGetPixelFormatAttribfvEXT", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(attribute, "nAttributes"), "piAttributes"), Out(Array(FLOAT, "nAttributes"), "pfValues")], sideeffects=False),
235 StdFunction(BOOL, "wglChoosePixelFormatEXT", [(HDC, "hdc"), (Pointer(Const(Int)), "piAttribIList"), (Pointer(Const(FLOAT)), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "nMaxFormats"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]),
236
237 # must be last
238 StdFunction(PROC, "wglGetProcAddress", [(LPCSTR, "lpszProc")]),
239])
240
241if __name__ == '__main__':
242 print
243 print '#define _GDI32_'
244 print
245 print '#include <windows.h>'
246 print '#include <tchar.h>'
247 print '#include <GL/gl.h>'
248 print '#include "glext.h"'
249 print '#include "wglext.h"'
250 print
251 print '#include "glhelpers.hpp"'
252 print '#include "log.hpp"'
253 print
254 print '#ifndef PFD_SUPPORT_DIRECTDRAW'
255 print '#define PFD_SUPPORT_DIRECTDRAW 0x00002000'
256 print '#endif'
257 print '#ifndef PFD_SUPPORT_COMPOSITION'
258 print '#define PFD_SUPPORT_COMPOSITION 0x00008000'
259 print '#endif'
260 print
261 print '#ifdef __MINGW32__'
262 print ''
263 print 'typedef struct _WGLSWAP'
264 print '{'
265 print ' HDC hdc;'
266 print ' UINT uiFlags;'
267 print '} WGLSWAP, *PWGLSWAP, FAR *LPWGLSWAP;'
268 print ''
269 print '#define WGL_SWAPMULTIPLE_MAX 16'
270 print ''
271 print '#endif'
272 print
273 print 'extern "C" {'
274 print
275 wrap()
276 print
277 print '}'