當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。