From 73de17afa821ccea84a119096b267e05a77db3ff Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Sun, 16 Apr 2017 14:44:15 +0200 Subject: Android progressbar fix (#5601) * Fix progressbar for Android Fixes #5599 Fixed #5403 * draw_load_screen: use texturesource this permits to unify texture loading code * scale progress bar * Add gl version check for GL_OES_texture_npot. This fixed the texture on loading screen * Remove two sanity checks pointed by @celeron55 * sfan5 comments + android ratio fixes --- src/client/tile.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/client') diff --git a/src/client/tile.cpp b/src/client/tile.cpp index 0aa06980c..509da3c92 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -790,8 +790,6 @@ void TextureSource::rebuildImagesAndTextures() video::IImage *img = generateImage(ti->name); #ifdef __ANDROID__ img = Align2Npot2(img, driver); - sanity_check(img->getDimension().Height == npot2(img->getDimension().Height)); - sanity_check(img->getDimension().Width == npot2(img->getDimension().Width)); #endif // Create texture from resulting image video::ITexture *t = NULL; @@ -1124,6 +1122,14 @@ video::IImage* TextureSource::generateImage(const std::string &name) * @param driver driver to use for image operations * @return image or copy of image aligned to npot2 */ + +inline u16 get_GL_major_version() +{ + const GLubyte *gl_version = glGetString(GL_VERSION); + std::string gl_ver((const char *)gl_version); + return (u16) (gl_version[0] - '0'); +} + video::IImage * Align2Npot2(video::IImage * image, video::IVideoDriver* driver) { @@ -1134,7 +1140,10 @@ video::IImage * Align2Npot2(video::IImage * image, core::dimension2d dim = image->getDimension(); std::string extensions = (char*) glGetString(GL_EXTENSIONS); - if (extensions.find("GL_OES_texture_npot") != std::string::npos) { + + // Only GLES2 is trusted to correctly report npot support + if (get_GL_major_version() > 1 && + extensions.find("GL_OES_texture_npot") != std::string::npos) { return image; } -- cgit v1.2.3