Create a program and add it to this MultiProgram. It is the caller's responsibility to keep a reference to the returned program. The *name* must be unique, but is otherwise arbitrary and used for debugging purposes.
(self, name=None)
| 27 | self._geom = None if gcode is None else MultiShader(self, 'geom') |
| 28 | |
| 29 | def add_program(self, name=None): |
| 30 | """Create a program and add it to this MultiProgram. |
| 31 | |
| 32 | It is the caller's responsibility to keep a reference to the returned |
| 33 | program. |
| 34 | |
| 35 | The *name* must be unique, but is otherwise arbitrary and used for |
| 36 | debugging purposes. |
| 37 | """ |
| 38 | if name is None: |
| 39 | name = 'program' + str(self._next_prog_id) |
| 40 | self._next_prog_id += 1 |
| 41 | |
| 42 | if name in self._programs: |
| 43 | raise KeyError("Program named '%s' already exists." % name) |
| 44 | |
| 45 | # create a program and update it to look like the rest |
| 46 | prog = ModularProgram(self._vcode, self._fcode, self._gcode) |
| 47 | for key, val in self._set_items.items(): |
| 48 | prog[key] = val |
| 49 | self.frag._new_program(prog) |
| 50 | self.vert._new_program(prog) |
| 51 | if self._geom is not None: |
| 52 | self.geom._new_program(prog) |
| 53 | |
| 54 | self._programs[name] = prog |
| 55 | return prog |
| 56 | |
| 57 | @property |
| 58 | def vert(self): |