diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-07-15 22:58:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-07-15 22:58:19 +0300 |
commit | cb82d49bf76c821450934046ff423da51819b521 (patch) | |
tree | 6e2ee33448440ce54e6a7ebb59a14ca5a9d41b21 /src/graphics.cpp | |
parent | 676adcda69d383b923ed8de1f0411746ae5f7080 (diff) | |
download | manaplus-cb82d49bf76c821450934046ff423da51819b521.tar.gz manaplus-cb82d49bf76c821450934046ff423da51819b521.tar.bz2 manaplus-cb82d49bf76c821450934046ff423da51819b521.tar.xz manaplus-cb82d49bf76c821450934046ff423da51819b521.zip |
Fix bug in fillRectangle in software mode for 16 bit pixel screens.
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r-- | src/graphics.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp index fac91b4d5..d63c27324 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -65,8 +65,6 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel) logger->log("Setting video mode %dx%d %s", w, h, fs ? "fullscreen" : "windowed"); - logger->log("Bits per pixel: %d", bpp); - int displayFlags = SDL_ANYFORMAT; mWidth = w; @@ -102,6 +100,9 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel) logger->log("Double buffer mode: %s", mDoubleBuffer ? "yes" : "no"); + if (mTarget->format) + logger->log("Bits per pixel: %d", mTarget->format->BytesPerPixel); + const SDL_VideoInfo *vi = SDL_GetVideoInfo(); logger->log("Possible to create hardware surfaces: %s", @@ -723,7 +724,6 @@ int Graphics::SDL_FakeUpperBlit (SDL_Surface *src, SDL_Rect *srcrect, return 0; } -#if !defined(__MINGW32__) void Graphics::fillRectangle(const gcn::Rectangle& rectangle) { if (mClipStack.empty()) @@ -748,11 +748,12 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle) area.y + area.height : top.y + top.height; int x, y; + SDL_LockSurface(mTarget); + const int bpp = mTarget->format->BytesPerPixel; Uint32 pixel = SDL_MapRGB(mTarget->format, mColor.r, mColor.g, mColor.b); - SDL_LockSurface(mTarget); switch(bpp) { case 1: @@ -766,10 +767,11 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle) case 2: for (y = y1; y < y2; y++) { - Uint8 *p = (Uint8 *)mTarget->pixels + y * mTarget->pitch; + Uint8 *p0 = (Uint8 *)mTarget->pixels + y * mTarget->pitch; for (x = x1; x < x2; x++) { - *(Uint16 *)(p + x * 2) = gcn::SDLAlpha16( + Uint8 *p = p0 + x * 2; + *(Uint16 *)p = gcn::SDLAlpha16( pixel, *(Uint32 *)p, mColor.a, mTarget->format); } } @@ -843,4 +845,3 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle) SDL_FillRect(mTarget, &rect, color); } } -#endif |