diff --git a/data/CREDITS b/data/CREDITS index d12f77486..1307b2ce0 100755 Binary files a/data/CREDITS and b/data/CREDITS differ diff --git a/data/gui/License.txt b/data/gui/License.txt index c6f1edb3c..0b57b1285 100644 --- a/data/gui/License.txt +++ b/data/gui/License.txt @@ -12,6 +12,8 @@ mode_tt, released under Creative-Commons BY-SA 3, incorporatings artwork from ye mode_easter, mode_ftl, mode_soccer, mode_normal, race_giveup: by Totoplus62, released under CC-BY-SA 3.0 +soccer balls released under CC-BY-SA 3.0 by Néd J. Édoire + tutorial.png by Totoplus62, released under CC-BY-SA 3.0 Logo and Logo_slim : under CC-BY-SA 3.0+ by 'rastapax' diff --git a/data/gui/soccer_ball_blue.png b/data/gui/soccer_ball_blue.png index 8c440784b..9ce6823c2 100644 Binary files a/data/gui/soccer_ball_blue.png and b/data/gui/soccer_ball_blue.png differ diff --git a/data/gui/soccer_ball_normal.png b/data/gui/soccer_ball_normal.png index 339cf26a4..ab2a1d255 100644 Binary files a/data/gui/soccer_ball_normal.png and b/data/gui/soccer_ball_normal.png differ diff --git a/data/gui/soccer_ball_red.png b/data/gui/soccer_ball_red.png index c490d53f5..377ba5ff6 100644 Binary files a/data/gui/soccer_ball_red.png and b/data/gui/soccer_ball_red.png differ diff --git a/data/shaders/IBL.frag b/data/shaders/IBL.frag index cadb675c1..7d3eb2efa 100644 --- a/data/shaders/IBL.frag +++ b/data/shaders/IBL.frag @@ -1,8 +1,13 @@ uniform sampler2D ntex; uniform sampler2D dtex; +#ifdef GL_ES +layout (location = 0) out vec4 Diff; +layout (location = 1) out vec4 Spec; +#else out vec4 Diff; out vec4 Spec; +#endif #stk_include "utils/decodeNormal.frag" #stk_include "utils/getPosFromUVDepth.frag" diff --git a/data/shaders/degraded_ibl.frag b/data/shaders/degraded_ibl.frag index 05e10c942..be359f04d 100644 --- a/data/shaders/degraded_ibl.frag +++ b/data/shaders/degraded_ibl.frag @@ -1,7 +1,12 @@ uniform sampler2D ntex; +#ifdef GL_ES +layout (location = 0) out vec4 Diff; +layout (location = 1) out vec4 Spec; +#else out vec4 Diff; out vec4 Spec; +#endif #stk_include "utils/decodeNormal.frag" #stk_include "utils/getPosFromUVDepth.frag" diff --git a/data/shaders/pointlight.frag b/data/shaders/pointlight.frag index b49e7b816..294065be6 100644 --- a/data/shaders/pointlight.frag +++ b/data/shaders/pointlight.frag @@ -6,8 +6,13 @@ flat in float energy; flat in vec3 col; flat in float radius; +#ifdef GL_ES +layout (location = 0) out vec4 Diff; +layout (location = 1) out vec4 Spec; +#else out vec4 Diff; out vec4 Spec; +#endif #stk_include "utils/decodeNormal.frag" #stk_include "utils/SpecularBRDF.frag" diff --git a/data/shaders/sunlight.frag b/data/shaders/sunlight.frag index 32453ec56..36da04623 100644 --- a/data/shaders/sunlight.frag +++ b/data/shaders/sunlight.frag @@ -1,8 +1,13 @@ uniform sampler2D ntex; uniform sampler2D dtex; +#ifdef GL_ES +layout (location = 0) out vec4 Diff; +layout (location = 1) out vec4 Spec; +#else out vec4 Diff; out vec4 Spec; +#endif #stk_include "utils/decodeNormal.frag" #stk_include "utils/SpecularBRDF.frag" diff --git a/data/shaders/sunlightshadow.frag b/data/shaders/sunlightshadow.frag index ed35dff62..df86d2258 100644 --- a/data/shaders/sunlightshadow.frag +++ b/data/shaders/sunlightshadow.frag @@ -9,8 +9,13 @@ uniform float splitmax; uniform float shadow_res; in vec2 uv; +#ifdef GL_ES +layout (location = 0) out vec4 Diff; +layout (location = 1) out vec4 Spec; +#else out vec4 Diff; out vec4 Spec; +#endif #stk_include "utils/decodeNormal.frag" #stk_include "utils/SpecularBRDF.frag" diff --git a/data/shaders/sunlightshadowesm.frag b/data/shaders/sunlightshadowesm.frag index 8ac2a4235..4a0ca1c7d 100644 --- a/data/shaders/sunlightshadowesm.frag +++ b/data/shaders/sunlightshadowesm.frag @@ -8,8 +8,13 @@ uniform float split2; uniform float splitmax; in vec2 uv; +#ifdef GL_ES +layout (location = 0) out vec4 Diff; +layout (location = 1) out vec4 Spec; +#else out vec4 Diff; out vec4 Spec; +#endif #stk_include "utils/decodeNormal.frag" #stk_include "utils/SpecularBRDF.frag" diff --git a/src/graphics/central_settings.cpp b/src/graphics/central_settings.cpp index 13c743d28..3712cf008 100644 --- a/src/graphics/central_settings.cpp +++ b/src/graphics/central_settings.cpp @@ -49,6 +49,10 @@ void CentralVideoSettings::init() hasUBO = false; hasExplicitAttribLocation = false; hasGS = false; + +#if defined(USE_GLES2) + hasBGRA = false; +#endif m_GI_has_artifact = false; m_need_rh_workaround = false; @@ -218,6 +222,15 @@ void CentralVideoSettings::init() hasAtomics = true; hasSSBO = true; } + + if (!GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_TEXTURE_FORMAT_BGRA8888) && + (hasGLExtension("GL_IMG_texture_format_BGRA8888") || + hasGLExtension("GL_EXT_texture_format_BGRA8888"))) + { + hasBGRA = true; + Log::info("GLDriver", "EXT texture format BGRA8888 Present"); + } + #endif } } @@ -337,6 +350,13 @@ bool CentralVideoSettings::isARBMultiDrawIndirectUsable() const return hasMultiDrawIndirect; } +#if defined(USE_GLES2) +bool CentralVideoSettings::isEXTTextureFormatBGRA8888Usable() const +{ + return hasBGRA; +} +#endif + bool CentralVideoSettings::supportsShadows() const { return isARBGeometryShadersUsable() && isARBUniformBufferObjectUsable() && isARBExplicitAttribLocationUsable(); diff --git a/src/graphics/central_settings.hpp b/src/graphics/central_settings.hpp index 059840ebf..3553d7775 100644 --- a/src/graphics/central_settings.hpp +++ b/src/graphics/central_settings.hpp @@ -42,6 +42,10 @@ private: bool hasSSBO; bool hasImageLoadStore; bool hasMultiDrawIndirect; + +#if defined(USE_GLES2) + bool hasBGRA; +#endif bool m_need_rh_workaround; bool m_need_srgb_workaround; @@ -75,6 +79,10 @@ public: bool isARBImageLoadStoreUsable() const; bool isARBMultiDrawIndirectUsable() const; bool isARBExplicitAttribLocationUsable() const; + +#if defined(USE_GLES2) + bool isEXTTextureFormatBGRA8888Usable() const; +#endif // Are all required extensions available for feature support diff --git a/src/graphics/graphics_restrictions.cpp b/src/graphics/graphics_restrictions.cpp index cf624eafd..d660748b5 100644 --- a/src/graphics/graphics_restrictions.cpp +++ b/src/graphics/graphics_restrictions.cpp @@ -57,6 +57,9 @@ namespace GraphicsRestrictions "TextureCompressionS3TC", "AMDVertexShaderLayer", "ExplicitAttribLocation", +#if defined(USE_GLES2) + "TextureFormatBGRA8888", +#endif "DriverRecentEnough", "HighDefinitionTextures", "AdvancedPipeline", diff --git a/src/graphics/graphics_restrictions.hpp b/src/graphics/graphics_restrictions.hpp index 0f0038459..c17acf466 100644 --- a/src/graphics/graphics_restrictions.hpp +++ b/src/graphics/graphics_restrictions.hpp @@ -51,6 +51,9 @@ namespace GraphicsRestrictions GR_EXT_TEXTURE_COMPRESSION_S3TC, GR_AMD_VERTEX_SHADER_LAYER, GR_EXPLICIT_ATTRIB_LOCATION, +#if defined(USE_GLES2) + GR_TEXTURE_FORMAT_BGRA8888, +#endif GR_DRIVER_RECENT_ENOUGH, GR_HIGHDEFINITION_TEXTURES, GR_ADVANCED_PIPELINE, diff --git a/src/graphics/irr_driver.hpp b/src/graphics/irr_driver.hpp index 4927a993b..08bac725b 100644 --- a/src/graphics/irr_driver.hpp +++ b/src/graphics/irr_driver.hpp @@ -102,7 +102,9 @@ enum TypeFBO FBO_EIGHTH2, FBO_DISPLACE, FBO_BLOOM_1024, +#if !defined(USE_GLES2) FBO_SCALAR_1024, +#endif FBO_BLOOM_512, FBO_TMP_512, FBO_LENS_512, @@ -164,7 +166,9 @@ enum TypeRTT RTT_MLAA_TMP, RTT_BLOOM_1024, +#if !defined(USE_GLES2) RTT_SCALAR_1024, +#endif RTT_BLOOM_512, RTT_TMP_512, RTT_LENS_512, diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index 3ef16eefc..68e2c8cf2 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -431,8 +431,10 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po { PROFILER_PUSH_CPU_MARKER("- SSAO", 0xFF, 0xFF, 0x00); ScopedGPUTimer Timer(getGPUTimer(Q_SSAO)); + #if !defined(USE_GLES2) if (UserConfigParams::m_ssao) renderSSAO(); + #endif PROFILER_POP_CPU_MARKER(); } diff --git a/src/graphics/rtts.cpp b/src/graphics/rtts.cpp index 8fbe8b11d..f0c9bbd94 100644 --- a/src/graphics/rtts.cpp +++ b/src/graphics/rtts.cpp @@ -78,45 +78,67 @@ RTT::RTT(size_t width, size_t height) // All RTTs are currently RGBA16F mostly with stencil. The four tmp RTTs are the same size // as the screen, for use in post-processing. + +#if !defined(USE_GLES2) + GLint rgba_internal_format = GL_RGBA16F; + GLint rgba_format = GL_BGRA; + GLint red_internal_format = GL_R16F; + GLint red32_internal_format = GL_R32F; + GLint red_format = GL_RED; + GLint rgb_format = GL_BGR; + GLint diffuse_specular_internal_format = GL_R11F_G11F_B10F; + GLint type = GL_FLOAT; +#else + GLint rgba_internal_format = GL_RGBA8; + GLint rgba_format = GL_RGBA; + GLint red_internal_format = GL_R8; + GLint red32_internal_format = GL_R8; + GLint red_format = GL_RED; + GLint rgb_format = GL_RGB; + GLint diffuse_specular_internal_format = GL_RGBA8; + GLint type = GL_UNSIGNED_BYTE; +#endif - RenderTargetTextures[RTT_TMP1] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT); - RenderTargetTextures[RTT_TMP2] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT); - RenderTargetTextures[RTT_TMP3] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT); - RenderTargetTextures[RTT_TMP4] = generateRTT(res, GL_R16F, GL_RED, GL_FLOAT); - RenderTargetTextures[RTT_LINEAR_DEPTH] = generateRTT(res, GL_R32F, GL_RED, GL_FLOAT, linear_depth_mip_levels); - RenderTargetTextures[RTT_NORMAL_AND_DEPTH] = generateRTT(res, GL_RGBA16F, GL_RGBA, GL_FLOAT); - RenderTargetTextures[RTT_COLOR] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT); - RenderTargetTextures[RTT_MLAA_COLORS] = generateRTT(res, GL_SRGB8_ALPHA8, GL_BGR, GL_UNSIGNED_BYTE); - RenderTargetTextures[RTT_MLAA_TMP] = generateRTT(res, GL_SRGB8_ALPHA8, GL_BGR, GL_UNSIGNED_BYTE); - RenderTargetTextures[RTT_MLAA_BLEND] = generateRTT(res, GL_SRGB8_ALPHA8, GL_BGR, GL_UNSIGNED_BYTE); - RenderTargetTextures[RTT_SSAO] = generateRTT(res, GL_R16F, GL_RED, GL_FLOAT); - RenderTargetTextures[RTT_DISPLACE] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT); - RenderTargetTextures[RTT_DIFFUSE] = generateRTT(res, GL_R11F_G11F_B10F, GL_BGR, GL_FLOAT); - RenderTargetTextures[RTT_SPECULAR] = generateRTT(res, GL_R11F_G11F_B10F, GL_BGR, GL_FLOAT); + RenderTargetTextures[RTT_TMP1] = generateRTT(res, rgba_internal_format, rgba_format, type); + RenderTargetTextures[RTT_TMP2] = generateRTT(res, rgba_internal_format, rgba_format, type); + RenderTargetTextures[RTT_TMP3] = generateRTT(res, rgba_internal_format, rgba_format, type); + RenderTargetTextures[RTT_TMP4] = generateRTT(res, red_internal_format, red_format, type); + RenderTargetTextures[RTT_LINEAR_DEPTH] = generateRTT(res, red32_internal_format, red_format, type, linear_depth_mip_levels); + RenderTargetTextures[RTT_NORMAL_AND_DEPTH] = generateRTT(res, rgba_internal_format, GL_RGBA, type); + RenderTargetTextures[RTT_COLOR] = generateRTT(res, rgba_internal_format, rgba_format, type); + RenderTargetTextures[RTT_MLAA_COLORS] = generateRTT(res, GL_SRGB8_ALPHA8, rgb_format, GL_UNSIGNED_BYTE); + RenderTargetTextures[RTT_MLAA_TMP] = generateRTT(res, GL_SRGB8_ALPHA8, rgb_format, GL_UNSIGNED_BYTE); + RenderTargetTextures[RTT_MLAA_BLEND] = generateRTT(res, GL_SRGB8_ALPHA8, rgb_format, GL_UNSIGNED_BYTE); + RenderTargetTextures[RTT_SSAO] = generateRTT(res, red_internal_format, red_format, type); + RenderTargetTextures[RTT_DISPLACE] = generateRTT(res, rgba_internal_format, rgba_format, type); + RenderTargetTextures[RTT_DIFFUSE] = generateRTT(res, diffuse_specular_internal_format, rgb_format, type); + RenderTargetTextures[RTT_SPECULAR] = generateRTT(res, diffuse_specular_internal_format, rgb_format, type); - RenderTargetTextures[RTT_HALF1] = generateRTT(half, GL_RGBA16F, GL_BGRA, GL_FLOAT); - RenderTargetTextures[RTT_QUARTER1] = generateRTT(quarter, GL_RGBA16F, GL_BGRA, GL_FLOAT); - RenderTargetTextures[RTT_EIGHTH1] = generateRTT(eighth, GL_RGBA16F, GL_BGRA, GL_FLOAT); - RenderTargetTextures[RTT_HALF1_R] = generateRTT(half, GL_R16F, GL_RED, GL_FLOAT); + RenderTargetTextures[RTT_HALF1] = generateRTT(half, rgba_internal_format, rgba_format, type); + RenderTargetTextures[RTT_QUARTER1] = generateRTT(quarter, rgba_internal_format, rgba_format, type); + RenderTargetTextures[RTT_EIGHTH1] = generateRTT(eighth, rgba_internal_format, rgba_format, type); + RenderTargetTextures[RTT_HALF1_R] = generateRTT(half, red_internal_format, red_format, type); - RenderTargetTextures[RTT_HALF2] = generateRTT(half, GL_RGBA16F, GL_BGRA, GL_FLOAT); - RenderTargetTextures[RTT_QUARTER2] = generateRTT(quarter, GL_RGBA16F, GL_BGRA, GL_FLOAT); - RenderTargetTextures[RTT_EIGHTH2] = generateRTT(eighth, GL_RGBA16F, GL_BGRA, GL_FLOAT); - RenderTargetTextures[RTT_HALF2_R] = generateRTT(half, GL_R16F, GL_RED, GL_FLOAT); + RenderTargetTextures[RTT_HALF2] = generateRTT(half, rgba_internal_format, rgba_format, type); + RenderTargetTextures[RTT_QUARTER2] = generateRTT(quarter, rgba_internal_format, rgba_format, type); + RenderTargetTextures[RTT_EIGHTH2] = generateRTT(eighth, rgba_internal_format, rgba_format, type); + RenderTargetTextures[RTT_HALF2_R] = generateRTT(half, red_internal_format, red_format, type); - RenderTargetTextures[RTT_BLOOM_1024] = generateRTT(shadowsize0, GL_RGBA16F, GL_BGR, GL_FLOAT); - RenderTargetTextures[RTT_SCALAR_1024] = generateRTT(shadowsize0, GL_R32F, GL_RED, GL_FLOAT); - RenderTargetTextures[RTT_BLOOM_512] = generateRTT(shadowsize1, GL_RGBA16F, GL_BGR, GL_FLOAT); - RenderTargetTextures[RTT_TMP_512] = generateRTT(shadowsize1, GL_RGBA16F, GL_BGR, GL_FLOAT); - RenderTargetTextures[RTT_LENS_512] = generateRTT(shadowsize1, GL_RGBA16F, GL_BGR, GL_FLOAT); + RenderTargetTextures[RTT_BLOOM_1024] = generateRTT(shadowsize0, rgba_internal_format, rgb_format, type); +#if !defined(USE_GLES2) + RenderTargetTextures[RTT_SCALAR_1024] = generateRTT(shadowsize0, red32_internal_format, red_format, type); +#endif + RenderTargetTextures[RTT_BLOOM_512] = generateRTT(shadowsize1, rgba_internal_format, rgb_format, type); + RenderTargetTextures[RTT_TMP_512] = generateRTT(shadowsize1, rgba_internal_format, rgb_format, type); + RenderTargetTextures[RTT_LENS_512] = generateRTT(shadowsize1, rgba_internal_format, rgb_format, type); - RenderTargetTextures[RTT_BLOOM_256] = generateRTT(shadowsize2, GL_RGBA16F, GL_BGR, GL_FLOAT); - RenderTargetTextures[RTT_TMP_256] = generateRTT(shadowsize2, GL_RGBA16F, GL_BGR, GL_FLOAT); - RenderTargetTextures[RTT_LENS_256] = generateRTT(shadowsize2, GL_RGBA16F, GL_BGR, GL_FLOAT); + RenderTargetTextures[RTT_BLOOM_256] = generateRTT(shadowsize2, rgba_internal_format, rgb_format, type); + RenderTargetTextures[RTT_TMP_256] = generateRTT(shadowsize2, rgba_internal_format, rgb_format, type); + RenderTargetTextures[RTT_LENS_256] = generateRTT(shadowsize2, rgba_internal_format, rgb_format, type); - RenderTargetTextures[RTT_BLOOM_128] = generateRTT(shadowsize3, GL_RGBA16F, GL_BGR, GL_FLOAT); - RenderTargetTextures[RTT_TMP_128] = generateRTT(shadowsize3, GL_RGBA16F, GL_BGR, GL_FLOAT); - RenderTargetTextures[RTT_LENS_128] = generateRTT(shadowsize3, GL_RGBA16F, GL_BGR, GL_FLOAT); + RenderTargetTextures[RTT_BLOOM_128] = generateRTT(shadowsize3, rgba_internal_format, rgb_format, type); + RenderTargetTextures[RTT_TMP_128] = generateRTT(shadowsize3, rgba_internal_format, rgb_format, type); + RenderTargetTextures[RTT_LENS_128] = generateRTT(shadowsize3, rgba_internal_format, rgb_format, type); std::vector somevector; somevector.push_back(RenderTargetTextures[RTT_SSAO]); @@ -191,9 +213,11 @@ RTT::RTT(size_t width, size_t height) somevector.push_back(RenderTargetTextures[RTT_BLOOM_1024]); FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize0.Width, shadowsize0.Height)); somevector.clear(); +#if !defined(USE_GLES2) somevector.push_back(RenderTargetTextures[RTT_SCALAR_1024]); FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize0.Width, shadowsize0.Height)); somevector.clear(); +#endif somevector.push_back(RenderTargetTextures[RTT_BLOOM_512]); FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize1.Width, shadowsize1.Height)); diff --git a/src/graphics/shader.cpp b/src/graphics/shader.cpp index 306561d15..408248dd6 100644 --- a/src/graphics/shader.cpp +++ b/src/graphics/shader.cpp @@ -107,11 +107,17 @@ GLuint ShaderBase::loadShader(const std::string &file, unsigned type) if (CVS->needsRGBBindlessWorkaround()) code << "#define SRGBBindlessFix\n"; +#if !defined(USE_GLES2) //shader compilation fails with some drivers if there is no precision qualifier if (type == GL_FRAGMENT_SHADER) code << "precision mediump float;\n"; -#if defined(USE_GLES2) - else if (type == GL_VERTEX_SHADER) +#else + int range[2], precision; + glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, range, &precision); + + if (precision > 0) + code << "precision highp float;\n"; + else code << "precision mediump float;\n"; #endif diff --git a/src/graphics/skybox.cpp b/src/graphics/skybox.cpp index cf51bc70c..07d90f719 100644 --- a/src/graphics/skybox.cpp +++ b/src/graphics/skybox.cpp @@ -170,6 +170,15 @@ void Skybox::generateCubeMapFromTextures() image->copyToScaling(rgba[i], size, size); image->drop(); +#if defined(USE_GLES2) + for (unsigned int j = 0; j < size * size; j++) + { + char tmp_val = rgba[i][j*4]; + rgba[i][j*4] = rgba[i][j*4 + 2]; + rgba[i][j*4 + 2] = tmp_val; + } +#endif + if (i == 2 || i == 3) { char *tmp = new char[size * size * 4]; @@ -188,15 +197,14 @@ void Skybox::generateCubeMapFromTextures() #if !defined(USE_GLES2) GLint internal_format = CVS->isTextureCompressionEnabled() ? GL_COMPRESSED_SRGB_ALPHA : GL_SRGB_ALPHA; + GLint format = GL_BGRA; #else - // The GL_SRGB_ALPHA_EXT and GL_SRGB8_ALPHA8 formats are available in - // OpenGL ES, but they produce black texture for some reason. - // The basic GL_RGBA format works fine though. - GLint internal_format = GL_RGBA; + GLint internal_format = GL_RGBA8; + GLint format = GL_RGBA; #endif glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, - internal_format, size, size, 0, GL_BGRA, + internal_format, size, size, 0, format, GL_UNSIGNED_BYTE, (GLvoid*)rgba[i]); } glGenerateMipmap(GL_TEXTURE_CUBE_MAP); @@ -213,8 +221,13 @@ void Skybox::generateSpecularCubemap() size_t cubemap_size = 256; for (int i = 0; i < 6; i++) { +#if !defined(USE_GLES2) glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA16F, cubemap_size, cubemap_size, 0, GL_BGRA, GL_FLOAT, 0); +#else + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA8, + cubemap_size, cubemap_size, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); +#endif } glGenerateMipmap(GL_TEXTURE_CUBE_MAP); diff --git a/src/graphics/texture_manager.cpp b/src/graphics/texture_manager.cpp index 4ddc71cf2..5b823cf72 100644 --- a/src/graphics/texture_manager.cpp +++ b/src/graphics/texture_manager.cpp @@ -34,6 +34,8 @@ GLuint getTextureGLuint(irr::video::ITexture *tex) { + if (tex == NULL) + return 0; #if defined(USE_GLES2) return static_cast(tex)->getOpenGLTextureName(); #else @@ -87,10 +89,20 @@ void compressTexture(irr::video::ITexture *tex, bool srgb, bool premul_alpha) memcpy(data, tex->lock(), w * h * 4); tex->unlock(); unsigned internalFormat, Format; - if (tex->hasAlpha()) - Format = GL_BGRA; - else - Format = GL_BGR; + Format = tex->hasAlpha() ? GL_BGRA : GL_BGR; +#if defined(USE_GLES2) + if (!CVS->isEXTTextureFormatBGRA8888Usable()) + { + Format = tex->hasAlpha() ? GL_RGBA : GL_RGB; + + for (unsigned int i = 0; i < w * h; i++) + { + char tmp_val = data[i*4]; + data[i*4] = data[i*4 + 2]; + data[i*4 + 2] = tmp_val; + } + } +#endif if (premul_alpha) {