def attach(self, canvas): if self.config._requires_gl_3(): raise ContextException('AGL does not support OpenGL 3') super(CarbonContext, self).attach(canvas) if isinstance(canvas, CarbonFullScreenCanvas): # XXX not used any more (cannot use AGL_BUFFER_RECT) agl.aglEnable(self._context, agl.AGL_FS_CAPTURE_SINGLE) agl.aglSetFullScreen(self._context, canvas.width, canvas.height, canvas.screen._refresh_rate, 0) else: agl.aglSetDrawable(self._context, cast(canvas.drawable, agl.AGLDrawable)) agl.aglSetCurrentContext(self._context) if canvas.bounds is not None: bounds = (gl.GLint * 4)(*canvas.bounds) agl.aglSetInteger(self._context, agl.AGL_BUFFER_RECT, bounds) agl.aglEnable(self._context, agl.AGL_BUFFER_RECT) else: agl.aglDisable(self._context, agl.AGL_BUFFER_RECT) _aglcheck() self.set_current()
def detach(self): super(CarbonContext, self).detach() agl.aglSetDrawable(self._context, None) _aglcheck()