Experiments in using Lua with sol2 and how best to structure the data. Contains a shoot out of SOA, vs AOS vs. MOA. SOA = Struct of Arrays AOS = Array of Structs MOA = Many Array of Structs (kind of a hybrid)
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.
sol2_test/src/render.cpp

40 lines
870 B

#include "render.hpp"
#include "config.hpp"
#include <algorithm>
Engine::Engine(Deck &deck) :
deck(deck)
{
text.load_font();
screen.init();
framebuffer.init();
}
void Engine::render() {
framebuffer.begin();
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
auto& slide = deck.slides.at(at_slide);
float line = 0;
for(auto& node : slide.content) {
if(node.type == NodeType::TEXT || node.type == NodeType::H1 || node.type == NodeType::UL) {
line++;
float y = (text.font_size + 20) * line;
text.render(node.content, 25.0f, SCR_HEIGHT - y, 1.0f,
glm::vec3(1.0f, 1.0f, 1.0f));
}
}
framebuffer.commit();
framebuffer.draw(screen);
}
void Engine::change_slide(int dir) {
if(deck.slides.size() == 0) at_slide = 0;
at_slide = std::clamp(at_slide + dir, 0, int(deck.slides.size() - 1));
}