diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-25 19:36:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-25 23:26:55 +0300 |
commit | d5847d54a527c41006cb4cade15d0b6346490e77 (patch) | |
tree | 5146fc48f6e2d10eb3f41f1b20eac16f66b36f28 /src/resources/sdl2imagehelper.cpp | |
parent | 5b20a3d95717f75d33801c4dd2b093e106d90541 (diff) | |
download | manaverse-d5847d54a527c41006cb4cade15d0b6346490e77.tar.gz manaverse-d5847d54a527c41006cb4cade15d0b6346490e77.tar.bz2 manaverse-d5847d54a527c41006cb4cade15d0b6346490e77.tar.xz manaverse-d5847d54a527c41006cb4cade15d0b6346490e77.zip |
add partial support for software mode with SDL2.
Diffstat (limited to 'src/resources/sdl2imagehelper.cpp')
-rw-r--r-- | src/resources/sdl2imagehelper.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/resources/sdl2imagehelper.cpp b/src/resources/sdl2imagehelper.cpp index b131b4d69..ee342ee26 100644 --- a/src/resources/sdl2imagehelper.cpp +++ b/src/resources/sdl2imagehelper.cpp @@ -38,6 +38,9 @@ #include "debug.h" bool SDLImageHelper::mEnableAlphaCache = false; +#ifdef USE_SDL2 +SDL_Renderer *SDLImageHelper::mRenderer = nullptr; +#endif Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye) const { @@ -114,13 +117,9 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage, if (!tmpImage) return nullptr; - Image *img; - bool hasAlpha = false; - uint8_t *alphaChannel = nullptr; - SDL_Surface *image = SDLDuplicateSurface(tmpImage); - - img = new Image(image, hasAlpha, alphaChannel); - img->mAlpha = alpha; + Image *const img = _SDLload(tmpImage); + if (img) + img->setAlpha(alpha); return img; } @@ -137,8 +136,12 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const if (!tmpImage) return nullptr; - SDL_Surface *image = convertTo32Bit(tmpImage); - return new Image(image, false, nullptr); + SDL_Texture *const texture = SDL_CreateTextureFromSurface( + mRenderer, tmpImage); + if (!texture) + return nullptr; + SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); + return new Image(texture, tmpImage->w, tmpImage->h); } int SDLImageHelper::useOpenGL() const |