diff options
Diffstat (limited to 'backends/platform')
-rw-r--r-- | backends/platform/android/texture.cpp | 40 | ||||
-rw-r--r-- | backends/platform/android/texture.h | 1 |
2 files changed, 26 insertions, 15 deletions
diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index cb12d264b8..fb9f3bb913 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -109,14 +109,34 @@ void GLESTexture::release() { void GLESTexture::reinit() { GLCALL(glGenTextures(1, &_texture_name)); - // bypass allocBuffer() shortcut to reinit the texture properly - _texture_width = 0; - _texture_height = 0; + if (paletteSize()) { + // paletted textures are in a local buffer, don't wipe it + initSize(); + } else { + // bypass allocBuffer() shortcut to reinit the texture properly + _texture_width = 0; + _texture_height = 0; + + allocBuffer(_surface.w, _surface.h); + } - allocBuffer(_surface.w, _surface.h); setDirty(); } +void GLESTexture::initSize() { + // Allocate room for the texture now, but pixel data gets uploaded + // later (perhaps with multiple TexSubImage2D operations). + GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name)); + GLCALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); + GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)); + GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); + GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); + GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); + GLCALL(glTexImage2D(GL_TEXTURE_2D, 0, glFormat(), + _texture_width, _texture_height, + 0, glFormat(), glType(), 0)); +} + void GLESTexture::allocBuffer(GLuint w, GLuint h) { int bpp = bytesPerPixel(); _surface.w = w; @@ -137,17 +157,7 @@ void GLESTexture::allocBuffer(GLuint w, GLuint h) { _surface.pitch = _texture_width * bpp; - // Allocate room for the texture now, but pixel data gets uploaded - // later (perhaps with multiple TexSubImage2D operations). - GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name)); - GLCALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); - GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)); - GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); - GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); - GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); - GLCALL(glTexImage2D(GL_TEXTURE_2D, 0, glFormat(), - _texture_width, _texture_height, - 0, glFormat(), glType(), 0)); + initSize(); } void GLESTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h, diff --git a/backends/platform/android/texture.h b/backends/platform/android/texture.h index f1d5cad6e9..cc1f4e3dae 100644 --- a/backends/platform/android/texture.h +++ b/backends/platform/android/texture.h @@ -44,6 +44,7 @@ public: void release(); void reinit(); + void initSize(); virtual void allocBuffer(GLuint width, GLuint height); |