From 43fd8a8d53d4bd811a8e4d468a78f201148e5896 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 24 Aug 2013 18:51:52 +0300 Subject: fix atlases cretion in SDL2. --- src/resources/atlasmanager.cpp | 15 +++++++-------- src/resources/sdl2imagehelper.cpp | 3 ++- src/surfacegraphics.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp index 853f79743..4b3656ee6 100644 --- a/src/resources/atlasmanager.cpp +++ b/src/resources/atlasmanager.cpp @@ -200,10 +200,6 @@ void AtlasManager::simpleSort(const std::string &name, SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) { -#ifdef USE_SDL2 - // +++ should be enabled after - return nullptr; -#else #if SDL_BYTEORDER == SDL_BIG_ENDIAN const int rmask = 0xff000000; const int gmask = 0x00ff0000; @@ -244,19 +240,22 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) if (image) { + if (image->mSDLSurface) + { #ifdef USE_SDL2 - SDL_SetSurfaceAlphaMod(image->mSDLSurface, 255); + SDL_SetSurfaceAlphaMod(image->mSDLSurface, SDL_ALPHA_OPAQUE); + SDL_SetSurfaceBlendMode (image->mSDLSurface, SDL_BLENDMODE_NONE); #else - SDL_SetAlpha(image->mSDLSurface, 0, SDL_ALPHA_OPAQUE); + SDL_SetAlpha(image->mSDLSurface, 0, SDL_ALPHA_OPAQUE); #endif - graphics->drawImage(image, item->x, item->y); + graphics->drawImage(image, item->x, item->y); + } } } delete graphics; atlas->surface = surface; return surface; -#endif } void AtlasManager::convertAtlas(TextureAtlas *const atlas) diff --git a/src/resources/sdl2imagehelper.cpp b/src/resources/sdl2imagehelper.cpp index acc72ce00..c5a75d236 100644 --- a/src/resources/sdl2imagehelper.cpp +++ b/src/resources/sdl2imagehelper.cpp @@ -137,7 +137,8 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const if (!tmpImage) return nullptr; - return new Image(tmpImage, false, nullptr); + SDL_Surface *image = convertTo32Bit(tmpImage); + return new Image(image, false, nullptr); } int SDLImageHelper::useOpenGL() const diff --git a/src/surfacegraphics.h b/src/surfacegraphics.h index 5cce65ddd..9ba2f183f 100644 --- a/src/surfacegraphics.h +++ b/src/surfacegraphics.h @@ -52,7 +52,7 @@ class SurfaceGraphics : public Graphics virtual ~SurfaceGraphics(); - void setWindow(SDL_Surface *const target) + void setTarget(SDL_Surface *const target) { mTarget = target; } SDL_Surface *getTarget() const -- cgit v1.2.3-60-g2f50