Example #1
0
    def render(self):
        self.clock.record_frame_time()

        if self.is_recording and not self.timer.is_snoozed:
            self.frame_index += 1
            frame_name = "Frame_{0:05d}.jpg".format(self.frame_index)
            self.save_screenshot(frame_name)
            self.timer.snooze()


        glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        if camera.is_rotating:
            camera.rotate_z(0.2)
        camera.look()

        self.draw_detector()

        glEnable(GL_DEPTH_TEST)
        glEnable(GL_LINE_SMOOTH)
        glShadeModel(GL_FLAT)
        glEnable(GL_LIGHTING)

        for obj in self.shaded_objects:
            obj.draw(self.clock.time, self.spectrum)

        glDisable(GL_LIGHTING)

        for obj in self.objects:
            obj.draw(self.clock.time)

        self.draw_gui()


        glutSwapBuffers()
Example #2
0
 def render_all_shapes(self):
     glClear(GL_COLOR_BUFFER_BIT)
     #Update our game grid before we draw
     self.grid_instance.updateGrid()
     for _, s in self.grid_instance.active_grid_elements.iteritems():
         s.draw()
     glutSwapBuffers()
def display():
    ctx.viewport = (0, 0, width, height)
    ctx.clear(0.9, 0.9, 0.9)
    ctx.enable(ModernGL.BLEND)
    window_size.value = (width, height)
    vao.render()

    glutSwapBuffers()
Example #4
0
 def onDraw(self):
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     glLoadIdentity()
     glClearColor(*Environment.bgcolor)
     glTranslatef(0.0, 0.0, -10.0)
     for obj in self.objs:
         obj.draw()
     glutSwapBuffers()
Example #5
0
    def __display(self):
        """Render the model by existent vertices, colors and triangles."""
        self.__rotate_model()
        self.__generate_shadows()
        self.__generate_model()

        glutSwapBuffers()
        if self.__callback is not None:
            self.__callback()
Example #6
0
 def disp():
     global _lastTime
     display()
     tick = time()
     required_delta = (1/60) - (tick - _lastTime)
     if (required_delta > 0):
         sleep(required_delta)
     _lastTime = tick
     glutSwapBuffers()
Example #7
0
def display():
    width, height = glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT)
    elapsed = glutGet(GLUT_ELAPSED_TIME) / 1000.0

    ctx.clear(0.9, 0.9, 0.9)
    scale.value = (height / width * 0.75, 0.75)
    rotation.value = elapsed
    vao.render()

    glutSwapBuffers()
    def render_global_picture(self):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()

        self.light_source.draw_light_source()

        for object in self.list_of_objects_to_draw:
            object.render_me()

        glutSwapBuffers()
Example #9
0
File: View.py Project: char-lie/mfm
    def __display(self):
        """Render the model by existent vertices, colors and triangles."""
        self.__rotate_model()
        self.__generate_shadows()
        self.__generate_model()

        glutSwapBuffers()
        if self.__synchronous:
            glFinish()
        elif self.__callback is not None:
            self.__callback()
Example #10
0
def DrawGLScene():
    modelview_matrix, projection_matrix = update_world_matrices()
    contexts["world"]["modelview"]["matrix"] = modelview_matrix
    contexts["world"]["projection"]["matrix"] = projection_matrix

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)    # Clear The Screen And The Depth Buffer
    one = time()
    render_with_context(contexts["world"])
    render_with_context(contexts["interface"])
    two = time()
    glutSwapBuffers()
    three = time()
Example #11
0
    def display(self):
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        gluLookAt(0.0, 240.0, 1000.0, 0.0, 240.0, 0.0, 0.0, 1.0, 0.0)
        glClear(GL_COLOR_BUFFER_BIT)

        for i in self.fountains:
            i.life -= 1
            i.init()
            i.update()

        glutPostRedisplay()
        glutSwapBuffers()
Example #12
0
    def display(self):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        glPushMatrix()
        glTranslatef(0.0, 0.0, -1.0)
        glRotatef(self.rot_x, 1.0, 0.0, 0.0)
        glRotatef(self.rot_z, 0.0, 1.0, 0.0)

        self.render()

        glPopMatrix()
        glFlush()
        glutSwapBuffers()
Example #13
0
 def on_draw(self, want_cameras=False):
     # sys.stderr.write('fps: %.2e\n' % (1. / (time.time() - self.tm_for_fps)))
     self.tm_for_fps = time.time()
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     cameras = []
     for mvl in self.mesh_viewers:
         cameras.append([])
         for mv in mvl:
             cameras[-1].append(mv.on_draw(self.transform, want_cameras))
     glFlush()  # Flush The GL Rendering Pipeline
     glutSwapBuffers()
     self.need_redraw = False
     if want_cameras:
         return cameras
Example #14
0
def draw_points():
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glEnableClientState(GL_VERTEX_ARRAY)
    # glVertexPointer(3, GL_FLOAT, 24, points)
    # glColorPointer(3, GL_INT, 24, points+12)
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 24, points)
    glEnableVertexAttribArray(0)
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 24, points + 12)
    glEnableVertexAttribArray(1)

    glDrawArrays(GL_POINTS, 0, imgnp.shape[0] * imgnp.shape[1])

    glDisableVertexAttribArray(0)
    glDisableVertexAttribArray(1)
    glutSwapBuffers()
Example #15
0
def display():
    ctx.viewport = (0, 0, width, height)
    ctx.clear(0.9, 0.9, 0.9)
    ctx.enable(ModernGL.DEPTH_TEST)

    proj = Matrix44.perspective_projection(45.0, width / height, 0.1, 1000.0)
    lookat = Matrix44.look_at(
        (40.0, 30.0, 20.0),
        (0.0, 0.0, 0.0),
        (0.0, 0.0, 1.0),
    )

    mvp.write((proj * lookat).astype('float32').tobytes())
    vao.render(ModernGL.LINES)

    glutSwapBuffers()
Example #16
0
    def _defaultOnDraw(self):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()

        # We have smooth color mode on, this will blend across the vertices.
        # Draw a triangle rotated on the Y axis.
        glBegin(GL_POLYGON)                 # Start drawing a polygon
        glColor3f(1.0, 0.0, 0.0)            # Red
        glVertex3f(0.0, 1.0, 0.0)           # Top
        glColor3f(0.0, 1.0, 0.0)            # Green
        glVertex3f(1.0, -1.0, 0.0)          # Bottom Right
        glColor3f(0.0, 0.0, 1.0)            # Blue
        glVertex3f(-1.0, -1.0, 0.0)         # Bottom Left
        glEnd()

        glutSwapBuffers()
Example #17
0
    def _defaultOnDraw(self):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()

        # We have smooth color mode on, this will blend across the vertices.
        # Draw a triangle rotated on the Y axis.
        glBegin(GL_POLYGON)  # Start drawing a polygon
        glColor3f(1.0, 0.0, 0.0)  # Red
        glVertex3f(0.0, 1.0, 0.0)  # Top
        glColor3f(0.0, 1.0, 0.0)  # Green
        glVertex3f(1.0, -1.0, 0.0)  # Bottom Right
        glColor3f(0.0, 0.0, 1.0)  # Blue
        glVertex3f(-1.0, -1.0, 0.0)  # Bottom Left
        glEnd()

        glutSwapBuffers()
Example #18
0
def display_scene(curr_moons):
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glPushMatrix()
    glMaterialfv(GL_FRONT, GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
    glTranslatef(0, 0, 0)
    glutSolidSphere(.2, 60, 20)
    glPopMatrix()
    for index, m in enumerate(curr_moons):
        glPushMatrix()
        glMaterialfv(GL_FRONT, GL_DIFFUSE, colors[index])
        glTranslatef(m.x / 10, m.y / 10, m.z / 10)
        glutSolidSphere(.1, 60, 20)
        glPopMatrix()
    apply_gravity(curr_moons)
    apply_velocity(curr_moons)
    glutSwapBuffers()
Example #19
0
 def RenderScene(self):
     """draws the actual descriptor"""
     glClear(GL_COLOR_BUFFER_BIT)
     glMatrixMode(GL_MODELVIEW)
     glLoadIdentity()
     glPushMatrix()
     glTranslatef(-1.0, 0.0, 0.0)
     # draw at -1.0/0.0 - 0.0/1.0
     self.map.Draw(self.descriptor)
     glPopMatrix()
     glPushMatrix()
     # draw at 0.0/0.0 - 1.0/1.0 (standard)
     self.graph.Draw()
     glPopMatrix()
     glPushMatrix()
     glTranslatef(-1.0, -1.0, 0.0)
     # draw at -1.0/-1.0 - 0.0/1.0
     glScale(2.0, 1.0, 1.0)
     self.text.Draw()
     glPopMatrix()
     glutSwapBuffers()
Example #20
0
def display():
    start_point = (
        start_picture_coord[0] * HEIGHT * mosaic_factory.ratio / (args.tiles - 1),
        start_picture_coord[1] * HEIGHT / (args.tiles - 1)
    )
    center = (HEIGHT * mosaic_factory.ratio / 2., HEIGHT / 2.)
    reverse_sigmoid_progress = fake_sigmoid(1 - progress)
    sigmoid_progress = 1 - reverse_sigmoid_progress
    max_zoom = args.tiles
    zoom = max_zoom ** reverse_sigmoid_progress
    angle = start_orientation + sigmoid_progress * angle_difference(
        current_mosaic_picture.orientation,
        start_orientation
    )
    if reverse_sigmoid_progress > 0.1:
        alpha = 1.0
    else:
        alpha = reverse_sigmoid_progress * 10.0

    glClear(GL_COLOR_BUFFER_BIT)
    glPushMatrix()

    glTranslatef(center[0], center[1], 0.0)
    glRotatef(angle, 0, 0, 1)
    glTranslatef(-center[0], -center[1], 0.0)

    glTranslatef(start_point[0], start_point[1], 0.0)
    glScalef(zoom, zoom, 1.0)
    glTranslatef(-start_point[0], -start_point[1], 0.0)

    glColor4f(0.0, 0.0, 0.0, alpha)
    glCallList(mosaic_display_lists[current_mosaic_picture])
    glColor4f(0.0, 0.0, 0.0, 1.0 - alpha)

    glScalef(max_zoom, max_zoom, 1.0)
    glCallList(picture_display_lists[current_mosaic_picture])

    glPopMatrix()
    glutSwapBuffers()
Example #21
0
def display():
    start_point = (start_picture_coord[0] * HEIGHT * mosaic_factory.ratio /
                   (args.tiles - 1),
                   start_picture_coord[1] * HEIGHT / (args.tiles - 1))
    center = (HEIGHT * mosaic_factory.ratio / 2., HEIGHT / 2.)
    reverse_sigmoid_progress = fake_sigmoid(1 - progress)
    sigmoid_progress = 1 - reverse_sigmoid_progress
    max_zoom = args.tiles
    zoom = max_zoom**reverse_sigmoid_progress
    angle = start_orientation + sigmoid_progress * angle_difference(
        current_mosaic_picture.orientation, start_orientation)
    if reverse_sigmoid_progress > 0.1:
        alpha = 1.0
    else:
        alpha = reverse_sigmoid_progress * 10.0

    glClear(GL_COLOR_BUFFER_BIT)
    glPushMatrix()

    glTranslatef(center[0], center[1], 0.0)
    glRotatef(angle, 0, 0, 1)
    glTranslatef(-center[0], -center[1], 0.0)

    glTranslatef(start_point[0], start_point[1], 0.0)
    glScalef(zoom, zoom, 1.0)
    glTranslatef(-start_point[0], -start_point[1], 0.0)

    glColor4f(0.0, 0.0, 0.0, alpha)
    glCallList(mosaic_display_lists[current_mosaic_picture])
    glColor4f(0.0, 0.0, 0.0, 1.0 - alpha)

    glScalef(max_zoom, max_zoom, 1.0)
    glCallList(picture_display_lists[current_mosaic_picture])

    glPopMatrix()
    glutSwapBuffers()
Example #22
0
 def swap_buffers(cls):
     glutSwapBuffers()
    grid += struct.pack('6f', i - 16.0, -16.0, 0.0, 0.0, 0.0, 0.0)
    grid += struct.pack('6f', i - 16.0, 16.0, 0.0, 0.0, 0.0, 0.0)
    grid += struct.pack('6f', -16.0, i - 16.0, 0.0, 0.0, 0.0, 0.0)
    grid += struct.pack('6f', 16.0, i - 16.0, 0.0, 0.0, 0.0, 0.0)

vbo = ctx.buffer(grid)
vao = ctx.simple_vertex_array(prog, vbo, ['in_vert', 'in_color'])


def display():
    ctx.viewport = (0, 0, width, height)
    ctx.clear(0.9, 0.9, 0.9)
    ctx.enable(ModernGL.DEPTH_TEST)

    proj = Matrix44.perspective_projection(45.0, width / height, 0.1, 1000.0)
    lookat = Matrix44.look_at(
        (40.0, 30.0, 20.0),
        (0.0, 0.0, 0.0),
        (0.0, 0.0, 1.0),
    )

    mvp.write((proj * lookat).astype('float32').tobytes())
    vao.render(ModernGL.LINES)

    glutSwapBuffers()


glutDisplayFunc(display)
glutIdleFunc(display)
glutMainLoop()
Example #24
0
 def display_func(self):
     self.update()
     glutSwapBuffers()
def display():
    ctx.clear(0.9, 0.9, 0.9)
    vao.render()
    glutSwapBuffers()
Example #26
0
 def flip(self):
     glutSwapBuffers()
     super(MTWindowGlut, self).flip()
Example #27
0
 def flip(self):
     glutSwapBuffers()
     super(MTWindowGlut, self).flip()
Example #28
0
 def display():
     opengl_app.c_opengl_camera_app.display(og)
     of_obj.draw_opengl_surface(og)
     glutSwapBuffers()
     pass
Example #29
0
    def display(self):

        glLoadIdentity()
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        gluLookAt(self.cam_pos.x, self.cam_pos.y, self.cam_pos.z,
                  self.cam_focus.x, self.cam_focus.y, self.cam_focus.z, 0, 1,
                  0)

        self.level.draw()

        glLoadIdentity()

        gluLookAt(0, -0.5, 2.5, 0, 0, 0, 0, 1, 0)

        wdth = 0.3
        glTranslate(
            0.0 -
            (len(self.level.solomon.current_state.keys()) - 1) * wdth / 2.0,
            -1.3, 0)

        if debug == True:
            for k in self.level.solomon.current_state.keys():
                col = "red"
                if self.level.solomon.current_state[k]: col = "green"
                glMaterialfv(GL_FRONT, GL_DIFFUSE, colours[col])
                glutSolidCube(wdth - 0.02)
                glTranslate(wdth, 0, 0)
                glPushMatrix()
                #glLoadIdentity()
                glScale(0.005, 0.01, -0.01)
                glTranslate(-90, 4, -20)
                #glTranslate(-180,-70,0)
                glTranslate(-wdth, 0, 0)
                self.letters.drawString(k[:4])
                glPopMatrix()

        glLoadIdentity()

        gluLookAt(0, -0.5, 2.5, 0, 0, 0, 0, 1, 0)

        wdth = 0.2

        joystick_actions = [x for x in dir(self.joystick) if x[0:2] == "is"]
        glTranslate(0.0 - (len(joystick_actions) - 1) * wdth / 2.0, -1.0, 0)

        if debug == True:
            for k in joystick_actions:
                #print(k)
                col = "red"
                if getattr(self.joystick, k)(self.keys): col = "green"
                glMaterialfv(GL_FRONT, GL_DIFFUSE, colours[col])
                glutSolidCube(wdth - 0.02)
                glTranslate(wdth, 0, 0)
                glPushMatrix()
                #glLoadIdentity()
                glScale(0.005, 0.01, -0.01)
                glTranslate(-45, 0, -20)
                #glTranslate(-180,-70,0)
                glTranslate(-wdth, 0, 0)
                self.letters.drawString(k[2:4])
                glPopMatrix()

        glLoadIdentity()

        gluLookAt(0, 0, 2.5, 0, 0, 0, 0, 1, 0)

        glScale(0.01, 0.01, -0.01)
        glTranslate(-180, -70, 0)

        if debug == True:
            self.letters.drawString('X:' + str(self.level.solomon.x) + ' Y:' +
                                    str(self.level.solomon.y))
            glTranslate(0, 0 - 15, 0)
            gx, gy = int(self.level.solomon.x), int(self.level.solomon.y)
            self.letters.drawString('G {0} on: {1} below: {2}'.format(
                str((gx, gy)), self.level.grid[gy][gx],
                self.level.grid[gy - 1][gx]))
            glTranslate(0, 0 - 15, 0)
            self.letters.drawString('')

        glutSwapBuffers()
Example #30
0
 def display_rendered_content():
     """Swaps buffers once rendering is finished.
     """
     glutSwapBuffers()
Example #31
0
 def _draw(self):
     self.clear_color_buffer()
     self.clear_depth_buffer()
     self.draw()
     glutSwapBuffers()
Example #32
0
 def render_all_shapes(self):
     glClear(GL_COLOR_BUFFER_BIT)
     for _, s in self.grid_instance.active_grid_elements.iteritems():
         s.draw()
     glutSwapBuffers()
Example #33
0
def display():
    ctx.clear(0.9, 0.9, 0.9)
    vao.render()
    glutSwapBuffers()
Example #34
0
 def display_func(self):
     self.update()
     glutSwapBuffers()