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


Python gl.glUseProgram函数代码示例

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


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

示例1: render_to_texture

def render_to_texture():
    # select the target to draw into
    gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, framebuffer)
    draw_buffers = (gl.GLenum * 1)(gl.GL_COLOR_ATTACHMENT0)
    gl.glDrawBuffers(1, draw_buffers)
    gl.glViewport(0, 0, FB_WIDTH, FB_HEIGHT)

    # clear the destination
    gl.glClearColor(0.5, 0.6, 0.7, 1.0)
    gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

    # prepare the rendering
    gl.glUseProgram(render_program)

    # send the vertex data
    data = (COLOR_VERTEX * 3)(((-0.6, -0.5), (1.0, 0.0, 0.0, 1.0)),
                      ((0.6, -0.5), (0.0, 1.0, 0.0, 1.0)),
                      ((0.0, 0.5), (0.0, 0.0, 1.0, 1.0)))

    gl.glBindBuffer(gl.GL_ARRAY_BUFFER, render_vertexbuffer)
    gl.glBufferData(gl.GL_ARRAY_BUFFER, ctypes.sizeof(data), data, gl.GL_DYNAMIC_DRAW)

    # draw using the vertex array for vertex information
    gl.glBindVertexArray(render_vao)
    gl.glDrawArrays(gl.GL_TRIANGLES, 0, 3)
    gl.glBindVertexArray(0)
开发者ID:carloscabo,项目名称:geometric-bot,代码行数:26,代码来源:test_pyglet_gl.py

示例2: copy_texture_to_screen

def copy_texture_to_screen():
    # select the target to draw into
    gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0)
    gl.glViewport(0, 0, window.width, window.height)

    # clear the destination
    gl.glClearColor(0.4, 0.4, 0.4, 1.0)
    gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

    # select the program for drawing
    gl.glUseProgram(copy_program)

    # send the vertex data
    data = (TEXTURE_VERTEX * 8)(((-0.9, -0.9), (0.0, 0.0)),
                                ((0.5, -0.9), (1.0, 0.0)),
                                ((0.5, 0.5), (1.0, 1.0)),
                                ((-0.9, 0.5), (0.0, 1.0)),

                                ((0.6, 0.6), (0.0, 1.0)),
                                ((1.0, 0.6), (1.0, 1.0)),
                                ((1.0, 1.0), (1.0, 0.0)),
                                ((0.6, 1.0), (0.0, 0.0)),
                                )

    gl.glBindBuffer(gl.GL_ARRAY_BUFFER, copy_vertexbuffer)
    gl.glBufferData(gl.GL_ARRAY_BUFFER, ctypes.sizeof(data), data, gl.GL_DYNAMIC_DRAW)


    # draw
    gl.glBindVertexArray(copy_vao)
    gl.glDrawArrays(gl.GL_QUADS, 0, 8)
    gl.glBindVertexArray(0)
开发者ID:carloscabo,项目名称:geometric-bot,代码行数:32,代码来源:test_pyglet_gl.py

示例3: unuse

    def unuse(self):
        """P.unuse()

        Disable the program for rendering.
        """

        gl.glUseProgram(0)
开发者ID:szabba,项目名称:silica-display,代码行数:7,代码来源:shaders.py

示例4: use

    def use(self):
        """P.use()

        Enables the program for rendering.
        """

        gl.glUseProgram(self.__program)
开发者ID:szabba,项目名称:silica-display,代码行数:7,代码来源:shaders.py

示例5: use

    def use(self):
        """Bind the program into the rendering pipeline.

        """
        if not self.linked:
            self._link()

        # bind the program
        gl.glUseProgram(self.handle)
        self.bound = True
开发者ID:certik,项目名称:scikits.gpu,代码行数:10,代码来源:shader.py

示例6: use

    def use(self):
        self.id = gl.glCreateProgram()
        
        for shader in self.shaders:
            shader.compile()
            gl.glAttachShader(self.id, shader.id)

        gl.glLinkProgram(self.id)

        message = self._getMessage()
        if not self.getLinkStatus():
            raise LinkError(message)

        gl.glUseProgram(self.id)
        return message
开发者ID:tartley,项目名称:pyglet-shaders,代码行数:15,代码来源:shader.py

示例7: __draw

  def __draw(self):
    gl.glClearColor(self.__bg_color[0],
        self.__bg_color[1],
        self.__bg_color[2],
        self.__bg_color[3])
    gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
    gl.glUseProgram(self.__prog.value)

    # update data buffer if necessary
    with self.__data_lock:
      if self.__data_altered:
        self.__setup_data_buffer()

    self.__set_uniforms()
    self.__set_attributes()

    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE)
    gl.glEnable(gl.GL_BLEND)
    gl.glEnable(gl.GL_CULL_FACE)
    gl.glDrawArraysInstanced(gl.GL_TRIANGLES,
        0, 36, self.__data.size / (self.__downsample**3))
开发者ID:greyhill,项目名称:volvis,代码行数:21,代码来源:vis.py

示例8: _prepareFBOrender

 def _prepareFBOrender(self):
     if self.mode=='mono++':
         GL.glUseProgram(self._shaders['mono++'])
     elif self.mode=='color++':
         GL.glUseProgram(self._shaders['color++'])
     else:
         GL.glUseProgram(self.win._progFBOtoFrame)
开发者ID:alexholcombe,项目名称:psychopy,代码行数:7,代码来源:bits.py

示例9: _finishFBOrender

 def _finishFBOrender(self):
     if self.mode[:4] in ['mono','colo']:
         GL.glUseProgram(0)
     elif self.mode[:4]=='bits':
         self._drawLUTtoScreen()
开发者ID:Lx37,项目名称:psychopy,代码行数:5,代码来源:bits.py

示例10: unbind

 def unbind(self):
     # unbind whatever program is currently bound - not necessarily this program,
     # so this should probably be a class method instead
     GL.glUseProgram(0)
开发者ID:eulerlab,项目名称:QDSpy,代码行数:4,代码来源:shader_opengl.py

示例11: _prepareFBOrender

 def _prepareFBOrender(self):
     if self.mode=='mono++':
         GL.glUseProgram(self._shaders['mono++'])
     if self.mode=='color++':
         GL.glUseProgram(self._shaders['color++'])
开发者ID:Lx37,项目名称:psychopy,代码行数:5,代码来源:bits.py

示例12: disable

    def disable(self):
        """Unbind all programs in use.

        """
        gl.glUseProgram(0)
        self.bound = False
开发者ID:certik,项目名称:scikits.gpu,代码行数:6,代码来源:shader.py

示例13: bind

 def bind(self):
     # bind the program
     GL.glUseProgram(self.handle)
开发者ID:eulerlab,项目名称:QDSpy,代码行数:3,代码来源:shader_opengl.py

示例14: unbind

 def unbind(self):
     gl.glUseProgram(0)
开发者ID:biddy,项目名称:pywonderland,代码行数:2,代码来源:shader.py

示例15: end

 def end(self):
     gl.glUseProgram(0)
开发者ID:Victor01exe,项目名称:cocos,代码行数:2,代码来源:draw.py


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