blob: 9510006be4df8a4aed8d282e6906714171428191 [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 *
José Fonsecaf20c1262010-11-25 11:39:57 +000028from winapi import *
José Fonseca8fbdd3a2010-11-23 20:55:07 +000029
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([
José Fonsecaa9e80d02010-11-24 15:56:47 +0000189 # WGL
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000190 StdFunction(HGLRC, "wglCreateContext", [(HDC, "hdc")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000191 StdFunction(BOOL, "wglDeleteContext", [(HGLRC, "hglrc")]),
192 StdFunction(HGLRC, "wglGetCurrentContext", [], sideeffects=False),
José Fonsecafe3791e2010-11-25 11:28:52 +0000193 StdFunction(BOOL, "wglMakeCurrent", [(HDC, "hdc"), (HGLRC, "hglrc")]),
194 StdFunction(BOOL, "wglCopyContext", [(HGLRC, "hglrcSrc"), (HGLRC, "hglrcDst"), (UINT, "mask")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000195 StdFunction(Int, "wglChoosePixelFormat", [(HDC, "hdc"), (Pointer(Const(PIXELFORMATDESCRIPTOR)), "ppfd")]),
196 StdFunction(Int, "wglDescribePixelFormat", [(HDC, "hdc"), (Int, "iPixelFormat"), (UINT, "nBytes"), Out(Pointer(PIXELFORMATDESCRIPTOR), "ppfd")]),
José Fonsecafe3791e2010-11-25 11:28:52 +0000197 StdFunction(HDC, "wglGetCurrentDC", [], sideeffects=False),
198 StdFunction(PROC, "wglGetDefaultProcAddress", [(LPCSTR, "lpszProc")], sideeffects=False),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000199 StdFunction(Int, "wglGetPixelFormat", [(HDC, "hdc")], sideeffects=False),
200 StdFunction(BOOL, "wglSetPixelFormat", [(HDC, "hdc"), (Int, "iPixelFormat"), (Pointer(Const(PIXELFORMATDESCRIPTOR)), "ppfd")]),
José Fonsecafe3791e2010-11-25 11:28:52 +0000201 StdFunction(BOOL, "wglSwapBuffers", [(HDC, "hdc")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000202 StdFunction(BOOL, "wglShareLists", [(HGLRC, "hglrc1"), (HGLRC, "hglrc2")]),
José Fonsecafe3791e2010-11-25 11:28:52 +0000203 StdFunction(HGLRC, "wglCreateLayerContext", [(HDC, "hdc"), (Int, "iLayerPlane")]),
204 StdFunction(BOOL, "wglDescribeLayerPlane", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nBytes"), Out(Pointer(LAYERPLANEDESCRIPTOR), "plpd")]),
205 StdFunction(Int, "wglSetLayerPaletteEntries", [(HDC, "hdc"), (Int, "iLayerPlane"), (Int, "iStart"), (Int, "cEntries"), (Array(Const(COLORREF), "cEntries"), "pcr")]),
206 StdFunction(Int, "wglGetLayerPaletteEntries", [(HDC, "hdc"), (Int, "iLayerPlane"), (Int, "iStart"), (Int, "cEntries"), Out(Array(COLORREF, "cEntries"), "pcr")], sideeffects=False),
207 StdFunction(BOOL, "wglRealizeLayerPalette", [(HDC, "hdc"), (Int, "iLayerPlane"), (BOOL, "bRealize")]),
208 StdFunction(BOOL, "wglSwapLayerBuffers", [(HDC, "hdc"), (UINT, "fuPlanes")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000209 StdFunction(BOOL, "wglUseFontBitmapsA", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase")]),
210 StdFunction(BOOL, "wglUseFontBitmapsW", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase")]),
José Fonsecafe3791e2010-11-25 11:28:52 +0000211 StdFunction(DWORD, "wglSwapMultipleBuffers", [(UINT, "n"), (Array(Const(WGLSWAP), "n"), "ps")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000212 StdFunction(BOOL, "wglUseFontOutlinesA", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase"), (FLOAT, "deviation"), (FLOAT, "extrusion"), (Int, "format"), (LPGLYPHMETRICSFLOAT, "lpgmf")]),
213 StdFunction(BOOL, "wglUseFontOutlinesW", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase"), (FLOAT, "deviation"), (FLOAT, "extrusion"), (Int, "format"), (LPGLYPHMETRICSFLOAT, "lpgmf")]),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000214
215 # WGL_ARB_buffer_region
216 StdFunction(HANDLE, "wglCreateBufferRegionARB", [(HDC, "hDC"), (Int, "iLayerPlane"), (UINT, "uType")]),
217 StdFunction(VOID, "wglDeleteBufferRegionARB", [(HANDLE, "hRegion")]),
218 StdFunction(BOOL, "wglSaveBufferRegionARB", [(HANDLE, "hRegion"), (Int, "x"), (Int, "y"), (Int, "width"), (Int, "height")]),
219 StdFunction(BOOL, "wglRestoreBufferRegionARB", [(HANDLE, "hRegion"), (Int, "x"), (Int, "y"), (Int, "width"), (Int, "height"), (Int, "xSrc"), (Int, "ySrc")]),
220
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000221 # WGL_ARB_extensions_string
José Fonseca5f81c3a2010-11-24 08:42:22 +0000222 StdFunction(Const(CString), "wglGetExtensionsStringARB", [(HDC, "hdc")], sideeffects=False),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000223
José Fonsecac36f1482010-11-24 16:56:54 +0000224 # 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"), (Const(OpaquePointer(Int)), "piAttribIList"), (Const(OpaquePointer(FLOAT)), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "nMaxFormats"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]),
228
José Fonseca01dc3792010-11-24 16:50:31 +0000229 # WGL_ARB_make_current_read
230 StdFunction(BOOL, "wglMakeContextCurrentARB", [(HDC, "hDrawDC"), (HDC, "hReadDC"), (HGLRC, "hglrc")]),
231 StdFunction(HDC, "wglGetCurrentReadDCARB", [], sideeffects=False),
232
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000233 # WGL_ARB_pbuffer
José Fonsecac36f1482010-11-24 16:56:54 +0000234 StdFunction(HPBUFFERARB, "wglCreatePbufferARB", [(HDC, "hDC"), (Int, "iPixelFormat"), (Int, "iWidth"), (Int, "iHeight"), (Const(OpaquePointer(Int)), "piAttribList")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000235 StdFunction(HDC, "wglGetPbufferDCARB", [(HPBUFFERARB, "hPbuffer")], sideeffects=False),
236 StdFunction(Int, "wglReleasePbufferDCARB", [(HPBUFFERARB, "hPbuffer"), (HDC, "hDC")]),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000237 StdFunction(BOOL, "wglDestroyPbufferARB", [(HPBUFFERARB, "hPbuffer")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000238 StdFunction(BOOL, "wglQueryPbufferARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iAttribute"), Out(Pointer(Int), "piValue")]),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000239
José Fonsecac36f1482010-11-24 16:56:54 +0000240 # WGL_ARB_render_texture
241 StdFunction(BOOL, "wglBindTexImageARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iBuffer")]),
242 StdFunction(BOOL, "wglReleaseTexImageARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iBuffer")]),
243 StdFunction(BOOL, "wglSetPbufferAttribARB", [(HPBUFFERARB, "hPbuffer"), (Const(OpaquePointer(Int)), "piAttribList")]),
244
245 # WGL_ARB_create_context
246 StdFunction(HGLRC, "wglCreateContextAttribsARB", [(HDC, "hDC"), (HGLRC, "hShareContext"), (Const(OpaquePointer(Int)), "attribList")]),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000247
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000248 # WGL_EXT_extensions_string
José Fonseca5f81c3a2010-11-24 08:42:22 +0000249 StdFunction(Const(CString), "wglGetExtensionsStringEXT", [], sideeffects=False),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000250
José Fonseca01dc3792010-11-24 16:50:31 +0000251 # WGL_EXT_make_current_read
252 StdFunction(BOOL, "wglMakeContextCurrentEXT", [(HDC, "hDrawDC"), (HDC, "hReadDC"), (HGLRC, "hglrc")]),
253 StdFunction(HDC, "wglGetCurrentReadDCEXT", [], sideeffects=False),
254
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000255 # WGL_EXT_pixel_format
256 StdFunction(BOOL, "wglGetPixelFormatAttribivEXT", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(attribute, "nAttributes"), "piAttributes"), Out(Array(Int, "nAttributes"), "piValues")], sideeffects=False),
257 StdFunction(BOOL, "wglGetPixelFormatAttribfvEXT", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(attribute, "nAttributes"), "piAttributes"), Out(Array(FLOAT, "nAttributes"), "pfValues")], sideeffects=False),
258 StdFunction(BOOL, "wglChoosePixelFormatEXT", [(HDC, "hdc"), (Pointer(Const(Int)), "piAttribIList"), (Pointer(Const(FLOAT)), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "nMaxFormats"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]),
259
José Fonseca01dc3792010-11-24 16:50:31 +0000260 # WGL_EXT_swap_control
261 StdFunction(BOOL, "wglSwapIntervalEXT", [(Int, "interval")]),
262 StdFunction(Int, "wglGetSwapIntervalEXT", [], sideeffects=False),
263
José Fonseca76819862010-11-25 19:06:00 +0000264 # WGL_NV_vertex_array_range
265 StdFunction(OpaquePointer(Void), "wglAllocateMemoryNV", [(GLsizei, "size"), (GLfloat, "readfreq"), (GLfloat, "writefreq"), (GLfloat, "priority")]),
266 StdFunction(Void, "wglFreeMemoryNV", [(OpaquePointer(Void), "pointer")]),
267
José Fonseca4441baf2010-11-25 19:55:27 +0000268 # GL_WIN_swap_hint
269 StdFunction(Void, "glAddSwapHintRectWIN", [(GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
270
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000271 # must be last
272 StdFunction(PROC, "wglGetProcAddress", [(LPCSTR, "lpszProc")]),
273])