Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (22 sloc) 0.825 kB
#include "libs.h"
#include "SDLWrappers.h"
#include "FileSystem.h"
SDLSurfacePtr LoadSurfaceFromFile(const std::string &fname, FileSystem::FileSource &source)
{
RefCountedPtr<FileSystem::FileData> filedata = FileSystem::gameDataFiles.ReadFile(fname);
if (!filedata) {
fprintf(stderr, "LoadSurfaceFromFile: %s: could not read file\n", fname.c_str());
return SDLSurfacePtr();
}
SDL_RWops *datastream = SDL_RWFromConstMem(filedata->GetData(), filedata->GetSize());
SDL_Surface *surface = IMG_Load_RW(datastream, 1);
if (!surface) {
fprintf(stderr, "LoadSurfaceFromFile: %s: %s\n", fname.c_str(), IMG_GetError());
return SDLSurfacePtr();
}
return SDLSurfacePtr::WrapNew(surface);
}
SDLSurfacePtr LoadSurfaceFromFile(const std::string &fname)
{
return LoadSurfaceFromFile(fname, FileSystem::gameDataFiles);
}
Jump to Line
Something went wrong with that request. Please try again.