diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-26 16:56:17 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-26 17:21:08 +0300 |
commit | 299c99691589a72ac2506d4fcb92cad96a0f40bf (patch) | |
tree | 565d5fe5ece43d99e6b1f7ff428e3390fb4b6b81 /src | |
parent | e68a7408f2eba3b50b81db303fdd38ffa5d4bb8b (diff) | |
download | manaverse-299c99691589a72ac2506d4fcb92cad96a0f40bf.tar.gz manaverse-299c99691589a72ac2506d4fcb92cad96a0f40bf.tar.bz2 manaverse-299c99691589a72ac2506d4fcb92cad96a0f40bf.tar.xz manaverse-299c99691589a72ac2506d4fcb92cad96a0f40bf.zip |
fix draw line/point color in software in SDL2.
Diffstat (limited to 'src')
-rw-r--r-- | src/sdl2graphics.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/sdl2graphics.cpp b/src/sdl2graphics.cpp index 263404270..533b44179 100644 --- a/src/sdl2graphics.cpp +++ b/src/sdl2graphics.cpp @@ -331,9 +331,10 @@ void SDLGraphics::calcTileSDL(ImageVertexes *const vert, int x, int y) const return; const Image *const image = vert->image; + const gcn::ClipRectangle &top = mClipStack.top(); - x += mClipStack.top().xOffset; - y += mClipStack.top().yOffset; + x += top.xOffset; + y += top.yOffset; DoubleRect *rect = new DoubleRect(); @@ -477,10 +478,11 @@ bool SDLGraphics::calcWindow(ImageCollection *const vertCol, void SDLGraphics::fillRectangle(const gcn::Rectangle &rectangle) { + const gcn::ClipRectangle &top = mClipStack.top(); const SDL_Rect rect { - static_cast<int16_t>(rectangle.x) + mClipStack.top().xOffset, - static_cast<int16_t>(rectangle.y) + mClipStack.top().yOffset, + static_cast<int16_t>(rectangle.x) + top.xOffset, + static_cast<int16_t>(rectangle.y) + top.yOffset, static_cast<uint16_t>(rectangle.width), static_cast<uint16_t>(rectangle.height) }; @@ -536,7 +538,7 @@ void SDLGraphics::drawPoint(int x, int y) if (mClipStack.empty()) return; - const gcn::ClipRectangle& top = mClipStack.top(); + const gcn::ClipRectangle &top = mClipStack.top(); x += top.xOffset; y += top.yOffset; @@ -544,16 +546,18 @@ void SDLGraphics::drawPoint(int x, int y) if (!top.isPointInRect(x, y)) return; + SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a); SDL_RenderDrawPoint(mRenderer, x, y); } void SDLGraphics::drawRectangle(const gcn::Rectangle &rectangle) { + const gcn::ClipRectangle &top = mClipStack.top(); const SDL_Rect rect { - static_cast<int16_t>(rectangle.x) + mClipStack.top().xOffset, - static_cast<int16_t>(rectangle.y) + mClipStack.top().yOffset, + static_cast<int16_t>(rectangle.x) + top.xOffset, + static_cast<int16_t>(rectangle.y) + top.yOffset, static_cast<uint16_t>(rectangle.width), static_cast<uint16_t>(rectangle.height) }; @@ -564,12 +568,12 @@ void SDLGraphics::drawRectangle(const gcn::Rectangle &rectangle) void SDLGraphics::drawLine(int x1, int y1, int x2, int y2) { - const gcn::ClipRectangle& top = mClipStack.top(); + const gcn::ClipRectangle &top = mClipStack.top(); const int x0 = top.xOffset; const int y0 = top.yOffset; - - SDL_RenderDrawLine(mRenderer, x1 + x0, y1 + x0, x2 + x0, y2 + x0); + SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a); + SDL_RenderDrawLine(mRenderer, x1 + x0, y1 + y0, x2 + x0, y2 + y0); } bool SDLGraphics::setVideoMode(const int w, const int h, const int bpp, |