Files
voxel-raycaster/include/Gui.h
MitchellHansen 3ff6fb0b14 Adding a method of rendering GUI's that avoid the whole throwing raw
data around everywhere thing I had going on before
2017-09-27 23:36:20 -07:00

67 lines
919 B
C++

#pragma once
#include <mutex>
#include <Logger.h>
#include <list>
class Gui {
public:
Gui() {
container_lock.lock();
renderable_container.push_back(this);
container_lock.unlock();
};
virtual ~Gui() {
container_lock.lock();
renderable_container.remove(this);
container_lock.unlock();
};
virtual void render_gui() = 0;
virtual void update_gui() = 0;
// Instead of rendering nil, we can pass our render call if we would like
bool renderable() { return rendering; };
private:
// Whatever class that wants to call this must be a friend!!!
friend class Application;
static void do_render() {
for (auto i : renderable_container) {
i->update_gui();
if (i->renderable())
i->render_gui();
}
};
static std::mutex container_lock;
static std::list<Gui*> renderable_container;
protected:
bool rendering = false;
// Derived class will handle imgui calls
};