save and restore layers image when context is lost in Android

This commit is contained in:
2017-04-29 21:30:40 +01:00
parent 2e47ccb0c6
commit fa49d9ee09
17 changed files with 210 additions and 69 deletions

View File

@@ -27,6 +27,10 @@ Texture2D& TextureManager::get(uint16_t id)
void TextureManager::invalidate()
{
for (auto& t : m_textures)
{
t.second.destroy();
}
m_textures.clear();
}
@@ -37,6 +41,7 @@ bool Texture2D::create(int width, int height, GLint internal_format, GLint forma
m_format = format;
m_iformat = internal_format;
glGenTextures(1, &m_tex);
LOG("genTex %d", m_tex);
bind();
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, GL_UNSIGNED_BYTE, data);
unbind();
@@ -60,6 +65,7 @@ void Texture2D::assign(GLuint tex, int w/* = -1*/, int h/* = -1*/, GLuint intern
bool Texture2D::load(std::string filename)
{
LOG("load texture %s", filename.c_str());
ui::Image img;
if (!img.load(filename))
return false;