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


Python GL.GL_VERTEX_SHADER属性代码示例

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


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

示例1: link

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import GL_VERTEX_SHADER [as 别名]
def link(self):
    if gl.GL_VERTEX_SHADER not in self.shaders_ or gl.GL_FRAGMENT_SHADER not in self.shaders_:
      raise RuntimeError("program needs at least vertex and fragment shader")

    for shader in self.shaders_.values():
      gl.glAttachShader(self.id_, shader.id)
      for line in shader.code.split("\n"):
        match = re.search(r"uniform\s+(\S+)\s+(\S+)\s*;", line)
        if match:
          self.uniform_types_[match.group(2)] = match.group(1)

    gl.glLinkProgram(self.id_)
    isLinked = bool(gl.glGetProgramiv(self.id_, gl.GL_LINK_STATUS))
    if not isLinked:
      msg = gl.glGetProgramInfoLog(self.id_)

      raise RuntimeError(str(msg.decode("utf-8")))

    # after linking we don't need the source code anymore.
    self.shaders_ = {}
    self.is_linked = True 
开发者ID:PRBonn,项目名称:semantic-kitti-api,代码行数:23,代码来源:glow.py

示例2: _init_shaders

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import GL_VERTEX_SHADER [as 别名]
def _init_shaders(self):
    """Initializes the shaders used to render the textures fullscreen quad."""
    vs = shaders.compileShader(_VERTEX_SHADER, GL.GL_VERTEX_SHADER)
    fs = shaders.compileShader(_FRAGMENT_SHADER, GL.GL_FRAGMENT_SHADER)
    self._shader = shaders.compileProgram(vs, fs)

    stride = _FLOATS_PER_VERTEX * _SIZE_OF_FLOAT
    var_position = GL.glGetAttribLocation(self._shader, _VAR_POSITION)
    GL.glVertexAttribPointer(
        var_position, 2, GL.GL_FLOAT, GL.GL_FALSE, stride, None)
    GL.glEnableVertexAttribArray(var_position)

    var_uv = GL.glGetAttribLocation(self._shader, _VAR_UV)
    uv_offset = ctypes.c_void_p(_FLOATS_PER_XY * _SIZE_OF_FLOAT)
    GL.glVertexAttribPointer(
        var_uv, 2, GL.GL_FLOAT, GL.GL_FALSE, stride, uv_offset)
    GL.glEnableVertexAttribArray(var_uv)

    self._var_texture_sampler = GL.glGetUniformLocation(
        self._shader, _VAR_TEXTURE_SAMPLER) 
开发者ID:deepmind,项目名称:dm_control,代码行数:22,代码来源:fullscreen_quad.py

示例3: __init__

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import GL_VERTEX_SHADER [as 别名]
def __init__(self, vsCode, psCode):
        self.handle = gl.glCreateProgram()
        self.linked = False

        self.createShader(vsCode, gl.GL_VERTEX_SHADER)
        self.createShader(psCode, gl.GL_FRAGMENT_SHADER)

        self.link()

        if not self.linked:
            raise RuntimeError("Shader not linked") 
开发者ID:bitsawer,项目名称:renpy-shader,代码行数:13,代码来源:shaderprogram.py

示例4: __init__

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import GL_VERTEX_SHADER [as 别名]
def __init__(self, vertex_shader, fragment_shader, geom_shader=None):
        self.shaders = []
        self.compile_shader(vertex_shader, gl.GL_VERTEX_SHADER)
        self.compile_shader(fragment_shader, gl.GL_FRAGMENT_SHADER)
        if geom_shader is not None:
            self.compile_shader(geom_shader, gl.GL_GEOMETRY_SHADER)
        self.link() 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:9,代码来源:glhelpers.py

示例5: init_gl

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import GL_VERTEX_SHADER [as 别名]
def init_gl(self):
        vertex_shader = compileShader(
            shader_string("""
            layout(location = 0) in vec3 in_Position;
            layout(location = 1) in vec3 in_Normal;
            layout(location = 2) in vec2 in_TexCoord;
            
            layout(location = 0) uniform mat4 projection = mat4(1);
            layout(location = 4) uniform mat4 model_view = mat4(1);
            layout(location = 8) uniform mat4 normal_matrix = mat4(1);
            
            out vec3 color;
            out vec2 fragTexCoord;
            
            void main() {
              gl_Position = projection * model_view * vec4(in_Position, 1.0);
              vec3 normal = normalize((normal_matrix * vec4(in_Normal, 0)).xyz);
              color = (normal + vec3(1,1,1)) * 0.5; // color by normal
              fragTexCoord = in_TexCoord;
              // color = vec3(in_TexCoord, 0.5); // color by texture coordinate
            }
            """),
            GL.GL_VERTEX_SHADER)
        fragment_shader = compileShader(
            shader_string("""
            uniform sampler2D diffuse;
            in vec3 color;
            in vec2 fragTexCoord;
            out vec4 fragColor;
            
            void main() {
              // fragColor = vec4(color, 1.0);
              fragColor = texture(diffuse, fragTexCoord);
            }
            """),
            GL.GL_FRAGMENT_SHADER)
        self.shader = compileProgram(vertex_shader, fragment_shader)
        self._check_devices()
        GL.glEnable(GL.GL_DEPTH_TEST) 
开发者ID:cmbruns,项目名称:pyopenvr,代码行数:41,代码来源:tracked_devices_actor.py


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