1 """Descriptors for L{ShaderProgram} attributes.
2
3 End users should typically not need to use this module directly.
4
5 @bug: Attributes are currently unimplemented.
6
7 @author: Stephan Wenger
8 @date: 2012-02-29
9 """
10
11 from collections import OrderedDict as _odict
15
17 - def __init__(self, name, location, dtype, size, parent):
23
25 if self.size == 1:
26 return "%s %s;" % (self.dtype, self.name)
27 else:
28 return "%s %s[%d];" % (self.dtype, self.name, self.size)
29
32
34 """@todo: Implement this."""
35 raise NotImplementedError
36
38 """@todo: Implement this: if the shader is currently bound, set the attribute at once, else store only."""
39 raise NotImplementedError
40
42 """@todo: Implement this: call C{glVertexAttrib} with C{index=self._location}."""
43 pass
44
46 """@todo: Implement this: restore old vertex attrib values if possible."""
47 pass
48
54
57
60
62 """@todo: Implement this."""
63 raise NotImplementedError
64
66 """@todo: Implement this."""
67 raise NotImplementedError
68
70 """@todo: Implement this: call C{glVertexAttrib} with C{index=self._location}."""
71 pass
72
74 """@todo: Implement this: restore old vertex attrib values if possible."""
75 pass
76
82
83 @property
85 return max(index for index, field in self.keys()) + 1
86
88 unique_values = _odict((field, value) for ((index, field), value) in self.items())
89 return "struct { %s } %s[%d];" % (" ".join(repr(value) for value in unique_values.values()), self.name, self.size)
90
93
95 """@todo: Implement this."""
96 raise NotImplementedError
97
99 """@todo: Implement this."""
100 raise NotImplementedError
101
103 """@todo: Implement this: call C{glVertexAttrib} with C{index=self._location}."""
104 pass
105
107 """@todo: Implement this: restore old vertex attrib values if possible."""
108 pass
109