destroy all textures on window destruction and restore OpenGL objects when Android resumes the app
This commit is contained in:
@@ -16,6 +16,10 @@ public:
|
||||
bool m_locked = false;
|
||||
float m_opacity = 1.f;
|
||||
std::string m_name;
|
||||
struct Snapshot
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> image[6];
|
||||
};
|
||||
bool create(int width, int height, std::string name)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
@@ -44,6 +48,16 @@ public:
|
||||
// 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;
|
||||
}
|
||||
};
|
||||
|
||||
class Canvas
|
||||
@@ -78,6 +92,8 @@ public:
|
||||
Sampler m_sampler_bg;
|
||||
glm::vec2 m_cam_rot;
|
||||
float m_cam_fov = 85;
|
||||
|
||||
std::vector<Layer::Snapshot> m_layers_snapshot;
|
||||
|
||||
bool create(int width, int height);
|
||||
void resize(int width, int height);
|
||||
@@ -89,6 +105,8 @@ public:
|
||||
void stroke_end();
|
||||
void stroke_commit();
|
||||
void clear(const glm::vec4& color = { 1, 1, 1, 1 });
|
||||
void snapshot_save();
|
||||
void snapshot_restore();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user