save and restore layers image when context is lost in Android
This commit is contained in:
@@ -30,11 +30,12 @@ void RTT::destroy()
|
||||
{
|
||||
unbindFramebuffer();
|
||||
glDeleteFramebuffers(1, &fboID);
|
||||
LOG("RTT DESTROY %d", fboID);
|
||||
}
|
||||
fboID = 0;
|
||||
rboID = 0;
|
||||
w = 0;
|
||||
h = 0;
|
||||
// w = 0;
|
||||
// h = 0;
|
||||
}
|
||||
|
||||
bool RTT::create(int width, int height, int tex/* = -1*/)
|
||||
@@ -74,6 +75,7 @@ bool RTT::create(int width, int height, int tex/* = -1*/)
|
||||
// Create a framebuffer object
|
||||
glGenFramebuffers(1, &fboID);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fboID);
|
||||
LOG("RTT CREATE %d - tex %d", fboID, texID);
|
||||
|
||||
// Attach the texture to FBO color attachment point
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texID, 0);
|
||||
@@ -136,10 +138,12 @@ void RTT::clear(glm::vec4 color)
|
||||
|
||||
void RTT::readTextureData(uint8_t* buffer)
|
||||
{
|
||||
bindTexture();
|
||||
glReadBuffer(GL_BACK);
|
||||
bindFramebuffer();
|
||||
//glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer);
|
||||
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, buffer);
|
||||
unbindTexture();
|
||||
glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||
unbindFramebuffer();
|
||||
glReadBuffer(GL_NONE);
|
||||
}
|
||||
|
||||
uint8_t* RTT::createBuffer()
|
||||
|
||||
Reference in New Issue
Block a user