From f3f2e4616521c373a67f63b34323de18f843cfdf Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 23 Mar 2011 18:35:39 -0400 Subject: [PATCH] Implement interception of all of the core GLX functions. --- glxapi.py | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/glxapi.py b/glxapi.py index a99fbd0..d117ed4 100644 --- a/glxapi.py +++ b/glxapi.py @@ -30,10 +30,20 @@ from stdapi import * from glapi import glapi VisualID = Alias("VisualID", UInt32) - -GLXContext = Opaque("GLXContext") Display = Opaque("Display *") Visual = Opaque("Visual *") +Font = Alias("Font", UInt32) +Pixmap = Alias("Pixmap", UInt32) +Window = Alias("Window", UInt32) + +GLXContext = Opaque("GLXContext") +GLXPixmap = Alias("GLXPixmap", UInt32) +GLXDrawable = Alias("GLXDrawable", UInt32) +GLXFBConfig = Opaque("GLXFBConfig") +GLXFBConfigID = Alias("GLXFBConfigID", UInt32) +GLXContextID = Alias("GLXContextID", UInt32) +GLXWindow = Alias("GLXWindow", UInt32) +GLXPbuffer = Alias("GLXPbuffer", UInt32) XVisualInfo = Struct("XVisualInfo", [ (Visual, "visual"), @@ -56,8 +66,69 @@ PROC = Opaque("__GLXextFuncPtr") glxapi.add_functions(glapi.functions) glxapi.add_functions([ + # GLX + Function(Pointer(XVisualInfo), "glXChooseVisual", [(Display, "dpy"), (Int, "screen"), (Pointer(Int), "attribList")]), Function(GLXContext, "glXCreateContext", [(Display, "dpy"), (Pointer(XVisualInfo), "vis"), (GLXContext, "shareList"), (Bool_, "direct")]), - # TODO: the rest + Function(Void, "glXDestroyContext", [(Display, "dpy"), (GLXContext, "ctx")]), + Function(Bool_, "glXMakeCurrent", [(Display, "dpy"), (GLXDrawable, "drawable"), (GLXContext, "ctx")]), + Function(Void, "glXCopyContext", [(Display, "dpy"), (GLXContext, "src"), (GLXContext, "dst"), + (ULong, "mask")]), + Function(Void, "glXSwapBuffers", [(Display, "dpy"), (GLXDrawable, "drawable")]), + Function(GLXPixmap, "glXCreateGLXPixmap", [(Display, "dpy"), (Pointer(XVisualInfo), "visual"), + (Pixmap, "pixmap")]), + Function(Void, "glXDestroyGLXPixmap", [(Display, "dpy"), (GLXPixmap, "pixmap")]), + Function(Bool_, "glXQueryExtension", [(Display, "dpy"), (Pointer(Int), "errorb"), (Pointer(Int), "event")]), + Function(Bool_, "glXQueryVersion", [(Display, "dpy"), (Pointer(Int), "maj"), (Pointer(Int), "min")]), + Function(Bool_, "glXIsDirect", [(Display, "dpy"), (GLXContext, "ctx")]), + Function(Int, "glXGetConfig", [(Display, "dpy"), (Pointer(XVisualInfo), "visual"), + (Int, "attrib"), (Pointer(Int), "value")]), + Function(GLXContext, "glXGetCurrentContext", [], sideeffects=False), + Function(GLXDrawable, "glXGetCurrentDrawable", [], sideeffects=False), + Function(Void, "glXWaitGL", []), + Function(Void, "glXWaitX", []), + Function(Void, "glXUseXFont", [(Font, "font"), (Int, "first"), (Int, "count"), (Int, "list")]), + + # GLX 1.1 and later + Function((Const(String("char *"))), "glXQueryExtensionsString", [(Display, "dpy"), (Int, "screen")]), + Function((Const(String("char *"))), "glXQueryServerString", [(Display, "dpy"), (Int, "screen"), (Int, "name")]), + Function((Const(String("char *"))), "glXGetClientString", [(Display, "dpy"), (Int, "name")]), + + # GLX 1.2 and later + Function(Display, "glXGetCurrentDisplay", [], sideeffects=False), + + # GLX 1.3 and later + Function(Pointer(GLXFBConfig), "glXChooseFBConfig", [(Display, "dpy"), (Int, "screen"), + (Pointer(Const(Int)), "attribList"), (Pointer(Int), "nitems")]), + Function(Int, "glXGetFBConfigAttrib", [(Display, "dpy"), (GLXFBConfig, "config"), + (Int, "attribute"), (Pointer(Int), "value")]), + Function(Pointer(GLXFBConfig), "glXGetFBConfigs", [(Display, "dpy"), (Int, "screen"), + (Pointer(Int), "nelements")]), + Function(Pointer(XVisualInfo), "glXGetVisualFromFBConfig", [(Display, "dpy"), + (GLXFBConfig, "config")]), + Function(GLXWindow, "glXCreateWindow", [(Display, "dpy"), (GLXFBConfig, "config"), + (Window, "win"), (Pointer(Const(Int)), "attribList")]), + Function(Void, "glXDestroyWindow", [(Display, "dpy"), (GLXWindow, "window")]), + Function(GLXPixmap, "glXCreatePixmap", [(Display, "dpy"), (GLXFBConfig, "config"), + (Pixmap, "pixmap"), (Pointer(Const(Int)), "attribList")]), + Function(Void, "glXDestroyPixmap", [(Display, "dpy"), (GLXPixmap, "pixmap")]), + Function(GLXPbuffer, "glXCreatePbuffer", [(Display, "dpy"), (GLXFBConfig, "config"), + (Pointer(Const(Int)), "attribList")]), + Function(Void, "glXDestroyPbuffer", [(Display, "dpy"), (GLXPbuffer, "pbuf")]), + Function(Void, "glXQueryDrawable", [(Display, "dpy"), (GLXDrawable, "draw"), (Int, "attribute"), + (Pointer(UInt), "value")]), + Function(GLXContext, "glXCreateNewContext", [(Display, "dpy"), (GLXFBConfig, "config"), + (Int, "renderType"), (GLXContext, "shareList"), + (Bool_, "direct")]), + Function(Bool_, "glXMakeContextCurrent", [(Display, "dpy"), (GLXDrawable, "draw"), + (GLXDrawable, "read"), (GLXContext, "ctx")]), + Function(GLXDrawable, "glXGetCurrentReadDrawable", []), + Function(Int, "glXQueryContext", [(Display, "dpy"), (GLXContext, "ctx"), (Int, "attribute"), + (Pointer(Int), "value")]), + Function(Void, "glXSelectEvent", [(Display, "dpy"), (GLXDrawable, "drawable"), + (ULong, "mask")]), + Function(Void, "glXGetSelectedEvent", [(Display, "dpy"), (GLXDrawable, "drawable"), + (Pointer(ULong), "mask")]), + # TODO: extensions # Must be last Function(PROC, "glXGetProcAddressARB", [(Alias("const GLubyte *", CString), "procName")]), -- 2.7.4