From b7d7883ff0f662836b69e132759c78142d1488c4 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 18 Feb 2005 14:34:32 +0000 Subject: Improve window borders and speed up alpha property by not setting alpha each time the images are drawn. --- src/resources/image.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/resources/image.cpp') diff --git a/src/resources/image.cpp b/src/resources/image.cpp index efd126b1..2ec867ec 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -252,9 +252,6 @@ 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, (int)(255 * alpha)); - SDL_Rect dstRect; SDL_Rect srcRect; dstRect.x = dstX; dstRect.y = dstY; @@ -330,6 +327,11 @@ void Image::drawPattern(SDL_Surface *screen, int x, int y, int w, int h) void Image::setAlpha(float alpha) { this->alpha = alpha; + +#ifndef USE_OPENGL + // Set the alpha value this image is drawn at + SDL_SetAlpha(image, SDL_SRCALPHA | SDL_RLEACCEL, (int)(255 * alpha)); +#endif } float Image::getAlpha() @@ -391,9 +393,6 @@ 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, (int)(255 * alpha)); - SDL_Rect dstRect; SDL_Rect srcRect; dstRect.x = dstX; dstRect.y = dstY; -- cgit v1.2.3-70-g09d2