added constructor for external surfaces

This commit is contained in:
Bob Polis 2020-10-24 18:01:44 +02:00
parent 027b9ba84a
commit 84a196ab1a
2 changed files with 5 additions and 0 deletions

View File

@ -35,3 +35,7 @@ Image::Image(const std::string& path) {
if (!loaded) throw std::runtime_error(IMG_GetError());
_s.reset(loaded);
}
Image::Image(SDL_Surface* surface) {
_s.reset(surface);
}

View File

@ -19,6 +19,7 @@ namespace sc {
public:
Image(int w, int h);
Image(const std::string& path);
Image(SDL_Surface* surface);
SDL_Surface* surface() const { return _s.get(); }
int width() const { return _s.get()->w; }