summaryrefslogtreecommitdiff
path: root/src/resources/image.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-18 11:13:53 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-18 11:13:53 +0000
commit1cc8f5dc5413651d12df2ada51538d46734b0f0f (patch)
tree00ec79c11da398a1d53f8cee7e8faaddd2ff11fa /src/resources/image.cpp
parent700730abd0f2c87f4170d4565587ff986bd21018 (diff)
downloadmana-client-1cc8f5dc5413651d12df2ada51538d46734b0f0f.tar.gz
mana-client-1cc8f5dc5413651d12df2ada51538d46734b0f0f.tar.bz2
mana-client-1cc8f5dc5413651d12df2ada51538d46734b0f0f.tar.xz
mana-client-1cc8f5dc5413651d12df2ada51538d46734b0f0f.zip
So I added this alpha attribute to images...
Diffstat (limited to 'src/resources/image.cpp')
-rw-r--r--src/resources/image.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index eca4b42f..02eb2393 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -40,6 +40,8 @@ Image::Image(GLuint image, int width, int height, int texWidth, int texHeight):
texHeight(texHeight)
#endif
{
+ // Default to opaque
+ alpha = 1.0f;
}
Image::~Image()
@@ -250,6 +252,9 @@ bool Image::draw(SDL_Surface *screen, int srcX, int srcY, int dstX, int dstY,
// Check that preconditions for blitting are met.
if (screen == NULL || image == NULL) return false;
+ // Set the alpha value this image is drawn at
+ SDL_SetAlpha(image, SDL_SRCALPHA, 255 * alpha);
+
SDL_Rect dstRect;
SDL_Rect srcRect;
dstRect.x = dstX; dstRect.y = dstY;
@@ -303,6 +308,9 @@ bool Image::draw(SDL_Surface *screen, int x, int y)
// Check that preconditions for blitting are met.
if (screen == NULL || image == NULL) return false;
+ // Set the alpha value this image is drawn at
+ SDL_SetAlpha(image, SDL_SRCALPHA, 255 * alpha);
+
SDL_Rect dstRect;
dstRect.x = x;
dstRect.y = y;
@@ -367,6 +375,17 @@ void Image::drawPattern(SDL_Surface *screen, int x, int y, int w, int h)
}
}
+void Image::setAlpha(float alpha)
+{
+ this->alpha = alpha;
+}
+
+float Image::getAlpha()
+{
+ return alpha;
+}
+
+
//============================================================================
#ifndef USE_OPENGL
@@ -420,6 +439,9 @@ bool SubImage::draw(SDL_Surface *screen, int srcX, int srcY,
// Check that preconditions for blitting are met.
if (screen == NULL || image == NULL) return false;
+ // Set the alpha value this image is drawn at
+ SDL_SetAlpha(image, SDL_SRCALPHA, 255 * alpha);
+
SDL_Rect dstRect;
SDL_Rect srcRect;
dstRect.x = dstX; dstRect.y = dstY;
@@ -473,6 +495,9 @@ bool SubImage::draw(SDL_Surface *screen, int x, int y)
// Check that drawing preconditions are satisfied.
if (screen == NULL || image == NULL) return false;
+ // Set the alpha value this image is drawn at
+ SDL_SetAlpha(image, SDL_SRCALPHA, 255 * alpha);
+
SDL_Rect dstRect;
dstRect.x = x;
dstRect.y = y;