summaryrefslogtreecommitdiff
path: root/src/resources/sdlimagehelper.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-21 14:37:03 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-24 21:08:14 +0300
commitec1beaa2ee07368368e9bd45fe400eedc57419eb (patch)
treec8f4792dc2316c7cc852bcf6738dff7557d9b872 /src/resources/sdlimagehelper.cpp
parent8d4af08b165e10d7e82380074ce733ee9d068c6a (diff)
downloadmv-ec1beaa2ee07368368e9bd45fe400eedc57419eb.tar.gz
mv-ec1beaa2ee07368368e9bd45fe400eedc57419eb.tar.bz2
mv-ec1beaa2ee07368368e9bd45fe400eedc57419eb.tar.xz
mv-ec1beaa2ee07368368e9bd45fe400eedc57419eb.zip
first part of fixes for compilation with SDL2
Diffstat (limited to 'src/resources/sdlimagehelper.cpp')
-rw-r--r--src/resources/sdlimagehelper.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp
index ab0b0663b..8f9d8b396 100644
--- a/src/resources/sdlimagehelper.cpp
+++ b/src/resources/sdlimagehelper.cpp
@@ -51,8 +51,10 @@ Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye) const
rgba.palette = nullptr;
rgba.BitsPerPixel = 32;
rgba.BytesPerPixel = 4;
+#ifndef USE_SDL2
rgba.colorkey = 0;
rgba.alpha = 255;
+#endif
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rgba.Rmask = 0x000000FF;
@@ -117,6 +119,10 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
Image *img;
bool hasAlpha = false;
+#ifdef USE_SDL2
+ uint8_t *alphaChannel = nullptr;
+ SDL_Surface *image = SDLDuplicateSurface(tmpImage);
+#else
const int sz = tmpImage->w * tmpImage->h;
// The alpha channel to be filled with alpha values
@@ -170,6 +176,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
delete [] alphaChannel;
return nullptr;
}
+#endif
img = new Image(image, hasAlpha, alphaChannel);
img->mAlpha = alpha;
@@ -190,6 +197,10 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const
return nullptr;
bool hasAlpha = false;
+#ifdef USE_SDL2
+ uint8_t *alphaChannel = nullptr;
+ SDL_Surface *image = tmpImage;
+#else
bool converted = false;
if (tmpImage->format->BitsPerPixel != 32)
@@ -269,7 +280,7 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const
if (converted)
SDL_FreeSurface(tmpImage);
-
+#endif
return new Image(image, hasAlpha, alphaChannel);
}