def stop(self): '''Exit mainloop''' if (glut.glutLeaveMainLoop): glut.glutLeaveMainLoop() else: raise RuntimeError( '''Your GLUT implementation does not allow to stops the main loop''')
def stop(self): '''Exit mainloop''' # FIXME This will also kill the interpreter. # we do not want that. just to close the window and release resources. if (glut.glutLeaveMainLoop): glut.glutLeaveMainLoop() else: raise RuntimeError("Your GLUT implementation does not allow to stops the main loop")
def _vispy_quit(self): for timer in self._timers: timer._vispy_stop() self._timers = [] if hasattr(glut, 'glutLeaveMainLoop') and bool(glut.glutLeaveMainLoop): glut.glutLeaveMainLoop() else: for win in _VP_GLUT_ALL_WINDOWS: win._vispy_close()
def key_pressed(key, x, y): global delta_alpha if key == b'\x1b': GLUT.glutLeaveMainLoop() elif key == b" ": if delta_alpha == 0: delta_alpha = 0.5 else: delta_alpha = 0
def key_pressed(key, x, y): global delta_alpha if key == b"\033": GLUT.glutLeaveMainLoop() # Toggles Rotation elif key == b" ": if delta_alpha == 0: delta_alpha = 0.5 else: delta_alpha = 0
def key_pressed(key, x, y): global piramid_modifier if key == b"\033": GLUT.glutLeaveMainLoop() # Toggles Piramid elif key == b"p": if piramid_modifier == 1: piramid_modifier = 0.5 else: piramid_modifier = 1 GLUT.glutPostRedisplay()
def keyboard(key, x, y): global camera_pos speed = 0.1 if key == 'w': camera_pos[1] += speed elif key == 's': camera_pos[1] -= speed elif key == 'd': camera_pos[0] += speed elif key == 'a': camera_pos[0] -= speed if key in {'w', 's', 'd', 'a'}: update_world() if key == '\033': glut.glutLeaveMainLoop()
def _render(self): try: BaseDisplay._render(self) except StopIteration: self.do_exit() try: glut.glutLeaveMainLoop() except: os._exit(0) except BaseException as e: sys.excepthook(*sys.exc_info()) self.swap_buffers() if self.should_exit: self.do_exit() try: glut.glutLeaveMainLoop() except: os._exit(0)
def key_pressed(key, x, y): global delta_alpha, piramid_modifier if key == b"\033": GLUT.glutLeaveMainLoop() # Toggles Piramid elif key == b"p": if piramid_modifier == 1: piramid_modifier = 0.5 else: piramid_modifier = 1 # Toggles Rotation elif key == b" ": if delta_alpha == 0: delta_alpha = 0.5 else: delta_alpha = 0 GLUT.glutPostRedisplay()
def exit(self): '''Exit mainloop''' if (glut.glutLeaveMainLoop): glut.glutLeaveMainLoop() else: sys.exit();
def key_pressed(self, key, pos_x, pos_y): del pos_x, pos_y if key == b'\033': # esc GLUT.glutLeaveMainLoop() self._data.key_states[ord(key)] = True
def keyboard(self, key, x, y): global ALPHA global COLORMAP global CONTRAST global FULLSCREEN global POINT_SIZE global RECORDSCREEN global TRACEORBITS global ZOOM_FACTOR (ps_min, ps_max) = gl.glGetFloatv(gl.GL_ALIASED_POINT_SIZE_RANGE) if key == ' ': self.rotate['x'] = 0 self.rotate['y'] = 0 self.rotate['z'] = 0 elif key == '+': POINT_SIZE += 1 if POINT_SIZE > ps_max: POINT_SIZE = ps_max elif key == '-': POINT_SIZE -= 1 if POINT_SIZE < ps_min: POINT_SIZE = ps_min elif key == '<': self.rotate['z'] -= 1 elif key == '>': self.rotate['z'] += 1 elif key in '0123456789': COLORMAP = int(key) elif key == 'a': ALPHA /= 1.03125 if ALPHA < 0.0: ALPHA = 0.0 elif key == 'A': ALPHA *= 1.03125 if ALPHA > 1.0: ALPHA = 1.0 elif key == 'c': CONTRAST *= 1.015625 if CONTRAST > 256.0: CONTRAST = 256.0 elif key == 'C': CONTRAST /= 1.015625 if CONTRAST < 0.0625: CONTRAST = 0.0625 elif key == 'r': if not COLORMASK['r']: COLORMASK['r'] = True COLORMASK['g'] = False COLORMASK['b'] = False else: COLORMASK['r'] = False elif key == 'g': if not COLORMASK['g']: COLORMASK['r'] = False COLORMASK['g'] = True COLORMASK['b'] = False else: COLORMASK['g'] = False elif key == 'b': if not COLORMASK['b']: COLORMASK['r'] = False COLORMASK['g'] = False COLORMASK['b'] = True else: COLORMASK['b'] = False elif key == 'Z': ZOOM_FACTOR *= 1.03125 elif key == 'z': ZOOM_FACTOR /= 1.03125 elif key == 'o' or key == 'O': if not TRACEORBITS: TRACEORBITS = True else: TRACEORBITS = False elif key == 'f' or key == 'F': if not FULLSCREEN: glut.glutFullScreen() FULLSCREEN = True else: glut.glutReshapeWindow(WINDOW_WIDTH, WINDOW_HEIGHT) FULLSCREEN = False elif key == 's' or key == 'S': if not RECORDSCREEN: RECORDSCREEN = True else: RECORDSCREEN = False elif key == ESCAPE: self.exitgl = True glut.glutLeaveMainLoop() glut.glutHideWindow() glut.glutSetWindow(self.window_handle) glut.glutPostRedisplay()
def keyboard_handler(key, x, y): if key == b'q': print("Quitting. . .") glut.glutLeaveMainLoop()
def _on_exit(self): GLUT.glutLeaveMainLoop()
def quit(self): self.save_state() GLUT.glutLeaveMainLoop()
def keyboard(self, key, x, y): global ALPHA global COLORMAP global CONTRAST global FULLSCREEN global POINT_SIZE global RECORDSCREEN global TRACEORBITS global ZOOM_FACTOR (ps_min, ps_max) = gl.glGetFloatv(gl.GL_ALIASED_POINT_SIZE_RANGE) if key == " ": self.rotate["x"] = 0 self.rotate["y"] = 0 self.rotate["z"] = 0 elif key == "+": POINT_SIZE += 1 if POINT_SIZE > ps_max: POINT_SIZE = ps_max elif key == "-": POINT_SIZE -= 1 if POINT_SIZE < ps_min: POINT_SIZE = ps_min elif key == "<": self.rotate["z"] -= 1 elif key == ">": self.rotate["z"] += 1 elif key in "0123456789": COLORMAP = int(key) elif key == "a": ALPHA /= 1.03125 if ALPHA < 0.0: ALPHA = 0.0 elif key == "A": ALPHA *= 1.03125 if ALPHA > 1.0: ALPHA = 1.0 elif key == "c": CONTRAST *= 1.015625 if CONTRAST > 256.0: CONTRAST = 256.0 elif key == "C": CONTRAST /= 1.015625 if CONTRAST < 0.0625: CONTRAST = 0.0625 elif key == "r": if not COLORMASK["r"]: COLORMASK["r"] = True COLORMASK["g"] = False COLORMASK["b"] = False else: COLORMASK["r"] = False elif key == "g": if not COLORMASK["g"]: COLORMASK["r"] = False COLORMASK["g"] = True COLORMASK["b"] = False else: COLORMASK["g"] = False elif key == "b": if not COLORMASK["b"]: COLORMASK["r"] = False COLORMASK["g"] = False COLORMASK["b"] = True else: COLORMASK["b"] = False elif key == "Z": ZOOM_FACTOR *= 1.03125 elif key == "z": ZOOM_FACTOR /= 1.03125 elif key == "o" or key == "O": if not TRACEORBITS: TRACEORBITS = True else: TRACEORBITS = False elif key == "f" or key == "F": if not FULLSCREEN: glut.glutFullScreen() FULLSCREEN = True else: glut.glutReshapeWindow(WINDOW_WIDTH, WINDOW_HEIGHT) FULLSCREEN = False elif key == "s" or key == "S": if not RECORDSCREEN: RECORDSCREEN = True else: RECORDSCREEN = False elif key == ESCAPE: self.exitgl = True glut.glutLeaveMainLoop() glut.glutHideWindow() glut.glutSetWindow(self.window_handle) glut.glutPostRedisplay()
def keyboard(self, key, x, y): if key == '\033': glut.glutLeaveMainLoop()
def destroy(self): glut.glutLeaveMainLoop()