From 5883f4cc3fe5861c314afedb00c692f31f1a1124 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 12 Feb 2014 18:06:29 +0100 Subject: [PATCH] OPENGL/SDL: Default to RGBA8888 (memory layout). This makes sure the default mode also works for OpenGL ES contexts. --- .../graphics/openglsdl/openglsdl-graphics.cpp | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 6df67d0c1de5..9540a19e9e61 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -158,8 +158,18 @@ void OpenGLSdlGraphicsManager::resetGraphicsScale() { Common::List OpenGLSdlGraphicsManager::getSupportedFormats() const { Common::List formats; + // Our default mode is (memory layout wise) RGBA8888 which is a different + // logical layout depending on the endianness. We chose this mode because + // it is the only 32bit color mode we can safely assume to be present in + // OpenGL and OpenGL ES implementations. Thus, we need to supply different + // logical formats based on endianness. +#ifdef SCUMM_LITTLE_ENDIAN + // ABGR8888 + formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)); +#else // RGBA8888 formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); +#endif // RGB565 formats.push_back(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); // RGBA5551 @@ -168,6 +178,13 @@ Common::List OpenGLSdlGraphicsManager::getSupportedFormat formats.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0)); #ifndef USE_GLES +#ifdef SCUMM_LITTLE_ENDIAN + // RGBA8888 + formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); +#else + // ABGR8888 + formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)); +#endif // ARGB8888, this should not be here, but Sword25 requires it. :-/ formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)); @@ -327,7 +344,17 @@ bool OpenGLSdlGraphicsManager::setupMode(uint width, uint height) { } if (_hwScreen) { - const Graphics::PixelFormat rgba8888 = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0); + // This is pretty confusing since RGBA8888 talks about the memory + // layout here. This is a different logical layout depending on + // whether we run on little endian or big endian. However, we can + // only safely assume that RGBA8888 in memory layout is supported. + // Thus, we chose this one. + const Graphics::PixelFormat rgba8888 = +#ifdef SCUMM_LITTLE_ENDIAN + Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24); +#else + Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0); +#endif notifyContextCreate(rgba8888, rgba8888); setActualScreenSize(_hwScreen->w, _hwScreen->h); }