From 5e4fcb8a6036746ec1b500297fa55989a80094b4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 22 Aug 2013 14:47:53 +0300 Subject: final SDL2 compilation fixes. now it can be compiled, but still not works. --- src/sdl2graphics.cpp | 72 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 29 deletions(-) (limited to 'src/sdl2graphics.cpp') diff --git a/src/sdl2graphics.cpp b/src/sdl2graphics.cpp index a2fc010f6..09b52470b 100644 --- a/src/sdl2graphics.cpp +++ b/src/sdl2graphics.cpp @@ -35,14 +35,17 @@ #include -#include +#include + +//#include #include "debug.h" int MSDL_gfxBlitRGBA(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) { - return SDL_gfxBlitRGBA(src, srcrect, dst, dstrect); + return 0; +// return SDL_gfxBlitRGBA(src, srcrect, dst, dstrect); } #if SDL_BYTEORDER == SDL_LIL_ENDIAN @@ -100,8 +103,9 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, int srcX, int srcY srcRect.w = static_cast(width); srcRect.h = static_cast(height); - const bool returnValue = !(SDL_BlitSurface(tmpImage->mSDLSurface, - &srcRect, mWindow, &dstRect) < 0); + const bool returnValue(true); +// const bool returnValue = !(SDL_BlitSurface(tmpImage->mSDLSurface, +// &srcRect, mWindow, &dstRect) < 0); delete tmpImage; @@ -132,6 +136,8 @@ bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY, srcRect.w = static_cast(width); srcRect.h = static_cast(height); + return true; +/* if (mBlitMode == BLIT_NORMAL) { return !(SDL_BlitSurface(image->mSDLSurface, &srcRect, @@ -142,6 +148,7 @@ bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY, return !(SDL_gfxBlitRGBA(image->mSDLSurface, &srcRect, mWindow, &dstRect) < 0); } +*/ } void SDLGraphics::drawImagePattern(const Image *const image, @@ -182,7 +189,7 @@ void SDLGraphics::drawImagePattern(const Image *const image, srcRect.w = static_cast(dw); srcRect.h = static_cast(dh); - SDL_BlitSurface(image->mSDLSurface, &srcRect, mWindow, &dstRect); +// SDL_BlitSurface(image->mSDLSurface, &srcRect, mWindow, &dstRect); } } } @@ -234,8 +241,8 @@ void SDLGraphics::drawRescaledImagePattern(const Image *const image, srcRect.w = static_cast(dw); srcRect.h = static_cast(dh); - SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect, - mWindow, &dstRect); +// SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect, +// mWindow, &dstRect); } } @@ -279,12 +286,14 @@ void SDLGraphics::calcImagePattern(ImageVertexes* const vert, srcRect.w = static_cast(dw); srcRect.h = static_cast(dh); +/* if (SDL_FakeUpperBlit(image->mSDLSurface, &srcRect, mWindow, &dstRect) == 1) { vert->sdl.push_back(r); } else +*/ { delete r; } @@ -341,12 +350,14 @@ void SDLGraphics::calcTileSDL(ImageVertexes *const vert, int x, int y) const rect->src.y = static_cast(image->mBounds.y); rect->src.w = static_cast(image->mBounds.w); rect->src.h = static_cast(image->mBounds.h); +/* if (SDL_FakeUpperBlit(image->mSDLSurface, &rect->src, mWindow, &rect->dst) == 1) { vert->sdl.push_back(rect); } else +*/ { delete rect; } @@ -384,8 +395,8 @@ void SDLGraphics::drawTile(const ImageCollection *const vertCol) const DoubleRects::const_iterator it2_end = rects->end(); while (it2 != it2_end) { - SDL_LowerBlit(img->mSDLSurface, &(*it2)->src, - mWindow, &(*it2)->dst); +// SDL_LowerBlit(img->mSDLSurface, &(*it2)->src, +// mWindow, &(*it2)->dst); ++ it2; } } @@ -400,7 +411,7 @@ void SDLGraphics::drawTile(const ImageVertexes *const vert) const DoubleRects::const_iterator it_end = rects->end(); while (it != it_end) { - SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mWindow, &(*it)->dst); +// SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mWindow, &(*it)->dst); ++ it; } } @@ -408,15 +419,7 @@ void SDLGraphics::drawTile(const ImageVertexes *const vert) void SDLGraphics::updateScreen() { BLOCK_START("Graphics::updateScreen") - if (mDoubleBuffer) - { - SDL_Flip(mWindow); - } - else - { - SDL_UpdateRects(mWindow, 1, &mRect); -// SDL_UpdateRect(mWindow, 0, 0, 0, 0); - } + SDL_RenderPresent(mRenderer); BLOCK_END("Graphics::updateScreen") } @@ -436,8 +439,8 @@ SDL_Surface *SDLGraphics::getScreenshot() SDL_Surface *const screenshot = SDL_CreateRGBSurface(SDL_SWSURFACE, mRect.w, mRect.h, 24, rmask, gmask, bmask, amask); - if (screenshot) - SDL_BlitSurface(mWindow, nullptr, screenshot, nullptr); +// if (screenshot) +// SDL_BlitSurface(mWindow, nullptr, screenshot, nullptr); return screenshot; } @@ -482,9 +485,9 @@ bool SDLGraphics::calcWindow(ImageCollection *const vertCol, } int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src, - SDL_Rect *const srcrect, - const SDL_Surface *const dst, - SDL_Rect *dstrect) const + SDL_Rect *const srcrect, + const SDL_Surface *const dst, + SDL_Rect *dstrect) const { SDL_Rect fulldst; int srcx, srcy, w, h; @@ -578,7 +581,6 @@ int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src, dstrect->h = static_cast(h); return 1; -// return SDL_LowerBlit(src, &sr, dst, dstrect); } dstrect->w = dstrect->h = 0; return 0; @@ -586,6 +588,7 @@ int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src, void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle) { +/* FUNC_BLOCK("Graphics::fillRectangle", 1) if (mClipStack.empty()) return; @@ -778,6 +781,7 @@ void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle) static_cast(mColor.a)); SDL_FillRect(mWindow, &rect, color); } +*/ } void SDLGraphics::_beginDraw() @@ -800,7 +804,7 @@ bool SDLGraphics::pushClipArea(gcn::Rectangle area) rect.y = static_cast(carea.y); rect.w = static_cast(carea.width); rect.h = static_cast(carea.height); - SDL_SetClipRect(mWindow, &rect); +// SDL_SetClipRect(mWindow, &rect); return result; } @@ -819,7 +823,7 @@ void SDLGraphics::popClipArea() rect.w = static_cast(carea.width); rect.h = static_cast(carea.height); - SDL_SetClipRect(mWindow, &rect); +// SDL_SetClipRect(mWindow, &rect); } void SDLGraphics::drawPoint(int x, int y) @@ -835,14 +839,17 @@ void SDLGraphics::drawPoint(int x, int y) if (!top.isPointInRect(x, y)) return; +/* if (mAlpha) SDLputPixelAlpha(mWindow, x, y, mColor); else SDLputPixel(mWindow, x, y, mColor); +*/ } void SDLGraphics::drawHLine(int x1, int y, int x2) { +/* if (mClipStack.empty()) return; @@ -965,10 +972,12 @@ void SDLGraphics::drawHLine(int x1, int y, int x2) } // end switch SDL_UnlockSurface(mWindow); +*/ } void SDLGraphics::drawVLine(int x, int y1, int y2) { +/* if (mClipStack.empty()) return; @@ -1100,6 +1109,7 @@ void SDLGraphics::drawVLine(int x, int y1, int y2) } // end switch SDL_UnlockSurface(mWindow); +*/ } void SDLGraphics::drawRectangle(const gcn::Rectangle &rectangle) @@ -1146,9 +1156,13 @@ bool SDLGraphics::setVideoMode(const int w, const int h, const int bpp, return false; } - mRect.w = static_cast(mWindow->w); - mRect.h = static_cast(mWindow->h); + int w1 = 0; + int h1 = 0; + SDL_GetWindowSize(mWindow, &w1, &h1); + mRect.w = w1; + mRect.h = h1; + mRenderer = graphicsManager.createRenderer(mWindow, 0); return videoInfo(); } -- cgit v1.2.3-70-g09d2