From 7f6bcbba639bfbfcacd08113148a98be1693e00c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 11 Jul 2011 02:02:10 +0300 Subject: Bit improve draw speed with double buffer disabled in software mode. --- src/graphics.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/graphics.cpp') 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() -- cgit v1.2.3-60-g2f50