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

Python gl.glEnable函数代码示例

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

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



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

示例1: on_initialize

 def on_initialize(self, event):
     gl.glClearColor(0,0,0,1)
     gl.glDisable(gl.GL_DEPTH_TEST)
     gl.glEnable(gl.GL_BLEND)
     gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE) #_MINUS_SRC_ALPHA)
     # Start the timer upon initialization.
     self.timer.start()
开发者ID:PennyQ,项目名称:nbhdf5,代码行数:7,代码来源:nb6_h5_viewer.py


示例2: on_initialize

    def on_initialize(self, event):
        gl.glClearColor(1,1,1,1)
        gl.glEnable(gl.GL_DEPTH_TEST)
        
        # Create shader program
        self._prog_handle = gl.glCreateProgram()

        # Create vertex shader
        shader = gl.glCreateShader(gl.GL_VERTEX_SHADER)
        gl.glShaderSource(shader, VERT_CODE)
        gl.glCompileShader(shader)
        status = gl.glGetShaderiv(shader, gl.GL_COMPILE_STATUS)
        if not status:
            # We could show more useful info here, but that takes a few lines
            raise RuntimeError('Vertex shader did not compile.')
        else:
            gl.glAttachShader(self._prog_handle, shader)
        
        # Create fragment shader
        shader = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)
        gl.glShaderSource(shader, FRAG_CODE)
        gl.glCompileShader(shader)
        status = gl.glGetShaderiv(shader, gl.GL_COMPILE_STATUS)
        if not status:
            # We could show more useful info here, but that takes a few lines
            raise RuntimeError('Fragment shader did not compile.')
        else:
            gl.glAttachShader(self._prog_handle, shader)
        
        # Link
        gl.glLinkProgram(self._prog_handle)
        status = gl.glGetProgramiv(self._prog_handle, gl.GL_LINK_STATUS)
        if not status:
            # We could show more useful info here, but that takes a few lines
            raise RuntimeError('Program did not link.')
        
        # Create texture
        im = dataio.crate()
        self._tex_handle = gl.glGenTextures(1)
        gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, 1)
        gl.glBindTexture(gl.GL_TEXTURE_2D, self._tex_handle)
        gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, 
            im.shape[1], im.shape[0], 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, im)
        gl.glTexParameter(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
        gl.glTexParameter(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
        
        if use_buffers:
            # Create vertex buffer
            self._positions_handle = gl.glGenBuffers(1)
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self._positions_handle)
            gl.glBufferData(gl.GL_ARRAY_BUFFER, positions.nbytes, positions, gl.GL_DYNAMIC_DRAW)
            #
            self._texcoords_handle = gl.glGenBuffers(1)
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self._texcoords_handle)
            gl.glBufferData(gl.GL_ARRAY_BUFFER, texcoords.nbytes, texcoords, gl.GL_DYNAMIC_DRAW)
            
            # Create buffer for faces
            self._faces_handle = gl.glGenBuffers(1)
            gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, self._faces_handle)
            gl.glBufferData(gl.GL_ELEMENT_ARRAY_BUFFER, faces.nbytes, faces, gl.GL_DYNAMIC_DRAW)
开发者ID:ds604,项目名称:vispy,代码行数:60,代码来源:rawgl-cube.py


示例3: on_initialize

    def on_initialize(self, event):
        self.program = gl.glCreateProgram()
        vertex = gl.glCreateShader(gl.GL_VERTEX_SHADER)
        fragment = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)
        gl.glShaderSource(vertex, vertex_code)
        gl.glShaderSource(fragment, fragment_code)
        gl.glCompileShader(vertex)
        gl.glCompileShader(fragment)
        gl.glAttachShader(self.program, vertex)
        gl.glAttachShader(self.program, fragment)
        gl.glLinkProgram(self.program)
        gl.glDetachShader(self.program, vertex)
        gl.glDetachShader(self.program, fragment)
        gl.glUseProgram(self.program)

        n = 10000000
        self.data = np.zeros((n, 4), dtype=np.float32)
        self.data[:, :2] = .15 * prng.randn(n, 2)
        self.data[:, 3] = 1.
        vbuffer = gl.glCreateBuffer()
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, vbuffer)
        gl.glBufferData(gl.GL_ARRAY_BUFFER, self.data, gl.GL_DYNAMIC_DRAW)

        stride = self.data.strides[0]
        offset = 0
        loc = gl.glGetAttribLocation(self.program, "a_position")
        gl.glEnableVertexAttribArray(loc)
        gl.glVertexAttribPointer(loc, 4, gl.GL_FLOAT, False, stride, offset)

        gl.glClearColor(0, 0, 0, 1)
        gl.glEnable(34370)
        gl.glEnable(34913)

        # Auto-close after 10 seconds
        self.timer = app.Timer(10, self.on_timer, start=True)
开发者ID:swq0553,项目名称:webgl-insights,代码行数:35,代码来源:test_gl.py


示例4: __init__

    def __init__(self):
        app.Canvas.__init__(self, size=(1024, 1024), title='Skybox example',
                            keys='interactive')

        self.cubeSize = 10
        self.pressed = False
        self.azimuth = pi / 2.0
        self.elevation = pi / 2.0
        self.distanceMin = 1
        self.distanceMax = 50
        self.distance = 30
        self.sensitivity = 5.0
        self.view = getView(self.azimuth, self.elevation, self.distance)
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)

        self.program = gloo.Program(vertex_shader, fragment_shader, count=24)
        self.program['a_position'] = faces*self.cubeSize
        self.program['a_texcoord'] = faces
        self.program['a_texture'] = gloo.TextureCube(texture, interpolation='linear')
        self.program['u_model'] = self.model
        self.program['u_view'] = self.view
        gloo.set_viewport(0, 0, *self.physical_size)
        self.projection = perspective(60.0, self.size[0] /
                                      float(self.size[1]), 1.0, 100.0)
        self.program['u_projection'] = self.projection

        gl.glEnable(gl.GL_DEPTH_TEST)
        gloo.set_clear_color('black')
        self.show()
开发者ID:vispy,项目名称:vispy,代码行数:30,代码来源:skybox.py


示例5: _draw_context

 def _draw_context(self):
     if self._rect_clip is None:
         yield
     else:
         gl.glEnable(gl.GL_SCISSOR_TEST);
         gloo.set_scissor(*self._rect_clip)
         yield
         gl.glDisable(gl.GL_SCISSOR_TEST);
开发者ID:tonysyu,项目名称:deli,代码行数:8,代码来源:element.py


示例6: on_initialize

    def on_initialize(self, event):
        gl.glClearColor(0,0,0,1);
        
        # Enable blending
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE)
        
        # Create shader program
        self._prog_handle = gl.glCreateProgram()

        # Create vertex shader
        shader = gl.glCreateShader(gl.GL_VERTEX_SHADER)
        gl.glShaderSource_compat(shader, VERT_CODE)
        gl.glCompileShader(shader)
        status = gl.glGetShaderiv(shader, gl.GL_COMPILE_STATUS)
        if not status:
            # We could show more useful info here, but that takes a few lines
            raise RuntimeError('Vertex shader did not compile.')
        else:
            gl.glAttachShader(self._prog_handle, shader)
        
        # Create fragment shader
        shader = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)
        need_enabled = gl.glShaderSource_compat(shader, FRAG_CODE)
        gl.glCompileShader(shader)
        status = gl.glGetShaderiv(shader, gl.GL_COMPILE_STATUS)
        if not status:
            # We could show more useful info here, but that takes a few lines
            raise RuntimeError('Fragment shader did not compile.')
        else:
            gl.glAttachShader(self._prog_handle, shader)
        
        # Enable point sprites
        for enum in need_enabled:
            gl.glEnable(enum)
        
        # Link
        gl.glLinkProgram(self._prog_handle)
        status = gl.glGetProgramiv(self._prog_handle, gl.GL_LINK_STATUS)
        if not status:
            # We could show more useful info here, but that takes a few lines
            raise RuntimeError('Program did not link.')
        
        # Create texture
        self._tex_handle = gl.glGenTextures(1)
        gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, 1)
        gl.glBindTexture(gl.GL_TEXTURE_2D, self._tex_handle)
        gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_LUMINANCE, 
            im1.shape[1], im1.shape[0], 0, gl.GL_LUMINANCE, gl.GL_FLOAT,
             im1.astype(np.float32))
        gl.glTexParameter(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
        gl.glTexParameter(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
        
        # Create vertex buffer
        self._vbo_handle = gl.glGenBuffers(1)
开发者ID:ds604,项目名称:vispy,代码行数:55,代码来源:rawgl-fireworks.py


示例7: on_initialize

 def on_initialize(self, event):
     gl.glClearColor(1,1,1,1)
     gl.glEnable(gl.GL_BLEND)
     gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
     
     n = 10000
     self.discs = DiscCollection()
     self.discs.line_width = 2.
     self.discs.position = 0.25 * np.random.randn(n, 2).astype(np.float32)
     self.discs.color = np.random.uniform(0,1,(n,3)).astype(np.float32)
     self.discs.size = np.random.uniform(2,12,(n,1)).astype(np.float32)
开发者ID:ds604,项目名称:vispy,代码行数:11,代码来源:visual_experiments.py


示例8: on_initialize

 def on_initialize(self, event):
     gl.glClearColor(1, 1, 1, 1)
     gl.glEnable(gl.GL_DEPTH_TEST)
     gl.glEnable(gl.GL_BLEND)
     gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
     gl.glEnable(GL_VERTEX_PROGRAM_POINT_SIZE)
     gl.glEnable(GL_POINT_SPRITE)
开发者ID:LiloD,项目名称:vispy,代码行数:7,代码来源:donut.py


示例9: _test_enabling_disabling

def _test_enabling_disabling():
    # Enabling/disabling
    gl.glEnable(gl.GL_DEPTH_TEST)
    assert_equal(gl.glIsEnabled(gl.GL_DEPTH_TEST), True)
    assert_equal(gl.glGetParameter(gl.GL_DEPTH_TEST), 1)
    gl.glDisable(gl.GL_DEPTH_TEST)
    assert_equal(gl.glIsEnabled(gl.GL_DEPTH_TEST), False)
    assert_equal(gl.glGetParameter(gl.GL_DEPTH_TEST), 0)
    #
    gl.glEnable(gl.GL_BLEND)
    assert_equal(gl.glIsEnabled(gl.GL_BLEND), True)
    assert_equal(gl.glGetParameter(gl.GL_BLEND), 1)
    gl.glDisable(gl.GL_BLEND)
    assert_equal(gl.glIsEnabled(gl.GL_BLEND), False)
    assert_equal(gl.glGetParameter(gl.GL_BLEND), 0)
    
    gl.check_error()
开发者ID:LiloD,项目名称:vispy,代码行数:17,代码来源:test_basics.py


示例10: on_initialize

    def on_initialize(self, event):
        gl.glClearColor(0, 0, 0, 1)

        # Enable blending
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE)
        gl.glEnable(GL_VERTEX_PROGRAM_POINT_SIZE)
        gl.glEnable(GL_POINT_SPRITE)
开发者ID:LiloD,项目名称:vispy,代码行数:8,代码来源:fireworks.py


示例11: on_initialize

    def on_initialize(self, event):
        # Build & activate program
        self.program = gl.glCreateProgram()
        vertex = gl.glCreateShader(gl.GL_VERTEX_SHADER)
        fragment = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)
        gl.glShaderSource(vertex, vertex_code)
        gl.glShaderSource(fragment, fragment_code)
        gl.glCompileShader(vertex)
        gl.glCompileShader(fragment)
        gl.glAttachShader(self.program, vertex)
        gl.glAttachShader(self.program, fragment)
        gl.glLinkProgram(self.program)
        gl.glDetachShader(self.program, vertex)
        gl.glDetachShader(self.program, fragment)
        gl.glUseProgram(self.program)

        # Build vertex buffer
        n = 10000
        self.data = np.zeros(n, dtype=[('lifetime', np.float32, 1),
                                       ('start',    np.float32, 3),
                                       ('end',      np.float32, 3)])
        vbuffer = gl.glCreateBuffer()
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, vbuffer)
        gl.glBufferData(gl.GL_ARRAY_BUFFER, self.data, gl.GL_DYNAMIC_DRAW)

        # Bind buffer attributes
        stride = self.data.strides[0]

        offset = 0
        loc = gl.glGetAttribLocation(self.program, "lifetime")
        gl.glEnableVertexAttribArray(loc)
        gl.glVertexAttribPointer(loc, 1, gl.GL_FLOAT, False, stride, offset)

        offset = self.data.dtype["lifetime"].itemsize
        loc = gl.glGetAttribLocation(self.program, "start")
        gl.glEnableVertexAttribArray(loc)
        gl.glVertexAttribPointer(loc, 3, gl.GL_FLOAT, False, stride, offset)

        offset = self.data.dtype["start"].itemsize
        loc = gl.glGetAttribLocation(self.program, "end")
        gl.glEnableVertexAttribArray(loc)
        gl.glVertexAttribPointer(loc, 3, gl.GL_FLOAT, False, stride, offset)

        # OpenGL initalization
        self.elapsed_time = 0
        gl.glClearColor(0, 0, 0, 1)
        gl.glDisable(gl.GL_DEPTH_TEST)
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE)
        gl.glEnable(34370)  # gl.GL_VERTEX_PROGRAM_POINT_SIZE
        gl.glEnable(34913)  # gl.GL_POINT_SPRITE
        gl.glViewport(0, 0, *self.physical_size)
        self.new_explosion()
        self.timer = app.Timer('auto', self.on_timer, start=True)
开发者ID:Lx37,项目名称:vispy,代码行数:54,代码来源:fireworks.py


示例12: 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


示例13: on_initialize

 def on_initialize(self, event):
     gl.glClearColor(0,0,0,1)
     gl.glDisable(gl.GL_DEPTH_TEST)
     gl.glEnable(gl.GL_BLEND)
     gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
开发者ID:ds604,项目名称:vispy,代码行数:5,代码来源:atom.py


示例14: on_initialize

    def on_initialize(self, event):
        gl.glClearColor(0, 0, 0, 1)

        # Enable blending
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE)
开发者ID:dengemann,项目名称:vispy,代码行数:6,代码来源:fireworks.py


示例15: on_initialize

 def on_initialize(self, event):
     gl.glClearColor(1, 1, 1, 1)
     gl.glEnable(gl.GL_DEPTH_TEST)
开发者ID:LiloD,项目名称:vispy,代码行数:3,代码来源:glsl-sandbox-cube.py


示例16: on_initialize

    def on_initialize(self, event):
        # Build & activate cube program
        self.cube = gl.glCreateProgram()
        vertex = gl.glCreateShader(gl.GL_VERTEX_SHADER)
        fragment = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)
        gl.glShaderSource(vertex, cube_vertex)
        gl.glShaderSource(fragment, cube_fragment)
        gl.glCompileShader(vertex)
        gl.glCompileShader(fragment)
        gl.glAttachShader(self.cube, vertex)
        gl.glAttachShader(self.cube, fragment)
        gl.glLinkProgram(self.cube)
        gl.glDetachShader(self.cube, vertex)
        gl.glDetachShader(self.cube, fragment)
        gl.glUseProgram(self.cube)

        # Get data & build cube buffers
        vcube_data, self.icube_data = makecube()
        vcube = gl.glCreateBuffer()
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, vcube)
        gl.glBufferData(gl.GL_ARRAY_BUFFER, vcube_data, gl.GL_STATIC_DRAW)
        icube = gl.glCreateBuffer()
        gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, icube)
        gl.glBufferData(gl.GL_ELEMENT_ARRAY_BUFFER,
                        self.icube_data, gl.GL_STATIC_DRAW)

        # Bind cube attributes
        stride = vcube_data.strides[0]
        offset = 0
        loc = gl.glGetAttribLocation(self.cube, "a_position")
        gl.glEnableVertexAttribArray(loc)
        gl.glVertexAttribPointer(loc, 3, gl.GL_FLOAT, False, stride, offset)

        offset = vcube_data.dtype["a_position"].itemsize
        loc = gl.glGetAttribLocation(self.cube, "a_texcoord")
        gl.glEnableVertexAttribArray(loc)
        gl.glVertexAttribPointer(loc, 2, gl.GL_FLOAT, False, stride, offset)

        # Create & bind cube texture
        crate = checkerboard()
        texture = gl.glCreateTexture()
        gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER,
                           gl.GL_LINEAR)
        gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER,
                           gl.GL_LINEAR)
        gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S,
                           gl.GL_CLAMP_TO_EDGE)
        gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T,
                           gl.GL_CLAMP_TO_EDGE)
        gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_LUMINANCE, gl.GL_LUMINANCE,
                        gl.GL_UNSIGNED_BYTE, crate.shape[:2])
        gl.glTexSubImage2D(gl.GL_TEXTURE_2D, 0, 0, 0, gl.GL_LUMINANCE,
                           gl.GL_UNSIGNED_BYTE, crate)
        loc = gl.glGetUniformLocation(self.cube, "u_texture")
        gl.glUniform1i(loc, texture)
        gl.glBindTexture(gl.GL_TEXTURE_2D, 0)

        # Create & bind cube matrices
        view = np.eye(4, dtype=np.float32)
        model = np.eye(4, dtype=np.float32)
        projection = np.eye(4, dtype=np.float32)
        translate(view, 0, 0, -7)
        self.phi, self.theta = 60, 20
        rotate(model, self.theta, 0, 0, 1)
        rotate(model, self.phi, 0, 1, 0)
        loc = gl.glGetUniformLocation(self.cube, "u_model")
        gl.glUniformMatrix4fv(loc, 1, False, model)
        loc = gl.glGetUniformLocation(self.cube, "u_view")
        gl.glUniformMatrix4fv(loc, 1, False, view)
        loc = gl.glGetUniformLocation(self.cube, "u_projection")
        gl.glUniformMatrix4fv(loc, 1, False, projection)

        # OpenGL initalization
        gl.glClearColor(0.30, 0.30, 0.35, 1.00)
        gl.glEnable(gl.GL_DEPTH_TEST)

        self.timer.start()
开发者ID:Peque,项目名称:vispy,代码行数:77,代码来源:cube.py


示例17: on_initialize

 def on_initialize(self, event):
     gl.glClearColor(1,1,1,1)
     
     gl.glEnable(gl.GL_BLEND)
     gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
开发者ID:ds604,项目名称:vispy,代码行数:5,代码来源:display-points.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python gl.glFinish函数代码示例发布时间:2022-05-26
下一篇:
Python gl.glClearColor函数代码示例发布时间: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