+ 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::releaseContext((uintptr_t)ctx)) {'
+ print ' if (_CGLGetCurrentContext() == ctx) {'
+ print ' gltrace::clearContext();'
+ print ' }'
+ print ' }'
+