From 1724d87c2271e18e9349abce5a3eebec5ec72f6d Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Sat, 15 Oct 2005 19:51:19 +0000 Subject: Some small cleanups. --- ChangeLog | 2 ++ src/openglgraphics.cpp | 2 +- src/resources/image.cpp | 21 ++++++++------------- src/resources/image.h | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4cd759b3..037c87df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2005-10-15 Björn Steinbrink + * src/openglgraphics.cpp, src/resources/image.cpp, + src/resources/image.h: Some small cleanups. * src/engine.cpp: Removed some legacy debug code. 2005-10-13 Bjørn Lindeijer diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index 983c948e..efe875bc 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -94,7 +94,7 @@ bool OpenGLGraphics::drawImage(Image *image, int srcX, int srcY, float texX2 = (srcX + width) / (float)image->mTexWidth; float texY2 = (srcY + height) / (float)image->mTexHeight; - glColor4f(1.0f, 1.0f, 1.0f, image->alpha); + glColor4f(1.0f, 1.0f, 1.0f, image->mAlpha); glBindTexture(GL_TEXTURE_2D, image->mGLImage); drawTexedQuad(dstX, dstY, width, height, texX1, texY1, texX2, texY2); diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 266f46e3..52b6f447 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -32,11 +32,9 @@ bool Image::mUseOpenGL = false; #endif Image::Image(const std::string &idPath, SDL_Surface *image): - Resource(idPath), mImage(image) + Resource(idPath), mImage(image), + mAlpha(1.0f) { - // Default to opaque - alpha = 1.0f; - bounds.x = 0; bounds.y = 0; bounds.w = mImage->w; @@ -49,11 +47,9 @@ Image::Image(const std::string &idPath, GLuint glimage, int width, int height, Resource(idPath), mGLImage(glimage), mTexWidth(texWidth), - mTexHeight(texHeight) + mTexHeight(texHeight), + mAlpha(1.0f) { - // Default to opaque - alpha = 1.0f; - bounds.x = 0; bounds.y = 0; bounds.w = width; @@ -243,14 +239,13 @@ Image* Image::load(void *buffer, unsigned int bufferSize, // Set color key and alpha blending optins, and convert the surface to the // current display format - SDL_Surface *prevImage = tmpImage; if (hasAlpha) { image = SDL_DisplayFormatAlpha(tmpImage); } else { image = SDL_DisplayFormat(tmpImage); } - SDL_FreeSurface(prevImage); + SDL_FreeSurface(tmpImage); if (image == NULL) { logger->log("Error: Image convert failed."); @@ -290,7 +285,7 @@ Image *Image::getSubImage(int x, int y, int width, int height) void Image::setAlpha(float a) { - alpha = a; + mAlpha = a; #ifdef USE_OPENGL if (mUseOpenGL) { @@ -299,12 +294,12 @@ void Image::setAlpha(float a) #endif // Set the alpha value this image is drawn at - SDL_SetAlpha(mImage, SDL_SRCALPHA | SDL_RLEACCEL, (int)(255 * alpha)); + SDL_SetAlpha(mImage, SDL_SRCALPHA | SDL_RLEACCEL, (int)(255 * mAlpha)); } float Image::getAlpha() { - return alpha; + return mAlpha; } #ifdef USE_OPENGL diff --git a/src/resources/image.h b/src/resources/image.h index a7d5cdf1..44142155 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -129,7 +129,7 @@ class Image : public Resource static bool mUseOpenGL; #endif SDL_Surface *mImage; - float alpha; + float mAlpha; }; /** -- cgit v1.2.3-70-g09d2