summaryrefslogtreecommitdiff
path: root/src/resources/image.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-21 12:42:38 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-21 21:15:42 +0100
commit9f8cf8cf3031a0bb314779ab3c9d22fc87d6c306 (patch)
tree20dd5e4bba71c8fa0a8a35c7923e42a3b60c1751 /src/resources/image.cpp
parent5333d8554be855af7b78cdd47d19e8d31abd47c3 (diff)
downloadmana-9f8cf8cf3031a0bb314779ab3c9d22fc87d6c306.tar.gz
mana-9f8cf8cf3031a0bb314779ab3c9d22fc87d6c306.tar.bz2
mana-9f8cf8cf3031a0bb314779ab3c9d22fc87d6c306.tar.xz
mana-9f8cf8cf3031a0bb314779ab3c9d22fc87d6c306.zip
Removed the unused Image::mLoaded member
Diffstat (limited to 'src/resources/image.cpp')
-rw-r--r--src/resources/image.cpp48
1 files changed, 19 insertions, 29 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 82a928b4..ecf6a6be 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -45,7 +45,6 @@ bool Image::mDisableTransparency = false;
SDL_Renderer *Image::mRenderer;
Image::Image(SDL_Texture *texture, int width, int height):
- mLoaded(texture != nullptr),
mTexture(texture)
{
mBounds.x = 0;
@@ -53,16 +52,15 @@ Image::Image(SDL_Texture *texture, int width, int height):
mBounds.w = width;
mBounds.h = height;
- if (!mLoaded)
+ if (!texture)
{
logger->log(
- "Image::Image(SDL_Surface*): Couldn't load invalid Surface!");
+ "Image::Image(SDL_Texture*, ...): Couldn't load invalid Surface!");
}
}
#ifdef USE_OPENGL
Image::Image(GLuint glimage, int width, int height, int texWidth, int texHeight):
- mLoaded(glimage != 0),
mGLImage(glimage),
mTexWidth(texWidth),
mTexHeight(texHeight)
@@ -72,7 +70,7 @@ Image::Image(GLuint glimage, int width, int height, int texWidth, int texHeight)
mBounds.w = width;
mBounds.h = height;
- if (!mLoaded)
+ if (glimage == 0)
{
logger->log(
"Image::Image(GLuint, ...): Couldn't load invalid Surface!");
@@ -82,7 +80,19 @@ Image::Image(GLuint glimage, int width, int height, int texWidth, int texHeight)
Image::~Image()
{
- unload();
+ if (mTexture)
+ {
+ SDL_DestroyTexture(mTexture);
+ mTexture = nullptr;
+ }
+
+#ifdef USE_OPENGL
+ if (mGLImage)
+ {
+ glDeleteTextures(1, &mGLImage);
+ mGLImage = 0;
+ }
+#endif
}
Resource *Image::load(SDL_RWops *rw)
@@ -150,25 +160,6 @@ Image *Image::load(SDL_Surface *tmpImage)
return _SDLload(tmpImage);
}
-void Image::unload()
-{
- mLoaded = false;
-
- if (mTexture)
- {
- SDL_DestroyTexture(mTexture);
- mTexture = nullptr;
- }
-
-#ifdef USE_OPENGL
- if (mGLImage)
- {
- glDeleteTextures(1, &mGLImage);
- mGLImage = 0;
- }
-#endif
-}
-
bool Image::useOpenGL()
{
#ifdef USE_OPENGL
@@ -289,10 +280,9 @@ Image *Image::_GLload(SDL_Surface *image)
if (needsConversion)
SDL_FreeSurface(image);
- GLenum error = glGetError();
- if (error)
+ if (GLenum error = glGetError())
{
- std::string errmsg = "Unknown error";
+ const char *errmsg = "Unknown error";
switch (error)
{
case GL_INVALID_ENUM:
@@ -314,7 +304,7 @@ Image *Image::_GLload(SDL_Surface *image)
errmsg = "GL_OUT_OF_MEMORY";
break;
}
- logger->log("Error: Image GL import failed: %s", errmsg.c_str());
+ logger->log("Error: Image GL import failed: %s", errmsg);
return nullptr;
}