save and restore layers image when context is lost in Android
This commit is contained in:
@@ -20,44 +20,11 @@ public:
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> image[6];
|
||||
};
|
||||
bool create(int width, int height, std::string name)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
m_rtt[i].create(width, height);
|
||||
m_rtt[i].bindFramebuffer();
|
||||
m_rtt[i].clear();
|
||||
m_rtt[i].unbindFramebuffer();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void clear(const glm::vec4& c)
|
||||
{
|
||||
// push clear color state
|
||||
GLfloat cc[4];
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, cc);
|
||||
glClearColor(c.r, c.g, c.b, c.a);
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
m_rtt[i].bindFramebuffer();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
m_rtt[i].unbindFramebuffer();
|
||||
}
|
||||
|
||||
// restore clear color state
|
||||
glClearColor(cc[0], cc[1], cc[2], cc[3]);
|
||||
}
|
||||
Snapshot snapshot()
|
||||
{
|
||||
Snapshot snap;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
snap.image[i] = std::make_unique<uint8_t[]>(m_rtt[i].bytes());
|
||||
m_rtt[i].readTextureData(snap.image[i].get());
|
||||
}
|
||||
return snap;
|
||||
}
|
||||
bool create(int width, int height, std::string name);
|
||||
void clear(const glm::vec4& c);
|
||||
Snapshot snapshot(std::string data_path);
|
||||
void restore(const Snapshot& snap);
|
||||
void destroy();
|
||||
};
|
||||
|
||||
class Canvas
|
||||
@@ -105,8 +72,9 @@ public:
|
||||
void stroke_end();
|
||||
void stroke_commit();
|
||||
void clear(const glm::vec4& color = { 1, 1, 1, 1 });
|
||||
void snapshot_save();
|
||||
void snapshot_save(std::string data_path);
|
||||
void snapshot_restore();
|
||||
void clear_context();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user