blob: bb0b6c7d5816912d1bcac472d5ebec152bb5a051 [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
35wglapi = API("WGL")
36wglapi.add_functions(glapi.functions)
37
38
39HGLRC = Alias("HGLRC", HANDLE)
40PROC = Opaque("PROC")
41
42PFD = Flags(DWORD, [
43 "PFD_DOUBLEBUFFER",
44 "PFD_STEREO",
45 "PFD_DRAW_TO_WINDOW",
46 "PFD_DRAW_TO_BITMAP",
47 "PFD_SUPPORT_GDI",
48 "PFD_SUPPORT_OPENGL",
49 "PFD_GENERIC_FORMAT",
50 "PFD_NEED_PALETTE",
51 "PFD_NEED_SYSTEM_PALETTE",
52 "PFD_SWAP_EXCHANGE",
53 "PFD_SWAP_COPY",
54 "PFD_SWAP_LAYER_BUFFERS",
55 "PFD_GENERIC_ACCELERATED",
56 "PFD_SUPPORT_DIRECTDRAW",
José Fonsecaf0442832011-03-09 14:29:26 +000057 "PFD_SUPPORT_COMPOSITION",
José Fonseca8fbdd3a2010-11-23 20:55:07 +000058 "PFD_DEPTH_DONTCARE",
59 "PFD_DOUBLEBUFFER_DONTCARE",
60 "PFD_STEREO_DONTCARE",
61])
62
63PIXELFORMATDESCRIPTOR = Struct("PIXELFORMATDESCRIPTOR", [
64 (WORD, "nSize"),
65 (WORD, "nVersion"),
66 (PFD, "dwFlags"),
67 (BYTE, "iPixelType"),
68 (BYTE, "cColorBits"),
69 (BYTE, "cRedBits"),
70 (BYTE, "cRedShift"),
71 (BYTE, "cGreenBits"),
72 (BYTE, "cGreenShift"),
73 (BYTE, "cBlueBits"),
74 (BYTE, "cBlueShift"),
75 (BYTE, "cAlphaBits"),
76 (BYTE, "cAlphaShift"),
77 (BYTE, "cAccumBits"),
78 (BYTE, "cAccumRedBits"),
79 (BYTE, "cAccumGreenBits"),
80 (BYTE, "cAccumBlueBits"),
81 (BYTE, "cAccumAlphaBits"),
82 (BYTE, "cDepthBits"),
83 (BYTE, "cStencilBits"),
84 (BYTE, "cAuxBuffers"),
85 (BYTE, "iLayerType"),
86 (BYTE, "bReserved"),
87 (DWORD, "dwLayerMask"),
88 (DWORD, "dwVisibleMask"),
89 (DWORD, "dwDamageMask"),
90])
91
92POINTFLOAT = Struct("POINTFLOAT", [
93 (FLOAT, "x"),
94 (FLOAT, "y"),
95])
96
97GLYPHMETRICSFLOAT = Struct("GLYPHMETRICSFLOAT", [
98 (FLOAT, "gmfBlackBoxX"),
99 (FLOAT, "gmfBlackBoxY"),
100 (POINTFLOAT, "gmfptGlyphOrigin"),
101 (FLOAT, "gmfCellIncX"),
102 (FLOAT, "gmfCellIncY"),
103])
104LPGLYPHMETRICSFLOAT = Pointer(GLYPHMETRICSFLOAT)
105
106COLORREF = Alias("COLORREF", DWORD)
107
108
109LAYERPLANEDESCRIPTOR = Struct("LAYERPLANEDESCRIPTOR", [
110 (WORD, "nSize"),
111 (WORD, "nVersion"),
112 (DWORD, "dwFlags"),
113 (BYTE, "iPixelType"),
114 (BYTE, "cColorBits"),
115 (BYTE, "cRedBits"),
116 (BYTE, "cRedShift"),
117 (BYTE, "cGreenBits"),
118 (BYTE, "cGreenShift"),
119 (BYTE, "cBlueBits"),
120 (BYTE, "cBlueShift"),
121 (BYTE, "cAlphaBits"),
122 (BYTE, "cAlphaShift"),
123 (BYTE, "cAccumBits"),
124 (BYTE, "cAccumRedBits"),
125 (BYTE, "cAccumGreenBits"),
126 (BYTE, "cAccumBlueBits"),
127 (BYTE, "cAccumAlphaBits"),
128 (BYTE, "cDepthBits"),
129 (BYTE, "cStencilBits"),
130 (BYTE, "cAuxBuffers"),
131 (BYTE, "iLayerPlane"),
132 (BYTE, "bReserved"),
133 (COLORREF, "crTransparent"),
134])
135LPLAYERPLANEDESCRIPTOR = Pointer(LAYERPLANEDESCRIPTOR)
136
137WGLSWAP = Struct("WGLSWAP", [
José Fonseca19828972010-11-29 20:34:32 +0000138 (HDC, "hdc"),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000139 (UINT, "uiFlags"),
140])
141
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000142HPBUFFERARB = Alias("HPBUFFERARB", HANDLE)
143
144
145wglapi.add_functions([
José Fonsecaa9e80d02010-11-24 15:56:47 +0000146 # WGL
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000147 StdFunction(HGLRC, "wglCreateContext", [(HDC, "hdc")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000148 StdFunction(BOOL, "wglDeleteContext", [(HGLRC, "hglrc")]),
149 StdFunction(HGLRC, "wglGetCurrentContext", [], sideeffects=False),
José Fonsecafe3791e2010-11-25 11:28:52 +0000150 StdFunction(BOOL, "wglMakeCurrent", [(HDC, "hdc"), (HGLRC, "hglrc")]),
151 StdFunction(BOOL, "wglCopyContext", [(HGLRC, "hglrcSrc"), (HGLRC, "hglrcDst"), (UINT, "mask")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000152 StdFunction(Int, "wglChoosePixelFormat", [(HDC, "hdc"), (Pointer(Const(PIXELFORMATDESCRIPTOR)), "ppfd")]),
153 StdFunction(Int, "wglDescribePixelFormat", [(HDC, "hdc"), (Int, "iPixelFormat"), (UINT, "nBytes"), Out(Pointer(PIXELFORMATDESCRIPTOR), "ppfd")]),
José Fonsecafe3791e2010-11-25 11:28:52 +0000154 StdFunction(HDC, "wglGetCurrentDC", [], sideeffects=False),
155 StdFunction(PROC, "wglGetDefaultProcAddress", [(LPCSTR, "lpszProc")], sideeffects=False),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000156 StdFunction(Int, "wglGetPixelFormat", [(HDC, "hdc")], sideeffects=False),
157 StdFunction(BOOL, "wglSetPixelFormat", [(HDC, "hdc"), (Int, "iPixelFormat"), (Pointer(Const(PIXELFORMATDESCRIPTOR)), "ppfd")]),
José Fonsecafe3791e2010-11-25 11:28:52 +0000158 StdFunction(BOOL, "wglSwapBuffers", [(HDC, "hdc")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000159 StdFunction(BOOL, "wglShareLists", [(HGLRC, "hglrc1"), (HGLRC, "hglrc2")]),
José Fonsecafe3791e2010-11-25 11:28:52 +0000160 StdFunction(HGLRC, "wglCreateLayerContext", [(HDC, "hdc"), (Int, "iLayerPlane")]),
161 StdFunction(BOOL, "wglDescribeLayerPlane", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nBytes"), Out(Pointer(LAYERPLANEDESCRIPTOR), "plpd")]),
162 StdFunction(Int, "wglSetLayerPaletteEntries", [(HDC, "hdc"), (Int, "iLayerPlane"), (Int, "iStart"), (Int, "cEntries"), (Array(Const(COLORREF), "cEntries"), "pcr")]),
163 StdFunction(Int, "wglGetLayerPaletteEntries", [(HDC, "hdc"), (Int, "iLayerPlane"), (Int, "iStart"), (Int, "cEntries"), Out(Array(COLORREF, "cEntries"), "pcr")], sideeffects=False),
164 StdFunction(BOOL, "wglRealizeLayerPalette", [(HDC, "hdc"), (Int, "iLayerPlane"), (BOOL, "bRealize")]),
165 StdFunction(BOOL, "wglSwapLayerBuffers", [(HDC, "hdc"), (UINT, "fuPlanes")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000166 StdFunction(BOOL, "wglUseFontBitmapsA", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase")]),
167 StdFunction(BOOL, "wglUseFontBitmapsW", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase")]),
José Fonsecafe3791e2010-11-25 11:28:52 +0000168 StdFunction(DWORD, "wglSwapMultipleBuffers", [(UINT, "n"), (Array(Const(WGLSWAP), "n"), "ps")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000169 StdFunction(BOOL, "wglUseFontOutlinesA", [(HDC, "hdc"), (DWORD, "first"), (DWORD, "count"), (DWORD, "listBase"), (FLOAT, "deviation"), (FLOAT, "extrusion"), (Int, "format"), (LPGLYPHMETRICSFLOAT, "lpgmf")]),
170 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 +0000171
172 # WGL_ARB_buffer_region
173 StdFunction(HANDLE, "wglCreateBufferRegionARB", [(HDC, "hDC"), (Int, "iLayerPlane"), (UINT, "uType")]),
174 StdFunction(VOID, "wglDeleteBufferRegionARB", [(HANDLE, "hRegion")]),
175 StdFunction(BOOL, "wglSaveBufferRegionARB", [(HANDLE, "hRegion"), (Int, "x"), (Int, "y"), (Int, "width"), (Int, "height")]),
176 StdFunction(BOOL, "wglRestoreBufferRegionARB", [(HANDLE, "hRegion"), (Int, "x"), (Int, "y"), (Int, "width"), (Int, "height"), (Int, "xSrc"), (Int, "ySrc")]),
177
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000178 # WGL_ARB_extensions_string
José Fonseca5f81c3a2010-11-24 08:42:22 +0000179 StdFunction(Const(CString), "wglGetExtensionsStringARB", [(HDC, "hdc")], sideeffects=False),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000180
José Fonsecac36f1482010-11-24 16:56:54 +0000181 # WGL_ARB_pixel_format
José Fonseca4bfa5ab2011-03-09 15:47:55 +0000182 StdFunction(BOOL, "wglGetPixelFormatAttribivARB", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(WGLenum, "nAttributes"), "piAttributes"), Out(Array(Int, "nAttributes"), "piValues")], sideeffects=False),
183 StdFunction(BOOL, "wglGetPixelFormatAttribfvARB", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(WGLenum, "nAttributes"), "piAttributes"), Out(Array(FLOAT, "nAttributes"), "pfValues")], sideeffects=False),
184 StdFunction(BOOL, "wglChoosePixelFormatARB", [(HDC, "hdc"), (Const(Array(WGLenum, "__AttribList_size(piAttribIList)")), "piAttribIList"), (Const(Array(FLOAT, "__AttribList_size(pfAttribFList)")), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "(*nNumFormats)"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]),
José Fonsecac36f1482010-11-24 16:56:54 +0000185
José Fonseca01dc3792010-11-24 16:50:31 +0000186 # WGL_ARB_make_current_read
187 StdFunction(BOOL, "wglMakeContextCurrentARB", [(HDC, "hDrawDC"), (HDC, "hReadDC"), (HGLRC, "hglrc")]),
188 StdFunction(HDC, "wglGetCurrentReadDCARB", [], sideeffects=False),
189
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000190 # WGL_ARB_pbuffer
José Fonseca4bfa5ab2011-03-09 15:47:55 +0000191 StdFunction(HPBUFFERARB, "wglCreatePbufferARB", [(HDC, "hDC"), (Int, "iPixelFormat"), (Int, "iWidth"), (Int, "iHeight"), (Const(Array(WGLenum, "__AttribList_size(piAttribList)")), "piAttribList")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000192 StdFunction(HDC, "wglGetPbufferDCARB", [(HPBUFFERARB, "hPbuffer")], sideeffects=False),
193 StdFunction(Int, "wglReleasePbufferDCARB", [(HPBUFFERARB, "hPbuffer"), (HDC, "hDC")]),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000194 StdFunction(BOOL, "wglDestroyPbufferARB", [(HPBUFFERARB, "hPbuffer")]),
José Fonseca4bfa5ab2011-03-09 15:47:55 +0000195 StdFunction(BOOL, "wglQueryPbufferARB", [(HPBUFFERARB, "hPbuffer"), (WGLenum, "iAttribute"), Out(Pointer(Int), "piValue")]),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000196
José Fonsecac36f1482010-11-24 16:56:54 +0000197 # WGL_ARB_render_texture
198 StdFunction(BOOL, "wglBindTexImageARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iBuffer")]),
199 StdFunction(BOOL, "wglReleaseTexImageARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iBuffer")]),
José Fonseca4bfa5ab2011-03-09 15:47:55 +0000200 StdFunction(BOOL, "wglSetPbufferAttribARB", [(HPBUFFERARB, "hPbuffer"), (Const(Array(WGLenum, "__AttribList_size(piAttribList)")), "piAttribList")]),
José Fonsecac36f1482010-11-24 16:56:54 +0000201
202 # WGL_ARB_create_context
José Fonseca4bfa5ab2011-03-09 15:47:55 +0000203 StdFunction(HGLRC, "wglCreateContextAttribsARB", [(HDC, "hDC"), (HGLRC, "hShareContext"), (Const(Array(WGLenum, "__AttribList_size(attribList)")), "attribList")]),
José Fonsecaa9e80d02010-11-24 15:56:47 +0000204
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000205 # WGL_EXT_extensions_string
José Fonseca5f81c3a2010-11-24 08:42:22 +0000206 StdFunction(Const(CString), "wglGetExtensionsStringEXT", [], sideeffects=False),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000207
José Fonseca01dc3792010-11-24 16:50:31 +0000208 # WGL_EXT_make_current_read
209 StdFunction(BOOL, "wglMakeContextCurrentEXT", [(HDC, "hDrawDC"), (HDC, "hReadDC"), (HGLRC, "hglrc")]),
210 StdFunction(HDC, "wglGetCurrentReadDCEXT", [], sideeffects=False),
211
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000212 # WGL_EXT_pixel_format
José Fonseca4bfa5ab2011-03-09 15:47:55 +0000213 StdFunction(BOOL, "wglGetPixelFormatAttribivEXT", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(WGLenum, "nAttributes"), "piAttributes"), Out(Array(Int, "nAttributes"), "piValues")], sideeffects=False),
214 StdFunction(BOOL, "wglGetPixelFormatAttribfvEXT", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(WGLenum, "nAttributes"), "piAttributes"), Out(Array(FLOAT, "nAttributes"), "pfValues")], sideeffects=False),
215 StdFunction(BOOL, "wglChoosePixelFormatEXT", [(HDC, "hdc"), (Pointer(Const(WGLenum)), "piAttribIList"), (Pointer(Const(FLOAT)), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "nMaxFormats"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]),
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000216
José Fonseca01dc3792010-11-24 16:50:31 +0000217 # WGL_EXT_swap_control
218 StdFunction(BOOL, "wglSwapIntervalEXT", [(Int, "interval")]),
219 StdFunction(Int, "wglGetSwapIntervalEXT", [], sideeffects=False),
220
José Fonseca76819862010-11-25 19:06:00 +0000221 # WGL_NV_vertex_array_range
222 StdFunction(OpaquePointer(Void), "wglAllocateMemoryNV", [(GLsizei, "size"), (GLfloat, "readfreq"), (GLfloat, "writefreq"), (GLfloat, "priority")]),
223 StdFunction(Void, "wglFreeMemoryNV", [(OpaquePointer(Void), "pointer")]),
224
José Fonseca4441baf2010-11-25 19:55:27 +0000225 # GL_WIN_swap_hint
226 StdFunction(Void, "glAddSwapHintRectWIN", [(GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
227
José Fonseca8fbdd3a2010-11-23 20:55:07 +0000228 # must be last
229 StdFunction(PROC, "wglGetProcAddress", [(LPCSTR, "lpszProc")]),
230])