Exemple #1
0
 def uniform_f(self, name, values):
     loc = glGetUniformLocation(self._handle, name)
     assert loc >= 0
     values = _np.ascontiguousarray(_np.atleast_2d(values), _np.float32)
     n, m = values.shape
     functions = [glProgramUniform1fv, glProgramUniform2fv, glProgramUniform3fv, glProgramUniform4fv]
     gl_program_uniform_fv = functions[m - 1]
     gl_program_uniform_fv(self._handle, loc, n, values)
Exemple #2
0
 def uniform_f(self, name, values):
     loc = glGetUniformLocation(self._handle, name)
     assert loc >= 0
     values = _np.ascontiguousarray(_np.atleast_2d(values), _np.float32)
     n, m = values.shape
     functions = [glProgramUniform1fv, glProgramUniform2fv, glProgramUniform3fv, glProgramUniform4fv]
     gl_program_uniform_fv = functions[m - 1]
     gl_program_uniform_fv(self._handle, loc, n, values)
Exemple #3
0
 def uniform_matrix_f(self, name, mat, transpose=True):
     loc = glGetUniformLocation(self._handle, name)
     assert loc >= 0
     mat = _np.float32(mat)
     if mat.ndim < 3:
         mat = mat[_np.newaxis, ...]
     assert mat.shape[1] == mat.shape[2], 'Matrix is not square!'
     functions = [glUniformMatrix2fv, glUniformMatrix3fv, glUniformMatrix4fv]
     gl_uniform_matrix_nfv = functions[mat.shape[1] - 2]
     values = _np.ascontiguousarray(mat, _np.float32)
     gl_uniform_matrix_nfv(loc, len(mat), transpose, values)
Exemple #4
0
 def uniform_matrix_f(self, name, mat, transpose=True):
     loc = glGetUniformLocation(self._handle, name)
     assert loc >= 0
     mat = _np.float32(mat)
     if mat.ndim < 3:
         mat = mat[_np.newaxis, ...]
     assert mat.shape[1] == mat.shape[2], 'Matrix is not square!'
     functions = [glUniformMatrix2fv, glUniformMatrix3fv, glUniformMatrix4fv]
     gl_uniform_matrix_nfv = functions[mat.shape[1] - 2]
     values = _np.ascontiguousarray(mat, _np.float32)
     gl_uniform_matrix_nfv(loc, len(mat), transpose, values)
Exemple #5
0
 def uniform_i(self, name, values):
     loc = glGetUniformLocation(self._handle, name)
     if loc < 0:
         logger.warn('Uniform "{}" has location={}.'
                     ' (The reason maybe in name mismatch or simply compiler optimization)'
                     .format(name, loc))
         return
     values = _np.ascontiguousarray(_np.atleast_2d(values), _np.int32)
     n, m = values.shape
     functions = [glProgramUniform1iv, glProgramUniform2iv, glProgramUniform3iv, glProgramUniform4iv]
     gl_program_uniform_iv = functions[m - 1]
     gl_program_uniform_iv(self._handle, loc, n, values)
Exemple #6
0
 def uniform_i(self, name, values):
     loc = glGetUniformLocation(self._handle, name)
     if loc < 0:
         logger.warn('Uniform "{}" has location={}.'
                     ' (The reason maybe in name mismatch or simply compiler optimization)'
                     .format(name, loc))
         return
     values = _np.ascontiguousarray(_np.atleast_2d(values), _np.int32)
     n, m = values.shape
     functions = [glProgramUniform1iv, glProgramUniform2iv, glProgramUniform3iv, glProgramUniform4iv]
     gl_program_uniform_iv = functions[m - 1]
     gl_program_uniform_iv(self._handle, loc, n, values)