def load(self, mesh_file): # load mesh md = MeshData.from_file(mesh_file) self.mesh = Mesh(md) # instantiate animations self.animations = [ AnimationInstance(anim) for anim in md.animations ] self.current_anim_idx = -1 self.current_anim = self.next_anim() # compile shaders vert_file = open('data/default.vert', 'rb') frag_file = open('data/default.frag', 'rb') sources = [ ShaderSource.from_buffer(vert_file.read(), ShaderSource.VERTEX_SHADER), ShaderSource.from_buffer(frag_file.read(), ShaderSource.FRAGMENT_SHADER), ] vert_file.close() frag_file.close() # create and make active the shader program self.shader = Shader(*sources) self.shader.use()
def load_frag_shader_source(manager, fp, cwd): """Loader for frag files. :param manager: The resource manager :type manager: :class:`loaders.ResourceManager` :param fp: The file pointer :type fp: File :param cwd: The current working directory :type cwd: str :returns: The resulting frag object :rtype: :class:`surrender.ShaderSource` """ from surrender import ShaderSource return ShaderSource.from_buffer(fp.read(), ShaderSource.FRAGMENT_SHADER)