Add Support for SDL_RWops

This commit is contained in:
Kirigaya Kazuto 2017-04-10 15:27:24 +08:00
parent af18ae23da
commit 01735059fc
2 changed files with 35 additions and 0 deletions

View File

@ -129,6 +129,27 @@ namespace MiniEngine
return str.c_str();
}
RWOP::RWOP(FILE* fp,bool autoclose)
{
SDL_bool b=autoclose?SDL_TRUE:SDL_FALSE;
op.reset(SDL_RWFromFP(fp,b),[](SDL_RWops* p){SDL_RWclose(p);});
}
RWOP::RWOP(const std::string& filename,const std::string& openmode)
{
op.reset(SDL_RWFromFile(filename.c_str(),openmode.c_str()),[](SDL_RWops* p){SDL_RWclose(p);});
}
RWOP::RWOP(const void* mem,int size)
{
op.reset(SDL_RWFromConstMem(mem,size),[](SDL_RWops* p){SDL_RWclose(p);});
}
RWOP::RWOP(void* mem,int size)
{
op.reset(SDL_RWFromMem(mem,size),[](SDL_RWops* p){SDL_RWclose(p);});
}
Texture::Texture()
{
updateInfo();

View File

@ -72,6 +72,20 @@ namespace MiniEngine
std::string str;
};
class RWOP
{
public:
RWOP(FILE* fp,bool autoclose);
RWOP(const std::string& filename,const std::string& openmode);
RWOP(const void* mem,int size);
RWOP(void* mem,int size);
RWOP()=default;
~RWOP()=default;
private:
std::shared_ptr<SDL_RWops> op;
};
enum class BlendMode
{
None = SDL_BLENDMODE_NONE,