From 53eb3180a583cd755604f9b41e5ab0d285c2269a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 9 Jul 2012 10:47:16 +0100 Subject: [PATCH] Fix CGL. --- wrappers/cgltrace.py | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/wrappers/cgltrace.py b/wrappers/cgltrace.py index 9dd3253..4bb0c4c 100644 --- a/wrappers/cgltrace.py +++ b/wrappers/cgltrace.py @@ -40,38 +40,44 @@ class CglTracer(GlTracer): return True def traceFunctionImplBody(self, function): + if function.name == 'CGLReleaseContext': + # Unlike other GL APIs like EGL or GLX, CGL will make the context + # not current if it's the current context. + print ' if (_CGLGetContextRetainCount(ctx) == 1) {' + print ' if (gltrace::releaseContext((uintptr_t)ctx)) {' + print ' if (_CGLGetCurrentContext() == ctx) {' + print ' gltrace::clearContext();' + print ' }' + print ' }' + print ' }' + + if function.name == 'CGLDestroyContext': + # The same rule applies here about the as for CGLReleaseContext. + print ' if (gltrace::destroyContext((uintptr_t)ctx)) {' + print ' if (_CGLGetCurrentContext() == ctx) {' + print ' gltrace::clearContext();' + print ' }' + print ' }' + GlTracer.traceFunctionImplBody(self, function) if function.name == 'CGLCreateContext': - print ' if (_result == kCGLNoError)' + print ' if (_result == kCGLNoError) {' print ' gltrace::createContext((uintptr_t)*ctx);' + print ' }' if function.name == 'CGLSetCurrentContext': print ' if (_result == kCGLNoError) {' - print ' if (ctx != NULL)' + print ' if (ctx != NULL) {' print ' gltrace::setContext((uintptr_t)ctx);' - print ' else' + print ' } else {' print ' gltrace::clearContext();' + print ' }' print ' }' if function.name == 'CGLRetainContext': print ' gltrace::retainContext((uintptr_t)ctx);' - if function.name == 'CGLReleaseContext': - # Unlike other GL APIs like EGL or GLX, CGL will make the context - # not current if it's the current context. - print ' if (gltrace::releaseContext((uintptr_t)ctx)) {' - print ' if ((uintptr_t)ctx == gltrace::getContext())' - print ' gltrace::clearContext();' - print ' }' - - if function.name == 'CGLDestroyContext': - # The same rule applies here about the as for CGLReleaseContext. - print ' if (gltrace::destroyContext((uintptr_t)ctx)) {' - print ' if ((uintptr_t)ctx == gltrace::getContext())' - print ' gltrace::clearContext();' - print ' }' - if __name__ == '__main__': print -- 2.43.0