当前位置: 首页>>代码示例>>Python>>正文


Python gl.glClear函数代码示例

本文整理汇总了Python中vispy.gloo.gl.glClear函数的典型用法代码示例。如果您正苦于以下问题:Python glClear函数的具体用法?Python glClear怎么用?Python glClear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了glClear函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw00

 def draw00(event):
     print("  {0:7}: {1}".format("0", bgcolors[0]))
     if bgcolors[0] is not None:
         gl.glViewport(0, 0, *list(_win_size))
         gl.glClearColor(*bgcolors[0])
         gl.glClear(gl.GL_COLOR_BUFFER_BIT)
         gl.glFinish()
开发者ID:Zulko,项目名称:vispy,代码行数:7,代码来源:test_simultaneous.py

示例2: on_paint

 def on_paint(self, event):
     
     # Clear
     gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
     
     # Draw shape with texture, nested context
     self._program.draw(gl.GL_TRIANGLE_STRIP)
开发者ID:ds604,项目名称:vispy,代码行数:7,代码来源:texturing.py

示例3: draw11

 def draw11(event):
     print('  {0:7}: {1}'.format('1', bgcolors[1]))
     if bgcolors[1] is not None:
         gl.glViewport(0, 0, *list(_win_size))
         gl.glClearColor(*bgcolors[1])
         gl.glClear(gl.GL_COLOR_BUFFER_BIT)
         gl.glFinish()
开发者ID:Calvarez20,项目名称:vispy,代码行数:7,代码来源:test_simultaneous.py

示例4: on_paint

 def on_paint(self, event):
     
     # Set framebuffer input output
     self._program['u_texture'] = self._tex1
     self._fbo.attach_color(self._tex2)
     
     with self._fbo:
         # Init
         gl.glViewport(0, 0, im1.shape[1], im1.shape[0])
         gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
         # Draw
         self._program.draw(gl.GL_TRIANGLE_STRIP)
     
     # Draw to the normal color buffer (i.e. the screen)
     self._program['u_texture'] = self._tex2
     # Init
     gl.glViewport(0, 0, self.size[0], self.size[1])
     gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
     # Draw
     self._program.draw(gl.GL_TRIANGLE_STRIP)
     
     # Prepare for next round
     self._tex1, self._tex2 = self._tex2, self._tex1
     
     # Force redraw
     self.update()
开发者ID:ds604,项目名称:vispy,代码行数:26,代码来源:game_of_life.py

示例5: paint0

 def paint0(event):
     print('  {0:7}: {1}'.format(backend + '_0', bgcolors[0]))
     if bgcolors[0] is not None:
         gl.glViewport(0, 0, *list(_win_size))
         gl.glClearColor(*bgcolors[0])
         gl.glClear(gl.GL_COLOR_BUFFER_BIT)
         gl.glFinish()
开发者ID:kif,项目名称:vispy,代码行数:7,代码来源:test_simultaneous.py

示例6: on_paint

    def on_paint(self, event):

        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        # Activate program  and texture
        gl.glUseProgram(self._prog_handle)
        gl.glBindTexture(gl.GL_TEXTURE_2D, self._tex_handle)

        # Set attributes (again, the loc can be cached)
        loc = gl.glGetAttribLocation(
            self._prog_handle,
            'a_position'.encode('utf-8'))
        gl.glEnableVertexAttribArray(loc)
        if use_buffers:
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self._positions_handle)
            gl.glVertexAttribPointer(loc, 3, gl.GL_FLOAT, False, 0, None)
        else:
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0)  # 0 means do not use buffer
            gl.glVertexAttribPointer(loc, 3, gl.GL_FLOAT, False, 0, positions)
        #
        loc = gl.glGetAttribLocation(
            self._prog_handle,
            'a_texcoord'.encode('utf-8'))
        gl.glEnableVertexAttribArray(loc)
        if use_buffers:
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self._texcoords_handle)
            gl.glVertexAttribPointer(loc, 2, gl.GL_FLOAT, False, 0, None)
        else:
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0)  # 0 means do not use buffer
            gl.glVertexAttribPointer(loc, 2, gl.GL_FLOAT, False, 0, texcoords)

        # Set uniforms (note that you could cache the locations)
        loc = gl.glGetUniformLocation(
            self._prog_handle,
            'u_view'.encode('utf-8'))
        gl.glUniformMatrix4fv(loc, 1, False, self.view)
        loc = gl.glGetUniformLocation(
            self._prog_handle,
            'u_model'.encode('utf-8'))
        gl.glUniformMatrix4fv(loc, 1, False, self.model)
        loc = gl.glGetUniformLocation(
            self._prog_handle,
            'u_projection'.encode('utf-8'))
        gl.glUniformMatrix4fv(loc, 1, False, self.projection)

        # Draw
        if use_buffers:
            gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, self._faces_handle)
            gl.glDrawElements(
                gl.GL_TRIANGLES,
                faces.size,
                gl.GL_UNSIGNED_INT,
                None)
        else:
            gl.glDrawElements(
                gl.GL_TRIANGLES,
                faces.size,
                gl.GL_UNSIGNED_INT,
                faces)
开发者ID:dengemann,项目名称:vispy,代码行数:59,代码来源:rawgl-cube.py

示例7: on_draw

 def on_draw(self, event):
     t = timeit.default_timer()
     self.times.append(t)
     if len(self.times) >= 2:
         print(1./(t-self.times[-2]))
     gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
     gl.glDrawArrays(gl.GL_POINTS, 0, len(self.data))
     self.update()
开发者ID:swq0553,项目名称:webgl-insights,代码行数:8,代码来源:test_gl.py

示例8: on_paint

 def on_paint(self, event):
     # Clear
     gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
     # Correct way to draw the terrain
     #self.program.draw(gl.GL_TRIANGLES)
     """Drawing as line strip is wrong as the VB represents triangles but
     it gives better visualization of the terrain with minor mistakes
     """
     self.program.draw(gl.GL_TRIANGLES)
开发者ID:mssurajkaiga,项目名称:vispy-experiments,代码行数:9,代码来源:terrain.py

示例9: on_paint

 def on_paint(self, event):
     gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
     # update angles
     data['a_omega'] += do
     data['a_theta'] += dt
     # prevent accumulation
     data['a_omega'] %= 2 * np.pi
     data['a_theta'] %= 2 * np.pi
     self.vbo.set_data(data)
     self.program.draw(gl.GL_POINTS)
开发者ID:dengemann,项目名称:vispy,代码行数:10,代码来源:donut.py

示例10: on_paint

    def on_paint(self, event):
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        # Draw
        self.program.draw(gl.GL_POINTS)

        # Next iteration
        self._t = self.iteration(time.time() - self._t)

        # Invoke a new draw
        self.update()
开发者ID:LiloD,项目名称:vispy,代码行数:11,代码来源:boids.py

示例11: on_paint

def on_paint(event):
    global t, t0, frames
    gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        
    t = time.time()
    frames = frames + 1
    elapsed = (t-t0) # seconds
    if elapsed > 2.5:
        print( "FPS : %.2f (%d frames in %.2f second)"
               % (frames/elapsed, frames, elapsed))
        t0, frames = t,0
    canvas.update()
开发者ID:ds604,项目名称:vispy,代码行数:12,代码来源:simple-vispy.py

示例12: on_paint

    def on_paint(self, event):
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        # Draw
        self.program["position"] = VertexBuffer(particles["position"], client=True)
        self.program.draw(gl.GL_POINTS)

        # Next iteration
        self._t = self.iteration(time.time() - self._t)

        # Invoke a new draw
        self.update()
开发者ID:kif,项目名称:vispy,代码行数:12,代码来源:client-buffers.py

示例13: on_paint

    def on_paint(self, event):
        global T,dT,p,n
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        T += dT
        self.index = (self.index+1)%p
        data['a_position'][self.index::p,0] = np.cos(T)
        data['a_position'][self.index::p,1] = .5*np.sin(T)
        data['a_color'][:,3] -= 1.0/p
        data['a_color'][self.index::p,3] = 1
        self.vbo.set_data(data)
        self.program.draw(gl.GL_POINTS)
开发者ID:ds604,项目名称:vispy,代码行数:12,代码来源:atom.py

示例14: _test_setting_stuff

def _test_setting_stuff():
    # Set stuff to touch functions
    
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)
    #
    gl.glBlendColor(1.0, 1.0, 1.0, 1.0)
    gl.glBlendEquation(gl.GL_FUNC_ADD)
    gl.glBlendEquationSeparate(gl.GL_FUNC_ADD, gl.GL_FUNC_ADD)
    gl.glBlendFunc(gl.GL_ONE, gl.GL_ZERO)
    gl.glBlendFuncSeparate(gl.GL_ONE, gl.GL_ZERO, gl.GL_ONE, gl.GL_ZERO)
    #
    gl.glClearColor(0.0, 0.0, 0.0, 1.0)
    gl.glClearDepth(1)
    gl.glClearStencil(0)
    #
    gl.glColorMask(True, True, True, True)
    gl.glDepthMask(False)
    gl.glStencilMask(255)
    gl.glStencilMaskSeparate(gl.GL_FRONT, 128)
    #
    gl.glStencilFunc(gl.GL_ALWAYS, 0, 255)
    gl.glStencilFuncSeparate(gl.GL_FRONT, gl.GL_ALWAYS, 0, 255)
    gl.glStencilOp(gl.GL_KEEP, gl.GL_KEEP, gl.GL_KEEP)
    gl.glStencilOpSeparate(gl.GL_FRONT, gl.GL_KEEP, gl.GL_KEEP, gl.GL_KEEP)
    #
    gl.glFrontFace(gl.GL_CW)
    gl.glHint(gl.GL_GENERATE_MIPMAP_HINT, gl.GL_FASTEST)
    gl.glLineWidth(2.0)
    gl.glPolygonOffset(0.0, 0.0)
    gl.glSampleCoverage(1.0, False)
    
    # And getting stuff
    try:
        with use_log_level('error', print_msg=False):
            r, p = gl.glGetShaderPrecisionFormat(gl.GL_FRAGMENT_SHADER,
                                                 gl.GL_HIGH_FLOAT)
            gl.check_error()  # Sometimes the func is there but OpenGL errs
    except Exception:
        pass  # accept if the function is not there ...
        # We should catch RuntimeError and GL.error.NullFunctionError,
        # but PyOpenGL may not be available.
        # On Travis this function was not there on one machine according
        # to PyOpenGL, but our desktop backend worked fine ...
        
    #
    v = gl.glGetParameter(gl.GL_VERSION)
    assert_true(isinstance(v, string_types))
    assert_true(len(v) > 0)
    
    gl.check_error()
开发者ID:almarklein,项目名称:vispy,代码行数:50,代码来源:test_basics.py

示例15: on_paint

 def on_paint(self, event):
     
     # Clear
     gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
     
     # Draw
     self._program['sizeFactor'] = 0.5 + np.sin(time.time()*3)*0.2
     
     # Draw (pick one!)
     #self._program.draw(gl.GL_TRIANGLE_STRIP)
     self._program.draw(gl.GL_TRIANGLES, indices_buffer)
     #self._program.draw(gl.GL_TRIANGLES, client_indices_buffer)  # Not recommended
     
     self.update()
开发者ID:ds604,项目名称:vispy,代码行数:14,代码来源:animate-shape.py


注:本文中的vispy.gloo.gl.glClear函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。