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


Python GL.glUniform1i方法代码示例

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


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

示例1: render

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glUniform1i [as 别名]
def render(self, pixmap, viewport_shape):
    """Renders the pixmap on a fullscreen quad.

    Args:
      pixmap: A 3D numpy array of bytes (np.uint8), with dimensions
        (width, height, 3).
      viewport_shape: A tuple of two elements, (width, height).
    """
    GL.glClear(GL.GL_COLOR_BUFFER_BIT)
    GL.glViewport(0, 0, *viewport_shape)
    GL.glUseProgram(self._shader)
    GL.glActiveTexture(GL.GL_TEXTURE0)
    GL.glBindTexture(GL.GL_TEXTURE_2D, self._texture)
    GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
    GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, pixmap.shape[1],
                    pixmap.shape[0], 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE,
                    pixmap)
    GL.glUniform1i(self._var_texture_sampler, 0)
    GL.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4) 
开发者ID:deepmind,项目名称:dm_control,代码行数:21,代码来源:fullscreen_quad.py

示例2: uniformi

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glUniform1i [as 别名]
def uniformi(self, name, *values):
        {1 : gl.glUniform1i,
         2 : gl.glUniform2i,
         3 : gl.glUniform3i,
         4 : gl.glUniform4i
        }[len(values)](gl.glGetUniformLocation(self.handle, name), *values) 
开发者ID:bitsawer,项目名称:renpy-shader,代码行数:8,代码来源:shaderprogram.py

示例3: __setitem__

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glUniform1i [as 别名]
def __setitem__(self, name, value):
    # quitely ignore
    if name not in self.uniform_types_:
      if WARN_INVALID_UNIFORMS: print("No uniform with name '{}' available.".format(name))
      return

    loc = gl.glGetUniformLocation(self.id_, name)
    T = self.uniform_types_[name]

    if T == "int":
      gl.glUniform1i(loc, np.int32(value))
    if T == "uint":
      gl.glUniform1ui(loc, np.uint32(value))
    elif T == "float":
      gl.glUniform1f(loc, np.float32(value))
    elif T == "bool":
      gl.glUniform1f(loc, value)
    elif T == "vec2":
      gl.glUniform2fv(loc, 1, value)
    elif T == "vec3":
      gl.glUniform3fv(loc, 1, value)
    elif T == "vec4":
      gl.glUniform4fv(loc, 1, value)
    elif T == "ivec2":
      gl.glUniform2iv(loc, 1, value)
    elif T == "ivec3":
      gl.glUniform3iv(loc, 1, value)
    elif T == "ivec4":
      gl.glUniform4iv(loc, 1, value)
    elif T == "uivec2":
      gl.glUniform2uiv(loc, 1, value)
    elif T == "uivec3":
      gl.glUniform3uiv(loc, 1, value)
    elif T == "uivec4":
      gl.glUniform4uiv(loc, 1, value)
    elif T == "mat4":
      #print("set matrix: ", value)
      gl.glUniformMatrix4fv(loc, 1, False, value.astype(np.float32))
    elif T == "sampler2D":
      gl.glUniform1i(loc, np.int32(value))
    elif T == "sampler2DRect":
      gl.glUniform1i(loc, np.int32(value))
    else:
      raise NotImplementedError("uniform type {} not implemented. :(".format(T)) 
开发者ID:PRBonn,项目名称:semantic-kitti-api,代码行数:46,代码来源:glow.py


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