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_mesh_data(manager, fp, cwd): """Loader for bitmaps. :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: Simply the bytes read from file :rtype: :class:`sdl2.SDL_RWops.` """ from surrender import MeshData from surrender import Mesh md = MeshData.from_buffer(fp.read()) mesh = Mesh(md) return { 'mesh_data': md, 'mesh': mesh, }