Refactoring the GUECS UI::render and the components so that it's just calling a .render on each one. This will then let me allow registering any components people want.

This commit is contained in:
Zed A. Shaw 2025-05-12 00:09:21 -04:00
parent a9e219ea96
commit 4d71f552aa
7 changed files with 108 additions and 69 deletions

View file

@ -209,20 +209,11 @@ namespace guecs {
}
template<typename T>
void render_helper(sf::RenderWindow& window, Entity ent, bool is_shape, T& target) {
sf::Shader *shader_ptr = nullptr;
void render_helper(sf::RenderWindow& window, T& target, sf::Shader *shader_ptr) {
window.draw(*target, shader_ptr);
}
if(auto shader = get_if<Effect>(ent)) {
if(shader->$active) {
auto ptr = shader->checkout_ptr();
ptr->setUniform("is_shape", is_shape);
// NOTE: this is needed because SFML doesn't handle shared_ptr
shader_ptr = ptr.get();
}
}
window.draw(*target, shader_ptr);
}
sf::Shader* find_shader(Entity ent, bool is_shape);
void show_sprite(const string& region, const string& sprite_name);
void show_text(const string& region, const wstring& content);