diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/config.h.cmake | 5 | ||||
-rw-r--r-- | src/common/global.h | 3 | ||||
-rw-r--r-- | src/common/image.cpp | 30 | ||||
-rw-r--r-- | src/common/image.h | 6 |
4 files changed, 38 insertions, 6 deletions
diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake index 2f403fa..63cd93b 100644 --- a/src/common/config.h.cmake +++ b/src/common/config.h.cmake @@ -6,6 +6,11 @@ #cmakedefine PLATFORM_MACOSX @PLATFORM_MACOSX@ #cmakedefine PLATFORM_OTHER @PLATFORM_OTHER@ +#ifdef PLATFORM_MACOSX +// Assume we have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework +#define HAVE_CFLOCALECOPYCURRENT 1 +#endif + #cmakedefine GLEW_STATIC #cmakedefine OPENAL_SOUND diff --git a/src/common/global.h b/src/common/global.h index a322057..da62bac 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -173,7 +173,8 @@ enum Language LANGUAGE_ENGLISH = 0, LANGUAGE_FRENCH = 1, LANGUAGE_GERMAN = 2, - LANGUAGE_POLISH = 3 + LANGUAGE_POLISH = 3, + LANGUAGE_RUSSIAN = 4 }; /** diff --git a/src/common/image.cpp b/src/common/image.cpp index a9587ef..8a876e3 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -218,15 +218,30 @@ void CImage::PadToNearestPowerOfTwo() int w = Math::NextPowerOfTwo(m_data->surface->w); int h = Math::NextPowerOfTwo(m_data->surface->h); + BlitToNewRGBASurface(w, h); +} + +void CImage::ConvertToRGBA() +{ + assert(m_data != nullptr); + + int w = m_data->surface->w; + int h = m_data->surface->h; + + BlitToNewRGBASurface(w, h); +} + +void CImage::BlitToNewRGBASurface(int width, int height) +{ m_data->surface->flags &= (~SDL_SRCALPHA); - SDL_Surface* resizedSurface = SDL_CreateRGBSurface(0, w, h, 32, 0x00ff0000, 0x0000ff00, - 0x000000ff, 0xff000000); - assert(resizedSurface != NULL); - SDL_BlitSurface(m_data->surface, NULL, resizedSurface, NULL); + SDL_Surface* convertedSurface = SDL_CreateRGBSurface(0, width, height, 32, 0x00FF0000, 0x0000FF00, + 0x000000FF, 0xFF000000); + assert(convertedSurface != nullptr); + SDL_BlitSurface(m_data->surface, nullptr, convertedSurface, nullptr); SDL_FreeSurface(m_data->surface); - m_data->surface = resizedSurface; + m_data->surface = convertedSurface; } /** @@ -376,6 +391,11 @@ bool CImage::Load(const std::string& fileName) return false; } + if (m_data->surface->format->palette != nullptr) + { + ConvertToRGBA(); + } + return true; } diff --git a/src/common/image.h b/src/common/image.h index 44aedf1..31dab2d 100644 --- a/src/common/image.h +++ b/src/common/image.h @@ -97,6 +97,9 @@ public: //! Pads the image to nearest power of 2 dimensions void PadToNearestPowerOfTwo(); + //! Convert the image to RGBA surface + void ConvertToRGBA(); + //! Loads an image from the specified file bool Load(const std::string &fileName); @@ -107,6 +110,9 @@ public: std::string GetError(); private: + //! Blit to new RGBA surface with given size + void BlitToNewRGBASurface(int width, int height); + //! Last encountered error std::string m_error; //! Image data |