blob: f966df1c94d6c8e70216f59e3096614b47902c35 [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
José Fonseca4a826ed2010-11-30 16:58:22 +000027"""WGL API description"""
28
29
José Fonseca8fbdd3a2010-11-23 20:55:07 +000030from glapi import *
José Fonsecaf20c1262010-11-25 11:39:57 +000031from winapi import *
José Fonseca4bfa5ab2011-03-09 15:47:55 +000032from wglenum import *
José Fonseca8fbdd3a2010-11-23 20:55:07 +000033
34
José Fonseca81301932012-11-11 00:10:20 +000035wglapi = Module("WGL")
José Fonseca8fbdd3a2010-11-23 20:55:07 +000036
37
38HGLRC = Alias("HGLRC", HANDLE)
39PROC = Opaque("PROC")
40
41PFD = Flags(DWORD, [
42 "PFD_DOUBLEBUFFER",
43 "PFD_STEREO",
44 "PFD_DRAW_TO_WINDOW",
45 "PFD_DRAW_TO_BITMAP",
46 "PFD_SUPPORT_GDI",
47 "PFD_SUPPORT_OPENGL",
48 "PFD_GENERIC_FORMAT",
49 "PFD_NEED_PALETTE",
50 "PFD_NEED_SYSTEM_PALETTE",
51 "PFD_SWAP_EXCHANGE",
52 "PFD_SWAP_COPY",
53 "PFD_SWAP_LAYER_BUFFERS",
54 "PFD_GENERIC_ACCELERATED",
55 "PFD_SUPPORT_DIRECTDRAW",
José Fonsecaf0442832011-03-09 14:29:26 +000056 "PFD_SUPPORT_COMPOSITION",
José Fonseca8fbdd3a2010-11-23 20:55:07 +000057 "PFD_DEPTH_DONTCARE",
58 "PFD_DOUBLEBUFFER_DONTCARE",
59 "PFD_STEREO_DONTCARE",
60])
61
62PIXELFORMATDESCRIPTOR = Struct("PIXELFORMATDESCRIPTOR", [
63 (WORD, "nSize"),
64 (WORD, "nVersion"),
65 (PFD, "dwFlags"),
66 (BYTE, "iPixelType"),
67 (BYTE, "cColorBits"),
68 (BYTE, "cRedBits"),
69 (BYTE, "cRedShift"),
70 (BYTE, "cGreenBits"),
71 (BYTE, "cGreenShift"),
72 (BYTE, "cBlueBits"),
73 (BYTE, "cBlueShift"),
74 (BYTE, "cAlphaBits"),
75 (BYTE, "cAlphaShift"),
76 (BYTE, "cAccumBits"),
77 (BYTE, "cAccumRedBits"),
78 (BYTE, "cAccumGreenBits"),
79 (BYTE, "cAccumBlueBits"),
80 (BYTE, "cAccumAlphaBits"),
81 (BYTE, "cDepthBits"),
82 (BYTE, "cStencilBits"),
83 (BYTE, "cAuxBuffers"),
84 (BYTE, "iLayerType"),
85 (BYTE, "bReserved"),
86 (DWORD, "dwLayerMask"),
87 (DWORD, "dwVisibleMask"),
88 (DWORD, "dwDamageMask"),
89])
90
91POINTFLOAT = Struct("POINTFLOAT", [
92 (FLOAT, "x"),
93 (FLOAT, "y"),
94])
95
96GLYPHMETRICSFLOAT = Struct("GLYPHMETRICSFLOAT", [
97 (FLOAT, "gmfBlackBoxX"),
98 (FLOAT, "gmfBlackBoxY"),
99 (POINTFLOAT, "gmfptGlyphOrigin"),
100 (FLOAT, "gmfCellIncX"),
101 (FLOAT, "gmfCellIncY"),
102])
103LPGLYPHMETRICSFLOAT = Pointer(GLYPHMETRICSFLOAT)
104
105COLORREF = Alias("COLORREF", DWORD)
106
107
108LAYERPLANEDESCRIPTOR = Struct("LAYERPLANEDESCRIPTOR", [
109 (WORD, "nSize"),
110 (WORD, "nVersion"),
111 (DWORD, "dwFlags"),
112 (BYTE, "iPixelType"),
113 (BYTE, "cColorBits"),
114 (BYTE, "cRedBits"),
115 (BYTE, "cRedShift"),
116 (BYTE, "cGreenBits"),
117 (BYTE, "cGreenShift"),
118 (BYTE, "cBlueBits"),
119 (BYTE, "cBlueShift"),
120 (BYTE, "cAlphaBits"),
121 (BYTE, "cAlphaShift"),
122 (BYTE, "cAccumBits"),
123 (BYTE, "cAccumRedBits"),
124 (BYTE, "cAccumGreenBits"),
125 (BYTE, "cAccumBlueBits"),
126 (BYTE, "cAccumAlphaBits"),
127 (BYTE, "cDepthBits"),
128 (BYTE, "cStencilBits"),
129 (BYTE, "cAuxBuffers"),
130 (BYTE, "iLayerPlane"),
131 (BYTE, "bReserved"),
132 (COLORREF, "crTransparent"),
133])
134LPLAYERPLANEDESCRIPTOR = Pointer(LAYERPLANEDESCRIPTOR)
135
136WGLSWAP = Struct("WGLSWAP", [
José Fonseca19828972010-11-29 20:34:32 +0000137 (HDC, "hdc"),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000138 (UINT, "uiFlags"),
139])
140
Andreas Hartmetz13cd0ab2013-07-09 22:56:31 +0200141WGLContextAttribs = AttribArray(WGLenum, [
142 ('WGL_CONTEXT_MAJOR_VERSION_ARB', Int),
143 ('WGL_CONTEXT_MINOR_VERSION_ARB', Int),
144 ('WGL_CONTEXT_LAYER_PLANE_ARB', Int),
145 ('WGL_CONTEXT_FLAGS_ARB', Flags(Int, ["WGL_CONTEXT_DEBUG_BIT_ARB", "WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB"])),
146 ('WGL_CONTEXT_PROFILE_MASK_ARB', Flags(Int, ["WGL_CONTEXT_CORE_PROFILE_BIT_ARB", "WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB"]))
147])
148
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000149HPBUFFERARB = Alias("HPBUFFERARB", HANDLE)
150
151
José Fonseca54f304a2012-01-14 19:33:08 +0000152wglapi.addFunctions([
José Fonsecaa9e80d02010-11-24 15:56:47 +0000153 # WGL
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000154 StdFunction(HGLRC, "wglCreateContext", [(HDC, "hdc")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000155 StdFunction(BOOL, "wglDeleteContext", [(HGLRC, "hglrc")]),
156 StdFunction(HGLRC, "wglGetCurrentContext", [], sideeffects=False),
José Fonsecafe3791e2010-11-25 11:28:52 +0000157 StdFunction(BOOL, "wglMakeCurrent", [(HDC, "hdc"), (HGLRC, "hglrc")]),
158 StdFunction(BOOL, "wglCopyContext", [(HGLRC, "hglrcSrc"), (HGLRC, "hglrcDst"), (UINT, "mask")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000159 StdFunction(Int, "wglChoosePixelFormat", [(HDC, "hdc"), (Pointer(Const(PIXELFORMATDESCRIPTOR)), "ppfd")]),
160 StdFunction(Int, "wglDescribePixelFormat", [(HDC, "hdc"), (Int, "iPixelFormat"), (UINT, "nBytes"), Out(Pointer(PIXELFORMATDESCRIPTOR), "ppfd")]),
José Fonsecafe3791e2010-11-25 11:28:52 +0000161 StdFunction(HDC, "wglGetCurrentDC", [], sideeffects=False),
162 StdFunction(PROC, "wglGetDefaultProcAddress", [(LPCSTR, "lpszProc")], sideeffects=False),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000163 StdFunction(Int, "wglGetPixelFormat", [(HDC, "hdc")], sideeffects=False),
164 StdFunction(BOOL, "wglSetPixelFormat", [(HDC, "hdc"), (Int, "iPixelFormat"), (Pointer(Const(PIXELFORMATDESCRIPTOR)), "ppfd")]),
José Fonsecafe3791e2010-11-25 11:28:52 +0000165 StdFunction(BOOL, "wglSwapBuffers", [(HDC, "hdc")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000166 StdFunction(BOOL, "wglShareLists", [(HGLRC, "hglrc1"), (HGLRC, "hglrc2")]),
José Fonsecafe3791e2010-11-25 11:28:52 +0000167 StdFunction(HGLRC, "wglCreateLayerContext", [(HDC, "hdc"), (Int, "iLayerPlane")]),
168 StdFunction(BOOL, "wglDescribeLayerPlane", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nBytes"), Out(Pointer(LAYERPLANEDESCRIPTOR), "plpd")]),
169 StdFunction(Int, "wglSetLayerPaletteEntries", [(HDC, "hdc"), (Int, "iLayerPlane"), (Int, "iStart"), (Int, "cEntries"), (Array(Const(COLORREF), "cEntries"), "pcr")]),
170 StdFunction(Int, "wglGetLayerPaletteEntries", [(HDC, "hdc"), (Int, "iLayerPlane"), (Int, "iStart"), (Int, "cEntries"), Out(Array(COLORREF, "cEntries"), "pcr")], sideeffects=False),
171 StdFunction(BOOL, "wglRealizeLayerPalette", [(HDC, "hdc"), (Int, "iLayerPlane"), (BOOL, "bRealize")]),
172 StdFunction(BOOL, "wglSwapLayerBuffers", [(HDC, "hdc"), (UINT, "fuPlanes")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000173 StdFunction(BOOL, "wglUseFontBitmapsA", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase")]),
174 StdFunction(BOOL, "wglUseFontBitmapsW", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase")]),
José Fonsecafe3791e2010-11-25 11:28:52 +0000175 StdFunction(DWORD, "wglSwapMultipleBuffers", [(UINT, "n"), (Array(Const(WGLSWAP), "n"), "ps")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000176 StdFunction(BOOL, "wglUseFontOutlinesA", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase"), (FLOAT, "deviation"), (FLOAT, "extrusion"), (Int, "format"), (LPGLYPHMETRICSFLOAT, "lpgmf")]),
177 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 +0000178
179 # WGL_ARB_buffer_region
180 StdFunction(HANDLE, "wglCreateBufferRegionARB", [(HDC, "hDC"), (Int, "iLayerPlane"), (UINT, "uType")]),
181 StdFunction(VOID, "wglDeleteBufferRegionARB", [(HANDLE, "hRegion")]),
182 StdFunction(BOOL, "wglSaveBufferRegionARB", [(HANDLE, "hRegion"), (Int, "x"), (Int, "y"), (Int, "width"), (Int, "height")]),
183 StdFunction(BOOL, "wglRestoreBufferRegionARB", [(HANDLE, "hRegion"), (Int, "x"), (Int, "y"), (Int, "width"), (Int, "height"), (Int, "xSrc"), (Int, "ySrc")]),
184
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000185 # WGL_ARB_extensions_string
José Fonsecabcfc81b2012-08-07 21:07:22 +0100186 StdFunction(ConstCString, "wglGetExtensionsStringARB", [(HDC, "hdc")], sideeffects=False),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000187
José Fonsecac36f1482010-11-24 16:56:54 +0000188 # WGL_ARB_pixel_format
José Fonseca4bfa5ab2011-03-09 15:47:55 +0000189 StdFunction(BOOL, "wglGetPixelFormatAttribivARB", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(WGLenum, "nAttributes"), "piAttributes"), Out(Array(Int, "nAttributes"), "piValues")], sideeffects=False),
190 StdFunction(BOOL, "wglGetPixelFormatAttribfvARB", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(WGLenum, "nAttributes"), "piAttributes"), Out(Array(FLOAT, "nAttributes"), "pfValues")], sideeffects=False),
José Fonseca632a78d2012-04-19 07:18:59 +0100191 StdFunction(BOOL, "wglChoosePixelFormatARB", [(HDC, "hdc"), (Array(Const(WGLenum), "_AttribPairList_size(piAttribIList)"), "piAttribIList"), (Array(Const(FLOAT), "_AttribPairList_size(pfAttribFList)"), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "(*nNumFormats)"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]),
José Fonsecac36f1482010-11-24 16:56:54 +0000192
José Fonseca01dc3792010-11-24 16:50:31 +0000193 # WGL_ARB_make_current_read
194 StdFunction(BOOL, "wglMakeContextCurrentARB", [(HDC, "hDrawDC"), (HDC, "hReadDC"), (HGLRC, "hglrc")]),
195 StdFunction(HDC, "wglGetCurrentReadDCARB", [], sideeffects=False),
196
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000197 # WGL_ARB_pbuffer
José Fonseca632a78d2012-04-19 07:18:59 +0100198 StdFunction(HPBUFFERARB, "wglCreatePbufferARB", [(HDC, "hDC"), (Int, "iPixelFormat"), (Int, "iWidth"), (Int, "iHeight"), (Array(Const(WGLenum), "_AttribPairList_size(piAttribList)"), "piAttribList")]),
José Fonseca62617d12011-05-05 21:12:54 +0100199 StdFunction(HDC, "wglGetPbufferDCARB", [(HPBUFFERARB, "hPbuffer")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000200 StdFunction(Int, "wglReleasePbufferDCARB", [(HPBUFFERARB, "hPbuffer"), (HDC, "hDC")]),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000201 StdFunction(BOOL, "wglDestroyPbufferARB", [(HPBUFFERARB, "hPbuffer")]),
José Fonseca62617d12011-05-05 21:12:54 +0100202 StdFunction(BOOL, "wglQueryPbufferARB", [(HPBUFFERARB, "hPbuffer"), (WGLenum, "iAttribute"), Out(Pointer(Int), "piValue")], sideeffects=False),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000203
José Fonsecac36f1482010-11-24 16:56:54 +0000204 # WGL_ARB_render_texture
205 StdFunction(BOOL, "wglBindTexImageARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iBuffer")]),
206 StdFunction(BOOL, "wglReleaseTexImageARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iBuffer")]),
José Fonseca632a78d2012-04-19 07:18:59 +0100207 StdFunction(BOOL, "wglSetPbufferAttribARB", [(HPBUFFERARB, "hPbuffer"), (Array(Const(WGLenum), "_AttribPairList_size(piAttribList)"), "piAttribList")]),
José Fonsecac36f1482010-11-24 16:56:54 +0000208
209 # WGL_ARB_create_context
Andreas Hartmetz13cd0ab2013-07-09 22:56:31 +0200210 StdFunction(HGLRC, "wglCreateContextAttribsARB", [(HDC, "hDC"), (HGLRC, "hShareContext"), (WGLContextAttribs, "attribList")]),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000211
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000212 # WGL_EXT_extensions_string
José Fonsecabcfc81b2012-08-07 21:07:22 +0100213 StdFunction(ConstCString, "wglGetExtensionsStringEXT", [], sideeffects=False),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000214
José Fonseca01dc3792010-11-24 16:50:31 +0000215 # WGL_EXT_make_current_read
216 StdFunction(BOOL, "wglMakeContextCurrentEXT", [(HDC, "hDrawDC"), (HDC, "hReadDC"), (HGLRC, "hglrc")]),
217 StdFunction(HDC, "wglGetCurrentReadDCEXT", [], sideeffects=False),
218
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000219 # WGL_EXT_pixel_format
José Fonseca4bfa5ab2011-03-09 15:47:55 +0000220 StdFunction(BOOL, "wglGetPixelFormatAttribivEXT", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(WGLenum, "nAttributes"), "piAttributes"), Out(Array(Int, "nAttributes"), "piValues")], sideeffects=False),
221 StdFunction(BOOL, "wglGetPixelFormatAttribfvEXT", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(WGLenum, "nAttributes"), "piAttributes"), Out(Array(FLOAT, "nAttributes"), "pfValues")], sideeffects=False),
José Fonseca632a78d2012-04-19 07:18:59 +0100222 StdFunction(BOOL, "wglChoosePixelFormatEXT", [(HDC, "hdc"), (Array(Const(WGLenum), "_AttribPairList_size(piAttribIList)"), "piAttribIList"), (Array(Const(FLOAT), "_AttribPairList_size(pfAttribFList)"), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "*nNumFormats"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000223
José Fonseca01dc3792010-11-24 16:50:31 +0000224 # WGL_EXT_swap_control
225 StdFunction(BOOL, "wglSwapIntervalEXT", [(Int, "interval")]),
226 StdFunction(Int, "wglGetSwapIntervalEXT", [], sideeffects=False),
227
José Fonseca76819862010-11-25 19:06:00 +0000228 # WGL_NV_vertex_array_range
229 StdFunction(OpaquePointer(Void), "wglAllocateMemoryNV", [(GLsizei, "size"), (GLfloat, "readfreq"), (GLfloat, "writefreq"), (GLfloat, "priority")]),
230 StdFunction(Void, "wglFreeMemoryNV", [(OpaquePointer(Void), "pointer")]),
231
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000232 # must be last
233 StdFunction(PROC, "wglGetProcAddress", [(LPCSTR, "lpszProc")]),
234])