This is going to require a major rewrite of every component of this program. Going to revert back to the linear game loop for now
parent
5fcf1c0e44
commit
2d2a854f0f
@ -1,3 +1,3 @@
|
||||
[LOGGING]
|
||||
log_level = 0 # INFO, WARN, ERROR
|
||||
log_dest = 0 # STDOUT, FILE
|
||||
[LOGGING]
|
||||
log_level = 0 # INFO, WARN, ERROR
|
||||
log_dest = 0 # STDOUT, FILE
|
||||
|
@ -1,3 +1,3 @@
|
||||
[GRAPHICS]
|
||||
x_resolution = 800
|
||||
y_resolution = 800
|
||||
[GRAPHICS]
|
||||
x_resolution = 800
|
||||
y_resolution = 800
|
||||
|
@ -1,66 +1,66 @@
|
||||
#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 = true;
|
||||
// Derived class will handle imgui calls
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#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 = true;
|
||||
// Derived class will handle imgui calls
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "Gui.h"
|
||||
|
||||
std::mutex Gui::container_lock;
|
||||
#include "Gui.h"
|
||||
|
||||
std::mutex Gui::container_lock;
|
||||
std::list<Gui*> Gui::renderable_container;
|
Loading…
Reference in new issue