def on_close(self): logging.info("Deleting media player") self.media_player.delete() for fence in self.fences: gl.glDeleteSync(fence) pyglet.app.exit()
def on_draw(self): gl.glEnable(gl.GL_DEPTH_TEST) self.shader.use() self.player.update_matrices() while len(self.fences) > self.options.MAX_CPU_AHEAD_FRAMES: fence = self.fences.popleft() gl.glClientWaitSync(fence, gl.GL_SYNC_FLUSH_COMMANDS_BIT, 2147483647) gl.glDeleteSync(fence) self.window.clear() self.world.prepare_rendering() self.world.draw() # Draw the F3 Debug screen if self.show_f3: self.draw_f3() # Draw pause menu if self.show_pause: self.draw_pause() # CPU - GPU Sync if not self.options.SMOOTH_FPS: self.fences.append( gl.glFenceSync(gl.GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) else: gl.glFinish()
def on_save_game(self): self.window.mouse_captured = False self.window.set_exclusive_mouse(False) self.show_pause = True self.media_player.delete() for fence in self.fences: gl.glDeleteSync(fence) self.world.save.save() self.window.show_menu()