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


Python GL.glGetUniformLocation方法代码示例

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


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

示例1: _init_shaders

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glGetUniformLocation [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

示例2: uniformf

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

示例3: uniformi

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glGetUniformLocation [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

示例4: uniformMatrix4f

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glGetUniformLocation [as 别名]
def uniformMatrix4f(self, name, matrix):
        loc = gl.glGetUniformLocation(self.handle, name)
        gl.glUniformMatrix4fv(loc, 1, False, (ctypes.c_float * 16)(*matrix)) 
开发者ID:bitsawer,项目名称:renpy-shader,代码行数:5,代码来源:shaderprogram.py

示例5: uniformMatrix4fArray

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glGetUniformLocation [as 别名]
def uniformMatrix4fArray(self, name, values):
        loc = gl.glGetUniformLocation(self.handle, name)
        count = len(values) / 16
        gl.glUniformMatrix4fv(loc, count, False, (ctypes.c_float * len(values))(*values)) 
开发者ID:bitsawer,项目名称:renpy-shader,代码行数:6,代码来源:shaderprogram.py

示例6: init_shader

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glGetUniformLocation [as 别名]
def init_shader(self, program):
        self.loc_char_size = gl.glGetUniformLocation(program.program, 'char_size')
        self.loc_block_size = gl.glGetUniformLocation(program.program, 'block_size') 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:5,代码来源:glhelpers.py

示例7: get_uniform_location

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glGetUniformLocation [as 别名]
def get_uniform_location(self, name):
        return gl.glGetUniformLocation(self.program, name) 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:4,代码来源:glhelpers.py

示例8: _create_device_objects

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glGetUniformLocation [as 别名]
def _create_device_objects(self):
        # save state
        last_texture = gl.glGetIntegerv(gl.GL_TEXTURE_BINDING_2D)
        last_array_buffer = gl.glGetIntegerv(gl.GL_ARRAY_BUFFER_BINDING)

        last_vertex_array = gl.glGetIntegerv(gl.GL_VERTEX_ARRAY_BINDING)

        self._shader_handle = gl.glCreateProgram()
        # note: no need to store shader parts handles after linking
        vertex_shader = gl.glCreateShader(gl.GL_VERTEX_SHADER)
        fragment_shader = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)

        gl.glShaderSource(vertex_shader, self.VERTEX_SHADER_SRC)
        gl.glShaderSource(fragment_shader, self.FRAGMENT_SHADER_SRC)
        gl.glCompileShader(vertex_shader)
        gl.glCompileShader(fragment_shader)

        gl.glAttachShader(self._shader_handle, vertex_shader)
        gl.glAttachShader(self._shader_handle, fragment_shader)

        gl.glLinkProgram(self._shader_handle)

        # note: after linking shaders can be removed
        gl.glDeleteShader(vertex_shader)
        gl.glDeleteShader(fragment_shader)

        self._attrib_location_tex = gl.glGetUniformLocation(self._shader_handle, "Texture")
        self._attrib_proj_mtx = gl.glGetUniformLocation(self._shader_handle, "ProjMtx")
        self._attrib_location_position = gl.glGetAttribLocation(self._shader_handle, "Position")
        self._attrib_location_uv = gl.glGetAttribLocation(self._shader_handle, "UV")
        self._attrib_location_color = gl.glGetAttribLocation(self._shader_handle, "Color")

        self._vbo_handle = gl.glGenBuffers(1)
        self._elements_handle = gl.glGenBuffers(1)

        self._vao_handle = gl.glGenVertexArrays(1)
        gl.glBindVertexArray(self._vao_handle)
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self._vbo_handle)

        gl.glEnableVertexAttribArray(self._attrib_location_position)
        gl.glEnableVertexAttribArray(self._attrib_location_uv)
        gl.glEnableVertexAttribArray(self._attrib_location_color)

        gl.glVertexAttribPointer(self._attrib_location_position, 2, gl.GL_FLOAT, gl.GL_FALSE, imgui.VERTEX_SIZE, ctypes.c_void_p(imgui.VERTEX_BUFFER_POS_OFFSET))
        gl.glVertexAttribPointer(self._attrib_location_uv, 2, gl.GL_FLOAT, gl.GL_FALSE, imgui.VERTEX_SIZE, ctypes.c_void_p(imgui.VERTEX_BUFFER_UV_OFFSET))
        gl.glVertexAttribPointer(self._attrib_location_color, 4, gl.GL_UNSIGNED_BYTE, gl.GL_TRUE, imgui.VERTEX_SIZE, ctypes.c_void_p(imgui.VERTEX_BUFFER_COL_OFFSET))

        # restore state
        gl.glBindTexture(gl.GL_TEXTURE_2D, last_texture)
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, last_array_buffer)
        gl.glBindVertexArray(last_vertex_array) 
开发者ID:swistakm,项目名称:pyimgui,代码行数:53,代码来源:opengl.py

示例9: __setitem__

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glGetUniformLocation [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

示例10: initializeGL

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glGetUniformLocation [as 别名]
def initializeGL(self):
        """Initialize OpenGL, VBOs, upload data on the GPU, etc."""

        # First check for supported GL version
        gl_version = float(gl.glGetString(gl.GL_VERSION)[:3])
        if gl_version < 3.3:
            print(('OpenGL context created with GL version %.1f' % gl_version))
            qCritical("""Your system reports that it supports OpenGL up to version %.1f. The minimum requirement for BlueSky is OpenGL 3.3.
                Generally, AMD/ATI/nVidia cards from 2008 and newer support OpenGL 3.3, and Intel integrated graphics from the Haswell
                generation and newer. If you think your graphics system should be able to support GL>=3.3 please open an issue report
                on the BlueSky Github page (https://github.com/ProfHoekstra/bluesky/issues)""" % gl_version)
            return

        # background color
        gl.glClearColor(*(palette.background + (0,)))
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

        self.globaldata = radarUBO()

        try:
            shpath = path.join(settings.gfx_path, 'shaders')
            # Compile shaders and link color shader program
            self.color_shader = BlueSkyProgram(path.join(shpath, 'radarwidget-normal.vert'), path.join(shpath, 'radarwidget-color.frag'))
            self.color_shader.bind_uniform_buffer('global_data', self.globaldata)

            # Compile shaders and link texture shader program
            self.texture_shader = BlueSkyProgram(path.join(shpath, 'radarwidget-normal.vert'), path.join(shpath, 'radarwidget-texture.frag'))
            self.texture_shader.bind_uniform_buffer('global_data', self.globaldata)

            # Compile shaders and link text shader program
            self.text_shader = BlueSkyProgram(path.join(shpath, 'radarwidget-text.vert'), path.join(shpath, 'radarwidget-text.frag'))
            self.text_shader.bind_uniform_buffer('global_data', self.globaldata)

            self.ssd_shader = BlueSkyProgram(path.join(shpath, 'ssd.vert'), path.join(shpath, 'ssd.frag'), path.join(shpath, 'ssd.geom'))
            self.ssd_shader.bind_uniform_buffer('global_data', self.globaldata)
            self.ssd_shader.loc_vlimits = gl.glGetUniformLocation(self.ssd_shader.program, 'Vlimits')
            self.ssd_shader.loc_nac = gl.glGetUniformLocation(self.ssd_shader.program, 'n_ac')

        except RuntimeError as e:
            print('Error compiling shaders in radarwidget: ' + e.args[0])
            qCritical('Error compiling shaders in radarwidget: ' + e.args[0])
            return

        # create all vertex array objects
        try:
            self.create_objects()
        except Exception as e:
            print('Error while creating RadarWidget objects: ' + e.args[0]) 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:51,代码来源:radarwidget.py


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