Trees | Indices | Help |
---|
|
1 """Descriptors for L{ShaderProgram} uniforms. 2 3 End users should typically not need to use this module directly. 4 5 @bug: Structs and arrays of structs are currently unimplemented. 6 7 @author: Stephan Wenger 8 @date: 2012-02-29 9 """ 10 11 from collections import OrderedDict as _odict 12 import numpy as _np 13 14 import glitter.raw as _gl 186321 self.name = name 22 self.location = location 23 self.dtype = dtype 24 self.size = size 25 self.parent = parent 26 self.textures = []27 3032 if self.dtype.is_texture() and not get_texture_unit_instead_of_object: 33 return self.textures[0] if len(self.textures) == 1 else self.textures 34 else: 35 with obj._context: 36 if self.size == 1: 37 data = self.dtype.get_value(obj, self.location) 38 return data.item() if len(data) == 1 else data 39 else: 40 data = [self.dtype.get_value(obj, _gl.glGetUniformLocation(obj._id, "%s[%d]" % (self.name, i))) for i in range(self.size)] 41 return _np.concatenate([x.squeeze()[None] for x in data])4244 if self.dtype.is_texture(): 45 if self.parent._context.current_program == self.parent: 46 self._on_release() 47 self.textures = value if hasattr(value, "__iter__") else [value] 48 if self.parent._context.current_program == self.parent: 49 self._on_bind() 50 else: 51 self.dtype.set_value(obj, self.location, value, self.size)5254 if self.dtype.is_texture(): 55 units = [self.parent._context.texture_units.bind(x) for x in self.textures] 56 if units: 57 self.dtype.set_value(self.parent, self.location, units, self.size)5860 if self.dtype.is_texture(): 61 for x in self.textures: 62 self.parent._context.texture_units.release(x)6988 11871 return "uniform struct { %s } %s;" % (" ".join(str(value) for value in self.values()), self.name)72 76 80 84
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Mar 16 17:56:05 2012 | http://epydoc.sourceforge.net |