def update(): global position, orientation t0 = time.time() orientation = (rotator**-1) * orientation go = np.array((orientation** -1) * np.matrix([[0], [0], [.2]])).flatten() position[0] += go[0] position[1] += go[1] position[2] += go[2] draw() t1 = time.time() if heightfunc(-position[2], -position[0]) > -position[1]: print("dead") time.sleep(5) position = [0.1, -27, -1.5] makeTea() orientation = np.matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype = np.float) for i, pot in enumerate(teapots): if ((pot[0] + position[0])**2 + (pot[1] + position[1])**2 + (pot[2] + position[2])**2 < 4): teapots[i][3] = True #print position GLUT.glutSetWindowTitle(str(1 / (t1 - t0)))
def display(self): """ Render the scene. """ start = time.time() GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT) GL.glPushMatrix() cam_x = self.zoom * math.sin(self.cam_lat) * math.cos(self.cam_long) cam_y = self.zoom * math.sin(self.cam_lat) * math.sin(self.cam_long) cam_z = self.zoom * math.cos(self.cam_lat) GLU.gluLookAt(cam_x, cam_y, cam_z, 0, 0, 0, 0, 0, 2) self.display_box() self.display_points() self.display_segments() self.display_circles() self.display_polygons() self.display_regions() self.display_sphere() GL.glPopMatrix() GLUT.glutSwapBuffers() render_time = time.time() - start GLUT.glutSetWindowTitle("%.3f" % render_time)
def setFullscreen(self, state): ''' If **state** is True, the set_fullscreen() method requests the window manager to place the window in the fullscreen state. If **state** is False the set_fullscreen() method requests the window manager to toggle off the fullscreen state for the window. Note that in any case, you shouldn't not assume the window state is definitely set afterward, because other entities (e.g. the user or window manager) could fullscreen/unfullscreen it again, and not all window managers honor requests to fullscreen windows. :param bool state: Fullscreen state to be set. ''' if self._fullscreen == state: return if state == True: glut.glutSetWindow( self._id ) self._saved_width = glut.glutGet(glut.GLUT_WINDOW_WIDTH) self._saved_height = glut.glutGet(glut.GLUT_WINDOW_HEIGHT) self._saved_x = glut.glutGet(glut.GLUT_WINDOW_X) self._saved_y = glut.glutGet(glut.GLUT_WINDOW_Y) self._fullscreen = True glut.glutFullScreen() else: self._fullscreen = False glut.glutSetWindow( self._id ) glut.glutReshapeWindow(self._saved_width, self._saved_height) glut.glutPositionWindow( self._saved_x, self._saved_y ) glut.glutSetWindowTitle( self._title )
def show_fps(self, secs=0.0): elapsed_time = self.timer.elapsed() if elapsed_time < secs: self.frame_count += 1 else: fmt = "{0}: {1:.1f} fps @ {2} x {3}" win_title = fmt.format(WINDOW_TITLE_PREFIX, self.frame_count / elapsed_time, self.window_width, self.window_height) glut.glutSetWindow(self.window_handle) glut.glutSetWindowTitle(win_title) self.frame_count = 0 self.timer.start()
def show_fps(self, secs=0.0): elapsed_time = self.timer.elapsed() if elapsed_time < secs: self.frame_count += 1 else: fmt = "{0}: {1:.1f} fps @ {2} x {3}" win_title = fmt.format( WINDOW_TITLE_PREFIX, self.frame_count / elapsed_time, self.window_width, self.window_height ) glut.glutSetWindow(self.window_handle) glut.glutSetWindowTitle(win_title) self.frame_count = 0 self.timer.start()
def timer(self, value): """The timer callback function.""" if value != 0: caption = '{}: {} frames per secound @ {} x {}'.format( self.window_title.decode(), self.frame_count * 4, GLUT.glutGet(GLUT.GLUT_WINDOW_WIDTH), GLUT.glutGet(GLUT.GLUT_WINDOW_HEIGHT)) GLUT.glutSetWindowTitle(caption) self.frame_count = 0 GLUT.glutTimerFunc(250, self.timer, 1) # a quarter of a second
def setTitle(self, title): ''' The set_title() method sets the "title" property of the Window to the value specified by title. The title of a window will be displayed in its title bar. On the X Window System, the title bar is rendered by the window manager, so exactly how the title appears to users may vary according to a user's exact configuration. The title should help a user distinguish this window from other windows they may have open. A good title might include the application name and current document filename. :param string title: the title of the window. ''' glut.glutSetWindow( self._id ) glut.glutSetWindowTitle( title ) self._title = title
def handle_request(self, request): label = request['label'] obj = request['obj'] w = request['which_window'] mv = self.mesh_viewers[w[0]][w[1]] # Handle each type of request. # Some requests require a redraw, and # some don't. if label == 'dynamic_meshes': mv.dynamic_meshes = obj self.need_redraw = True elif label == 'dynamic_models': mv.dynamic_models = obj self.need_redraw = True elif label == 'static_meshes': mv.static_meshes = obj self.need_redraw = True elif label == 'dynamic_lines': mv.dynamic_lines = obj self.need_redraw = True elif label == 'static_lines': mv.static_lines = obj self.need_redraw = True elif label == 'autorecenter': mv.autorecenter = obj self.need_redraw = True elif label == 'titlebar': assert isinstance(obj, str) or isinstance(obj, unicode) self.titlebar = obj glut.glutSetWindowTitle(obj) elif label == 'background_color': gl.glClearColor(obj[0], obj[1], obj[2], 1.0) self.need_redraw = True elif label == 'save_snapshot': # redraws for itself assert isinstance(obj, str) or isinstance(obj, unicode) self.snapshot(obj) elif label == 'get_keypress': self.keypress_port = obj elif label == 'get_mouseclick': self.mouseclick_port = obj elif label == 'get_event': self.event_port = obj else: return False # can't handle this request string return True # handled the request string
def set_window_name(self, name): """ Изменение имени текущего окна (str) -> None Аргументы: name - Имя окна Возвращает: None """ # Проверка аргументов if type(name) is not str or not name: return None self.window_name = name # Установка имени окна GLUT.glutSetWindowTitle(self.window_name) # Имя окна
def set_title(self, title): self.activate() glut.glutSetWindowTitle(title) self._title = title
def _vispy_set_title(self, title): # Set the window title. Has no effect for widgets glut.glutSetWindow(self._id) glut.glutSetWindowTitle(title.encode('ASCII'))
def gottasettitle(self): GLUT.glutSetWindow(self.window) GLUT.glutSetWindowTitle(self._title)
def setWindowTitle(text): GLUT.glutSetWindowTitle(text)