def bind(self) -> bool: changed = super().bind() if changed: if self.ebo is not None: self.ebo._set_bound() else: Window.get_active().clear_bound(EBO.kind) return changed
def __init__(self, handle, shareable): self._handle = handle window = Window.get_active() assert window is not None self._window = window self._shareable = shareable if cfg.monitor_leaks: self._stack_trace = traceback.StackSummary.extract(traceback.walk_stack(None))
def test_shared_object_context(): window1 = Window(800, 600, hidden=True) window2 = Window(800, 600, object_context=window1.object_context, hidden=True) window3 = Window(800, 600, hidden=True) window1.activate() ebo = EBO(np.arange(5, dtype=np.uint32)) window2.activate() ebo.bind() window3.activate() with pytest.raises(Exception): ebo.bind() window1.activate() ebo.destroy() window1.destroy() window2.destroy() window3.destroy()
def get_default(cls): return Window.get_default(cls.kind)
def unbind(cls): cls._do_bind(0) Window.get_active().clear_bound(cls.kind)
def _set_bound(self): Window.get_active().set_bound(self.kind, self)
def get_bound(cls): return Window.get_active().get_bound(cls.kind)
# Check for linking errors. if check_errors: if not self.gl_get_program_iv(gl.GL_LINK_STATUS): error = self.gl_get_program_info_log() raise RuntimeError(f'Shader linking failed: {error}') # Detach shaders so that it's possible to free shader source and unlinked object code. for shader in shaders: self.gl_detach_shader(shader) def use(self): self.bind() @classmethod def _do_bind(cls, handle): gl.glUseProgram(handle) def _do_destroy(self): if gl.glDeleteProgram is not None: gl.glDeleteProgram(self.handle) # Add a hook for unhandled exceptions which disables warnings for leak monitoring. old_excepthook = sys.excepthook def excepthook(*args): cfg.monitor_leaks = False old_excepthook(*args) sys.excepthook = excepthook Window.set_bound_default_class(VAO.kind, DefaultVAO)
def window(): window = Window(800, 600, hidden=True) window.activate() yield window window.destroy()