diff options
Diffstat (limited to 'src/image.cpp')
-rw-r--r-- | src/image.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/image.cpp b/src/image.cpp index 177968a..5adaf6a 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -1,9 +1,9 @@ #include "FLD.hpp" static FLD::Image& -invalid_image() +invalid_image(FLD *fld) { - static FLD::Image image = { .valid = false }; + static FLD::Image image = { .fld = fld, .valid = false }; return image; } @@ -16,30 +16,31 @@ FLD::image(const std::string &path) const auto surf = SDL_LoadBMP(path.c_str()); if (surf == nullptr) { sdlError(path); - return invalid_image(); + return invalid_image(this); } const auto tex = SDL_CreateTextureFromSurface(_renderer, surf); SDL_FreeSurface(surf); if (tex == nullptr) { sdlError(path); - return invalid_image(); + return invalid_image(this); } if (SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND) < 0) { SDL_DestroyTexture(tex); sdlError(path); - return invalid_image(); + return invalid_image(this); } int width, height; if (SDL_QueryTexture(tex, nullptr, nullptr, &width, &height) < 0) { SDL_DestroyTexture(tex); sdlError(path); - return invalid_image(); + return invalid_image(this); } images[path] = { + .fld = this, .path = path, .ptr = tex, .width = width, |