Exemple #1
0
 def setProgramConstant(self, locname, data):
     loc = gl.getUniformLocation(self._current_prog.gl_program, locname)
     
     if isinstance(data, int):
         self._do(gl.uniform1i, loc, data)
     elif isinstance(data, float):
         self._do(gl.uniform1f, loc, data)
     else:
         assert len(data) <= 4
         meth_tp = 'f' if isinstance(data[0], float) else 'i'
         meth = getattr(gl, 'uniform%d%s' % (len(data), meth_tp))
         self._do(meth, loc, *data)
Exemple #2
0
    def setTextureAt(self, locname, texture, texture_index=0):
        loc = gl.getUniformLocation(self._current_prog.gl_program, locname)

        assert 0 <= texture_index < 8, \
                    'Texture index "%s" is not supported' % str(texture_index)
        self._do(gl.activeTexture, gl.TEXTURE0 + texture_index)

        self._bind_texture(texture)

        self._do(gl.uniform1i, loc, texture_index)
        self._do(gl.texParameter, gl.TEXTURE_2D,
                        gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
        self._do(gl.texParameter, gl.TEXTURE_2D,
                        gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
        self._do(gl.texParameter, gl.TEXTURE_2D,
                        gl.TEXTURE_MIN_FILTER, gl.LINEAR)
        self._do(gl.texParameter, gl.TEXTURE_2D,
                        gl.TEXTURE_MAG_FILTER, gl.LINEAR)
Exemple #3
0
 def setProgramConstantFromMatrix(self, locname, mat, transpose=False):
     loc = gl.getUniformLocation(self._current_prog.gl_program, locname)
     self._do(gl.uniformMatrix, loc, transpose, mat)