def get_shader_program( self, shader_wrapper: ShaderWrapper) -> tuple[moderngl.Program, str]: sid = shader_wrapper.get_program_id() if sid not in self.id_to_shader_program: # Create shader program for the first time, then cache # in the id_to_shader_program dictionary program = self.ctx.program(**shader_wrapper.get_program_code()) vert_format = moderngl.detect_format( program, shader_wrapper.vert_attributes) self.id_to_shader_program[sid] = (program, vert_format) return self.id_to_shader_program[sid]
def init_shader_data(self): self.fill_data = np.zeros(0, dtype=self.fill_dtype) self.stroke_data = np.zeros(0, dtype=self.stroke_dtype) self.fill_shader_wrapper = ShaderWrapper( vert_data=self.fill_data, vert_indices=np.zeros(0, dtype='i4'), shader_folder=self.fill_shader_folder, render_primitive=self.render_primitive, ) self.stroke_shader_wrapper = ShaderWrapper( vert_data=self.stroke_data, shader_folder=self.stroke_shader_folder, render_primitive=self.render_primitive, )