From 35eba8b2efe20f68dc86fca0c755075654b0dc0c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 9 Mar 2011 14:30:57 +0000 Subject: [PATCH] Compute WGL attribute list sizes. --- glsize.hpp | 20 ++++++++++++++++++++ wglapi.py | 8 ++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/glsize.hpp b/glsize.hpp index ead293b..7473543 100644 --- a/glsize.hpp +++ b/glsize.hpp @@ -1404,4 +1404,24 @@ __glTexImage3D_size(GLenum format, GLenum type, GLsizei width, GLsizei height, G #define __glBitmap_size(width, height) __glTexImage2D_size(GL_COLOR_INDEX, GL_BITMAP, width, height, 0) #define __glPolygonStipple_size() __glBitmap_size(32, 32) + +/* + * 0 terminated integer/float attribute list. + */ +template +static inline size_t +__AttribList_size(const T *pAttribList) +{ + size_t size = 0; + + if (pAttribList) { + do { + ++size; + } while (*pAttribList++); + } + + return size; +} + + #endif /* _GL_HELPERS_HPP_ */ diff --git a/wglapi.py b/wglapi.py index 06fe7e9..bee9db5 100644 --- a/wglapi.py +++ b/wglapi.py @@ -228,14 +228,14 @@ wglapi.add_functions([ # WGL_ARB_pixel_format StdFunction(BOOL, "wglGetPixelFormatAttribivARB", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(attribute, "nAttributes"), "piAttributes"), Out(Array(Int, "nAttributes"), "piValues")], sideeffects=False), StdFunction(BOOL, "wglGetPixelFormatAttribfvARB", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(attribute, "nAttributes"), "piAttributes"), Out(Array(FLOAT, "nAttributes"), "pfValues")], sideeffects=False), - StdFunction(BOOL, "wglChoosePixelFormatARB", [(HDC, "hdc"), (Const(OpaquePointer(Int)), "piAttribIList"), (Const(OpaquePointer(FLOAT)), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "nMaxFormats"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]), + StdFunction(BOOL, "wglChoosePixelFormatARB", [(HDC, "hdc"), (Const(Array(Int, "__AttribList_size(piAttribIList)")), "piAttribIList"), (Const(Array(FLOAT, "__AttribList_size(pfAttribFList)")), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "(*nNumFormats)"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]), # WGL_ARB_make_current_read StdFunction(BOOL, "wglMakeContextCurrentARB", [(HDC, "hDrawDC"), (HDC, "hReadDC"), (HGLRC, "hglrc")]), StdFunction(HDC, "wglGetCurrentReadDCARB", [], sideeffects=False), # WGL_ARB_pbuffer - StdFunction(HPBUFFERARB, "wglCreatePbufferARB", [(HDC, "hDC"), (Int, "iPixelFormat"), (Int, "iWidth"), (Int, "iHeight"), (Const(OpaquePointer(Int)), "piAttribList")]), + StdFunction(HPBUFFERARB, "wglCreatePbufferARB", [(HDC, "hDC"), (Int, "iPixelFormat"), (Int, "iWidth"), (Int, "iHeight"), (Const(Array(Int, "__AttribList_size(piAttribList)")), "piAttribList")]), StdFunction(HDC, "wglGetPbufferDCARB", [(HPBUFFERARB, "hPbuffer")], sideeffects=False), StdFunction(Int, "wglReleasePbufferDCARB", [(HPBUFFERARB, "hPbuffer"), (HDC, "hDC")]), StdFunction(BOOL, "wglDestroyPbufferARB", [(HPBUFFERARB, "hPbuffer")]), @@ -244,10 +244,10 @@ wglapi.add_functions([ # WGL_ARB_render_texture StdFunction(BOOL, "wglBindTexImageARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iBuffer")]), StdFunction(BOOL, "wglReleaseTexImageARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iBuffer")]), - StdFunction(BOOL, "wglSetPbufferAttribARB", [(HPBUFFERARB, "hPbuffer"), (Const(OpaquePointer(Int)), "piAttribList")]), + StdFunction(BOOL, "wglSetPbufferAttribARB", [(HPBUFFERARB, "hPbuffer"), (Const(Array(Int, "__AttribList_size(piAttribList)")), "piAttribList")]), # WGL_ARB_create_context - StdFunction(HGLRC, "wglCreateContextAttribsARB", [(HDC, "hDC"), (HGLRC, "hShareContext"), (Const(OpaquePointer(Int)), "attribList")]), + StdFunction(HGLRC, "wglCreateContextAttribsARB", [(HDC, "hDC"), (HGLRC, "hShareContext"), (Const(Array(Int, "__AttribList_size(attribList)")), "attribList")]), # WGL_EXT_extensions_string StdFunction(Const(CString), "wglGetExtensionsStringEXT", [], sideeffects=False), -- 2.43.0