• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python gl.glClear函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: on_paint

 def on_paint(self, event):
     
     # Technically, we would only need to set u_time on every draw,
     # because the program is enabled at the beginning and never disabled.
     # In vispy, the program is re-enabled at each draw though and we
     # want to keep the code similar.
     
     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)
     
     # Update VBO
     gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self._vbo_handle)
     gl.glBufferData(gl.GL_ARRAY_BUFFER, vertex_data.nbytes, vertex_data, gl.GL_DYNAMIC_DRAW)
     
     # Set attributes (again, the loc can be cached)
     loc = gl.glGetAttribLocation(self._prog_handle, 'a_lifetime'.encode('utf-8'))
     gl.glEnableVertexAttribArray(loc)
     gl.glVertexAttribPointer(loc, 1, gl.GL_FLOAT, False, 7*4, ctypes.c_voidp(0))
     #
     loc = gl.glGetAttribLocation(self._prog_handle, 'a_startPosition'.encode('utf-8'))
     gl.glEnableVertexAttribArray(loc)
     gl.glVertexAttribPointer(loc, 3, gl.GL_FLOAT, False, 7*4, ctypes.c_voidp(1*4))
     #
     loc = gl.glGetAttribLocation(self._prog_handle, 'a_endPosition'.encode('utf-8'))
     gl.glEnableVertexAttribArray(loc)
     gl.glVertexAttribPointer(loc, 3, gl.GL_FLOAT, False, 7*4, ctypes.c_voidp(4*4))
     #
     loc = gl.glGetUniformLocation(self._prog_handle, 'u_color'.encode('utf-8'))
     gl.glUniform4f(loc, *self._color)
     
     # Set unforms
     loc = gl.glGetUniformLocation(self._prog_handle, 'u_time'.encode('utf-8'))
     gl.glUniform1f(loc, time.time()-self._starttime)
     #
     loc = gl.glGetUniformLocation(self._prog_handle, 'u_centerPosition'.encode('utf-8'))
     gl.glUniform3f(loc, *self._centerpos)
     
     # Draw
     gl.glDrawArrays(gl.GL_POINTS, 0, N)
     
     # New explosion?
     if time.time() - self._starttime > 1.5:
         self._new_explosion()
         
     # Redraw as fast as we can
     self.update()
开发者ID:ds604,项目名称:vispy,代码行数:49,代码来源:rawgl-fireworks.py


示例17: on_paint

    def on_paint(self, event):

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

        # Draw
        self._program['u_time'] = time.time() - self._starttime
        self._program.draw(gl.GL_POINTS)

        # Invoke a new draw
        self.update()

        # New explosion?
        if time.time() - self._starttime > 1.5:
            self._new_explosion()
开发者ID:LiloD,项目名称:vispy,代码行数:15,代码来源:fireworks.py


示例18: on_paint

    def on_paint(self, event):
        # Paint events are "manually" propagated to the viewport instances,
        # because we first want to set the glViewport for each one.

        # Prepare
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        w1 = self.size[0] // 2
        w2 = self.size[0] - w1
        # Left
        gl.glViewport(0, 0, w1, self.size[1])
        self.left.on_paint()
        # Right
        gl.glViewport(w1, 0, w2, self.size[1])
        self.right.on_paint()

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


示例19: on_paint

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

        with self.program as prog:
            # Filled cube
            gl.glDisable(gl.GL_BLEND)
            gl.glEnable(gl.GL_DEPTH_TEST)
            gl.glEnable(gl.GL_POLYGON_OFFSET_FILL)
            prog['u_color'] = 1, 1, 1, 1
            prog.draw(gl.GL_TRIANGLES, self.filled_buf)

            # Outline
            gl.glDisable(gl.GL_POLYGON_OFFSET_FILL)
            gl.glEnable(gl.GL_BLEND)
            gl.glDepthMask(gl.GL_FALSE)
            prog['u_color'] = 0, 0, 0, 1
            prog.draw(gl.GL_LINES, self.outline_buf)
            gl.glDepthMask(gl.GL_TRUE)
开发者ID:LiloD,项目名称:vispy,代码行数:18,代码来源:rotate-cube.py


示例20: on_draw

    def on_draw(self, event):

        # Set geometry (is no-op if the size does not change)
        self._fbo.set_size(*self.size)

        # Draw the same scene as as in hello_quad.py, but draw it to the FBO
        with self._fbo:
            # Init
            gl.glClearColor(0, 0.0, 0.5, 1)
            gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
            # Draw
            self._program1.draw(gl.GL_TRIANGLE_STRIP)

        # Now draw result to a full-screen quad
        # Init
        gl.glClearColor(1, 1, 1, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        # Draw
        self._program2.draw(gl.GL_TRIANGLE_STRIP)
开发者ID:MatthieuDartiailh,项目名称:vispy,代码行数:19,代码来源:hello-fbo.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gl.glClearColor函数代码示例发布时间:2022-05-26
下一篇:
Python gloo.Program类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap