Because in the past call texture->lock() will return unmodified
cached image (always bgra), now the image will be converted
dependently
This commit is contained in:
Benau 2017-01-08 13:31:10 +08:00
parent f609114594
commit 6f191bd7da
3 changed files with 27 additions and 6 deletions

View File

@ -167,11 +167,15 @@ void Skybox::generateCubeMapFromTextures()
img->copyToScaling(rgba[i], size, size);
#if defined(USE_GLES2)
for (unsigned int j = 0; j < size * size; j++)
if (CVS->isEXTTextureFormatBGRA8888Usable())
{
char tmp_val = rgba[i][j*4];
rgba[i][j*4] = rgba[i][j*4 + 2];
rgba[i][j*4 + 2] = tmp_val;
// BGRA image returned by getTextureImage causes black sky in gles
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

View File

@ -17,8 +17,11 @@
#ifndef SERVER_ONLY
#include "graphics/irr_driver.hpp"
#include "graphics/spherical_harmonics.hpp"
#if defined(USE_GLES2)
#include "graphics/central_settings.hpp"
#endif
#include "graphics/irr_driver.hpp"
#include "graphics/stk_texture.hpp"
#include "utils/log.hpp"
@ -410,6 +413,18 @@ void SphericalHarmonics::setTextures(const std::vector<video::ITexture *> &spher
(m_spherical_harmonics_textures[idx])->getTextureImage();
assert(img != NULL);
img->copyToScaling(sh_rgba[i], sh_w, sh_h);
#if defined(USE_GLES2)
if (!CVS->isEXTTextureFormatBGRA8888Usable())
{
// Code here assume color format is BGRA
for (unsigned int j = 0; j < sh_w * sh_h; j++)
{
char tmp_val = sh_rgba[i][j * 4];
sh_rgba[i][j * 4] = sh_rgba[i][j * 4 + 2];
sh_rgba[i][j * 4 + 2] = tmp_val;
}
}
#endif
} //for (unsigned i = 0; i < 6; i++)
Color *float_tex_cube[6];
@ -420,7 +435,7 @@ void SphericalHarmonics::setTextures(const std::vector<video::ITexture *> &spher
{
delete[] sh_rgba[i];
delete[] float_tex_cube[i];
}
}
} //setSphericalHarmonicsTextures
/** Compute spherical harmonics coefficients from ambient light */

View File

@ -28,7 +28,9 @@
#include <fstream>
#include <functional>
#if !defined(USE_GLES2)
static const uint8_t CACHE_VERSION = 1;
#endif
// ----------------------------------------------------------------------------
STKTexture::STKTexture(const std::string& path, bool srgb, bool premul_alpha,
bool set_material, bool mesh_tex, bool no_upload)