def set_current(self): if not self.canvas: self.is_ok = 0 raise RuntimeError('Canvas has not been attached') # XXX not per-thread gl.current_context = self # XXX gl_info.set_active_context() glu_info.set_active_context() # Implement workarounds if not self._info: self._info = gl_info.GLInfo() self._info.set_active_context() for attr, check in self._workaround_checks: setattr(self, attr, check(self._info)) # Release textures and buffers on this context scheduled for deletion. # Note that the garbage collector may introduce a race condition, # so operate on a copy of the textures/buffers and remove the deleted # items using list slicing (which is an atomic operation) if self.object_space._doomed_textures: textures = self.object_space._doomed_textures[:] textures = (gl.GLuint * len(textures))(*textures) gl.glDeleteTextures(len(textures), textures) self.object_space._doomed_textures[0:len(textures)] = [] if self.object_space._doomed_buffers: buffers = self.object_space._doomed_buffers[:] buffers = (gl.GLuint * len(buffers))(*buffers) gl.glDeleteBuffers(len(buffers), buffers) self.object_space._doomed_buffers[0:len(buffers)] = []
def set_current(self): if not self.canvas: raise RuntimeError('Canvas has not been attached') # XXX not per-thread gl.current_context = self # XXX gl_info.set_active_context() glu_info.set_active_context() # Implement workarounds if not self._info: self._info = gl_info.GLInfo() self._info.set_active_context() for attr, check in self._workaround_checks: setattr(self, attr, check(self._info)) # Release textures and buffers on this context scheduled for deletion. # Note that the garbage collector may introduce a race condition, # so operate on a copy of the textures/buffers and remove the deleted # items using list slicing (which is an atomic operation) if self.object_space._doomed_textures: textures = self.object_space._doomed_textures[:] textures = (gl.GLuint * len(textures))(*textures) gl.glDeleteTextures(len(textures), textures) self.object_space._doomed_textures[0:len(textures)] = [] if self.object_space._doomed_buffers: buffers = self.object_space._doomed_buffers[:] buffers = (gl.GLuint * len(buffers))(*buffers) gl.glDeleteBuffers(len(buffers), buffers) self.object_space._doomed_buffers[0:len(buffers)] = []
def set_current(self): if not self.canvas: raise RuntimeError('Canvas has not been attached') # XXX not per-thread gl.current_context = self # XXX gl_info.set_active_context() glu_info.set_active_context() # Implement workarounds if not self._info: self._info = gl_info.GLInfo() self._info.set_active_context() for attr, check in self._workaround_checks: setattr(self, attr, check(self._info)) # Release textures on this context scheduled for deletion if self.object_space._doomed_textures: textures = self.object_space._doomed_textures textures = (gl.GLuint * len(textures))(*textures) gl.glDeleteTextures(len(textures), textures) self.object_space._doomed_textures = [] # Release buffers on this context scheduled for deletion if self.object_space._doomed_buffers: buffers = self.object_space._doomed_buffers buffers = (gl.GLuint * len(buffers))(*buffers) gl.glDeleteBuffers(len(buffers), buffers) self.object_space._doomed_buffers = []
def switch_to(self): if sys.platform == 'darwin': agl.aglSetCurrentContext(self._agl_context) _aglcheck() elif sys.platform in ('win32', 'cygwin'): self._dc = _user32.GetDC(self.window.handle) self.context._set_window(self) wgl.wglMakeCurrent(self._dc, self.context.glx_context) else: glx.glXMakeCurrent(self.context.x_display, self.get_property('window').get_xid(),self.context.glx_context) self.context.set_current() gl_info.set_active_context() glu_info.set_active_context()
def switch_to(self): if self._glx_1_3: if not self._glx_window: self._glx_window = glx.glXCreateWindow(self._x_display, self._config._fbconfig, self._window, None) glx.glXMakeContextCurrent(self._x_display, self._glx_window, self._glx_window, self._glx_context) else: glx.glXMakeCurrent(self._x_display, self._window, self._glx_context) self.set_vsync(self._vsync) self._context.set_current() gl_info.set_active_context() glu_info.set_active_context()
def switch_to(self): agl.aglSetCurrentContext(self._agl_context) self._context.set_current() _aglcheck() gl_info.set_active_context() glu_info.set_active_context()
def switch_to(self): wgl.wglMakeCurrent(self._dc, self._wgl_context) self._context.set_current() gl_info.set_active_context() glu_info.set_active_context()