diff --git a/MiniEngine.cpp b/MiniEngine.cpp index 2025cff..783067f 100644 --- a/MiniEngine.cpp +++ b/MiniEngine.cpp @@ -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(); diff --git a/MiniEngine.h b/MiniEngine.h index e01195d..6cb3d2e 100644 --- a/MiniEngine.h +++ b/MiniEngine.h @@ -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 op; + }; + + enum class BlendMode { None = SDL_BLENDMODE_NONE,