summaryrefslogtreecommitdiff
path: root/src/graphics.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-07-11 02:02:10 +0300
committerAndrei Karas <akaras@inbox.ru>2011-07-11 02:02:10 +0300
commit7f6bcbba639bfbfcacd08113148a98be1693e00c (patch)
tree19af07469e8dff8d3c7178fadc4fab0dfc0dc5c8 /src/graphics.cpp
parentb3ba55c192e08e094063ea9d2a70f2aece9c85d7 (diff)
downloadManaVerse-7f6bcbba639bfbfcacd08113148a98be1693e00c.tar.gz
ManaVerse-7f6bcbba639bfbfcacd08113148a98be1693e00c.tar.bz2
ManaVerse-7f6bcbba639bfbfcacd08113148a98be1693e00c.tar.xz
ManaVerse-7f6bcbba639bfbfcacd08113148a98be1693e00c.zip
Bit improve draw speed with double buffer disabled in software mode.
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r--src/graphics.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 4914d22ce..d07d45bb3 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -46,8 +46,13 @@ Graphics::Graphics():
mFullscreen(false),
mHWAccel(false),
mBlitMode(BLIT_NORMAL),
- mRedraw(false)
+ mRedraw(false),
+ mDoubleBuffer(false)
{
+ mRect.x = 0;
+ mRect.y = 0;
+ mRect.w = 0;
+ mRect.h = 0;
}
Graphics::~Graphics()
@@ -83,6 +88,9 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
if (!mTarget)
return false;
+ mRect.w = mTarget->w;
+ mRect.h = mTarget->h;
+
char videoDriverName[65];
if (SDL_VideoDriverName(videoDriverName, 64))
@@ -90,6 +98,10 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
else
logger->log1("Using video driver: unknown");
+ mDoubleBuffer = ((mTarget->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF);
+ logger->log("Double buffer mode: %s",
+ mDoubleBuffer ? "yes" : "no");
+
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
logger->log("Possible to create hardware surfaces: %s",
@@ -558,7 +570,15 @@ void Graphics::calcImagePattern(GraphicsVertexes* vert,
void Graphics::updateScreen()
{
- SDL_Flip(mTarget);
+ if (mDoubleBuffer)
+ {
+ SDL_Flip(mTarget);
+ }
+ else
+ {
+ SDL_UpdateRects(mTarget, 1, &mRect);
+// SDL_UpdateRect(mTarget, 0, 0, 0, 0);
+ }
}
SDL_Surface *Graphics::getScreenshot()