X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=wrappers%2Fwgltrace.py;h=c001cb1a988ffcd54f0b1ad8e8bd2242480d87f1;hb=d67cc37dee7e0d60af2cd172fa135962a6dc3ce5;hp=f345869b684f4e6090ad5c169d02f2699a272903;hpb=1b6c87507810fe2d72c81fc109110c1ca25ce94f;p=apitrace diff --git a/wrappers/wgltrace.py b/wrappers/wgltrace.py index f345869..c001cb1 100644 --- a/wrappers/wgltrace.py +++ b/wrappers/wgltrace.py @@ -28,7 +28,7 @@ from gltrace import GlTracer -from specs.stdapi import API +from specs.stdapi import Module, API from specs.glapi import glapi from specs.wglapi import wglapi @@ -39,6 +39,45 @@ class WglTracer(GlTracer): "wglGetProcAddress", ] + createContextFunctionNames = [ + 'wglCreateContext', + 'wglCreateContextAttribsARB', + 'wglCreateLayerContext', + ] + + destroyContextFunctionNames = [ + 'wglDeleteContext', + ] + + makeCurrentFunctionNames = [ + 'wglMakeCurrent', + 'wglMakeContextCurrentARB', + 'wglMakeContextCurrentEXT', + ] + + def traceFunctionImplBody(self, function): + if function.name in self.destroyContextFunctionNames: + # Unlike other GL APIs like EGL or GLX, WGL will make the context + # inactive if it's currently the active context. + print ' if (_wglGetCurrentContext() == hglrc) {' + print ' gltrace::clearContext();' + print ' }' + print ' gltrace::releaseContext((uintptr_t)hglrc);' + + GlTracer.traceFunctionImplBody(self, function) + + if function.name in self.createContextFunctionNames: + print ' if (_result)' + print ' gltrace::createContext((uintptr_t)_result);' + + if function.name in self.makeCurrentFunctionNames: + print ' if (_result) {' + print ' if (hglrc != NULL)' + print ' gltrace::setContext((uintptr_t)hglrc);' + print ' else' + print ' gltrace::clearContext();' + print ' }' + if __name__ == '__main__': print @@ -57,8 +96,10 @@ if __name__ == '__main__': print '#include "glproc.hpp"' print '#include "glsize.hpp"' print + module = Module() + module.mergeModule(glapi) + module.mergeModule(wglapi) api = API() - api.addApi(glapi) - api.addApi(wglapi) + api.addModule(module) tracer = WglTracer() tracer.traceApi(api)