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


Python Shader.from_files方法代码示例

本文整理汇总了Python中shader.Shader.from_files方法的典型用法代码示例。如果您正苦于以下问题:Python Shader.from_files方法的具体用法?Python Shader.from_files怎么用?Python Shader.from_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shader.Shader的用法示例。


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

示例1: __init__

# 需要导入模块: from shader import Shader [as 别名]
# 或者: from shader.Shader import from_files [as 别名]
    def __init__(self, width, height, pattern, scale=2):
        '''
        width, height:
            size of the window in pixels.
        scale:
            the size of the texture is (width//scale) x (height//scale).
        pattern:
            a name in dict 'species'.
        '''
        pyglet.window.Window.__init__(self, width, height, caption='GrayScott Simulation',
                                      visible=False, vsync=False)

        # we will need two shaders, one for computing the reaction and diffusion,
        # and one for coloring the uv_texture.
        self.reaction_shader = Shader.from_files('default.vert', 'reaction.frag')
        self.render_shader = Shader.from_files('default.vert', 'render.frag')

        self.pattern = pattern
        self.palette = GrayScott.palette_default

        self.tex_width = width // scale
        self.tex_height = height // scale
        self.uv_texture = create_uv_texture(width // scale, height // scale)
        # the texture is bind to unit '0'.
        gl.glActiveTexture(gl.GL_TEXTURE0)
        gl.glBindTexture(self.uv_texture.target, self.uv_texture.id)

        # set the uniforms and attributes in the two shaders.
        self.init_reaction_shader()
        self.init_render_shader()

        # we need a framebuffer to do the offscreen rendering.
        # once we finished computing the reaction-diffusion step with the reaction_shader,
        # we render the result to this 'invisible' buffer since we do not want to show it.
        # the final image is further colored and will be rendered to the window.
        with FrameBuffer() as self.fbo:
            self.fbo.attach_texture(self.uv_texture)

        # why do we need this?
        # the reason is in the 'on_mouse_drag' function.
        self.mouse_down = False
开发者ID:hooloong,项目名称:gitpython,代码行数:43,代码来源:main.py


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