#include <queue>
|
|
#include "render_state.h"
|
|
|
|
struct render_thunk {
|
|
float prio;
|
|
ant::render::layer_pos pos = ant::render::layer_pos::any;
|
|
std::function<void()> op;
|
|
};
|
|
|
|
static bool operator<(const render_thunk& lhs, const render_thunk& rhs) {
|
|
if(lhs.prio < rhs.prio) {
|
|
if(lhs.pos > rhs.pos) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
static std::priority_queue<render_thunk> renders;
|
|
|
|
void ant::render::schedule_in_frame(float layer, std::function<void()> fn, ant::render::layer_pos pos) {
|
|
renders.push({layer, pos, std::move(fn)});
|
|
}
|
|
|
|
void ant::render::render_all() {
|
|
while(not renders.empty()) {
|
|
renders.top().op();
|
|
renders.pop();
|
|
}
|
|
}
|