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

Python gl.glUseProgram函数代码示例

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

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



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


示例16: stop

 def stop(self):
     gl.glUseProgram(0)
开发者ID:gunny26,项目名称:pygame,代码行数:2,代码来源:pyglet_mandelbrot.py


示例17: bind

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


示例18: bind

 def bind(self):
     ''' Bind the program, i.e. use it. '''
     gl.glUseProgram(self.handle)
开发者ID:matthew-brett,项目名称:miniglumpy,代码行数:3,代码来源:shader.py


示例19: use

 def use(self):
     gl.glUseProgram(self.program)
开发者ID:gunny26,项目名称:pygame,代码行数:2,代码来源:pyglet_mandelbrot.py


示例20: main


#.........这里部分代码省略.........
            grounded_mask = numpy.zeros((len(instances),), dtype=bool)
            stop = numpy.empty((len(instances),2), dtype=bool)
            adjust, sides = rwc(motion_v, passive_tl, passive_br, walls_tlbr[0], walls_tlbr[1])
            numpy.logical_or.reduce(sides.reshape(-1, 2, 2), out=stop, axis=2)
            motion_v[stop] = 0
            do_translate(motion_v[:])
            while attempts < 20 and adjust_significant:
                adjust, sides, done_impulse = rppc(motion_v, passive_tl, passive_br)
                grounded_mask |= sides[:,3]
                adjust *= 0.5
                do_translate(adjust)
                adjust_significant = not numpy.allclose(adjust, 0, atol=0.125)
                adjust_significant |= done_impulse > 0.125
                del adjust, sides
                adjust, sides = rwc(motion_v, passive_tl, passive_br, walls_tlbr[0], walls_tlbr[1])
                adjust_significant |= not numpy.allclose(adjust, 0, atol=0.5)
                do_translate(adjust)
                numpy.logical_or.reduce(sides.reshape(-1, 2, 2), out=stop, axis=2)
                motion_v[stop] = 0
                grounded_mask |= sides[:,3]

                attempts += 1

            for thing in numpy.compress(grounded_mask, instances):
                thing.tags.add(GROUNDED)

            do_frame = False
            ticks_done += 1

        dead = []

        gl.glLoadIdentity()
        gl.glEnableVertexAttribArray(0)
        gl.glUseProgram(spriteprog.id)
        gl.glBindTexture(gl.GL_TEXTURE_2D, background.texid)
        spriteprog['texture'] = 0

        with backgroundbuf.bound:
            gl.glVertexAttribPointer(0, 4, gl.GL_FLOAT, gl.GL_FALSE, 0, 0)
            gl.glDrawArrays(gl.GL_TRIANGLE_FAN, 0, 4)

        # Now move camera
        camera_location = (screen_center - numpy.round(entities[0].location)) + (0, camera_offset)
        gl.glTranslated(camera_location[0], camera_location[1], 0.0)

        for thing in entities:
            if thing.hitpoints <= 0 or thing.location[1] > 10000:
                dead.append(thing)
                continue

        for thing in dead:
            scream.play()
            if thing.name == 'Player':
                thing.hitpoints = 100
                thing.location[:] = (500, -10)
                thing.motion_v[:] = 0
                if thing.physics is not None:
                    thing.physics.last_position[:] = thing.location
            else:
                entities.remove(thing)
                thing.dispose()

        xyuv = numpy.empty((4, 4), dtype=numpy.float32)
        texid = [0] * len(entities)
        with entitybuf.bound:
            for n, thing in enumerate(entities):
开发者ID:moshev,项目名称:project-viking,代码行数:67,代码来源:project_viking.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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