A small game engine for 2D games based of Raylib
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

31 rivejä
674 B

#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();
}
}