summaryrefslogtreecommitdiff
path: root/src/graphics.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-05-20 01:35:17 -0600
committerJared Adams <jaxad0127@gmail.com>2010-05-20 12:25:37 -0600
commit487a86fe7dc9904f445d91667095f641f72f7c81 (patch)
tree57191d175f7b2fe771f6b2da225bc2d9cb5ff1d9 /src/graphics.cpp
parent36832f3a5378f739da7040f0711b7101dbc2af02 (diff)
downloadMana-487a86fe7dc9904f445d91667095f641f72f7c81.tar.gz
Mana-487a86fe7dc9904f445d91667095f641f72f7c81.tar.bz2
Mana-487a86fe7dc9904f445d91667095f641f72f7c81.tar.xz
Mana-487a86fe7dc9904f445d91667095f641f72f7c81.zip
Buffer layered sprites under SDL
This improves framerate and allows transparent overlay for complex sprites. Two copies of the buffer are kept, one at full opacity, one with variable opactiy, to reduce calls to setAlpha. Reviewed-by: Bertram
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r--src/graphics.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 9815e1ad..24f92544 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -27,12 +27,15 @@
#include "resources/image.h"
#include "resources/imageloader.h"
+#include <SDL_gfxBlitFunc.h>
+
Graphics::Graphics():
mWidth(0),
mHeight(0),
mBpp(0),
mFullscreen(false),
- mHWAccel(false)
+ mHWAccel(false),
+ mBlitMode(BLIT_NORMAL)
{
}
@@ -183,7 +186,10 @@ bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY,
srcRect.w = width;
srcRect.h = height;
- return !(SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect) < 0);
+ if (mBlitMode == BLIT_NORMAL)
+ return !(SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect) < 0);
+ else
+ return !(SDL_gfxBlitRGBA(image->mSDLSurface, &srcRect, mTarget, &dstRect) < 0);
}
void Graphics::drawImage(gcn::Image const *image, int srcX, int srcY,