destroy all textures on window destruction and restore OpenGL objects when Android resumes the app
This commit is contained in:
@@ -92,6 +92,7 @@ class LayoutManager
|
||||
std::string m_path;
|
||||
struct stat m_file_info { 0 };
|
||||
public:
|
||||
bool m_loaded = false;
|
||||
std::function<void()> on_loaded;
|
||||
bool load(const char* path);
|
||||
bool reload();
|
||||
@@ -218,6 +219,13 @@ public:
|
||||
return o;
|
||||
}
|
||||
|
||||
virtual void restore_context()
|
||||
{
|
||||
for (auto& c : m_children)
|
||||
{
|
||||
c->restore_context();
|
||||
}
|
||||
};
|
||||
void update(float width, float height, float zoom);
|
||||
void update();
|
||||
void update_internal(const glm::vec2& origin, const glm::mat4& proj);
|
||||
@@ -275,39 +283,6 @@ public:
|
||||
void mouse_release() { root()->current_mouse_capture = nullptr; m_mouse_captured = false; }
|
||||
void key_capture() { root()->current_key_capture = this; m_key_captured = true; }
|
||||
void key_release() { root()->current_key_capture = nullptr; m_key_captured = false; }
|
||||
|
||||
// class iterator
|
||||
// {
|
||||
// std::stack<Node*> m_nodes;
|
||||
// Node* m_current;
|
||||
// public:
|
||||
// iterator(Node* root)
|
||||
// {
|
||||
// m_current = root;
|
||||
// if (root)
|
||||
// m_nodes.push(root);
|
||||
// }
|
||||
// iterator& operator++()
|
||||
// {
|
||||
// m_nodes.pop();
|
||||
// for (auto& c : m_current->m_children)
|
||||
// m_nodes.push(c.get());
|
||||
// m_current = m_nodes.size() ? m_nodes.top() : nullptr;
|
||||
// return *this;
|
||||
// }
|
||||
// Node& operator*() { return *m_current; }
|
||||
// Node* operator->() { return m_current; }
|
||||
// bool operator==(const iterator& rhs) { return m_current == rhs.m_current; }
|
||||
// bool operator!=(const iterator& rhs) { return m_current != rhs.m_current; }
|
||||
// };
|
||||
// iterator begin()
|
||||
// {
|
||||
// return this;
|
||||
// }
|
||||
// iterator end()
|
||||
// {
|
||||
// return nullptr;
|
||||
// }
|
||||
};
|
||||
|
||||
class NodeBorder : public Node
|
||||
@@ -421,6 +396,11 @@ public:
|
||||
m_text_mesh.update(font_id, m_text.c_str());
|
||||
SetSize(m_text_mesh.bb);
|
||||
}
|
||||
virtual void restore_context() override
|
||||
{
|
||||
Node::restore_context();
|
||||
create();
|
||||
}
|
||||
virtual void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr) override
|
||||
{
|
||||
Node::parse_attributes(ka, attr);
|
||||
@@ -507,6 +487,11 @@ public:
|
||||
m_sz = (m_region.zw - m_region.xy) / tex_sz;
|
||||
}
|
||||
}
|
||||
virtual void restore_context() override
|
||||
{
|
||||
Node::restore_context();
|
||||
create();
|
||||
}
|
||||
virtual void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr) override
|
||||
{
|
||||
Node::parse_attributes(ka, attr);
|
||||
@@ -1711,6 +1696,12 @@ public:
|
||||
TextureManager::load("data/Icons/Round-Hard.png");
|
||||
m_brush.m_tex_id = const_hash("data/Icons/Round-Hard.png");
|
||||
}
|
||||
virtual void restore_context() override
|
||||
{
|
||||
NodeBorder::restore_context();
|
||||
init_controls();
|
||||
m_rtt.create(m_rtt.getWidth(), m_rtt.getHeight());
|
||||
}
|
||||
void draw_stroke()
|
||||
{
|
||||
m_rtt.bindFramebuffer();
|
||||
@@ -1880,6 +1871,13 @@ public:
|
||||
m_sampler.create();
|
||||
m_face_plane.create<1>(2, 2);
|
||||
}
|
||||
virtual void restore_context() override
|
||||
{
|
||||
Node::restore_context();
|
||||
m_canvas->create(512, 512);
|
||||
m_sampler.create();
|
||||
m_face_plane.create<1>(2, 2);
|
||||
}
|
||||
virtual void draw() override
|
||||
{
|
||||
using namespace ui;
|
||||
|
||||
Reference in New Issue
Block a user