Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void free_sdl_surface(SDL_Surface* surf)
- {
- if(surf) {
- SDL_FreeSurface(surf);
- }
- }
- struct surface
- {
- public:
- surface()
- : surface_(nullptr)
- {}
- surface(SDL_Surface *surf)
- : surface_(surf, free_sdl_surface)
- {}
- surface(const surface& o)
- : surface_(o.surface_.get(), free_sdl_surface)
- {}
- // DO I NEED THIS IT DOESN'T BUILD
- surface& operator=(const SDL_Surface* s)
- {
- surface_ = std::make_shared(s);
- return *this;
- }
- surface& operator=(const surface& o)
- {
- surface_ = o.surface_;
- return *this;
- }
- operator SDL_Surface*() const { return surface_.get(); }
- SDL_Surface* get() const { return surface_.get(); }
- SDL_Surface* operator->() const { return surface_.get(); }
- bool null() const { return surface_.get() == nullptr; }
- private:
- std::shared_ptr<SDL_Surface> surface_;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement