Models all tested and refactored so that the draw() call doesn't do a bunch of irrelevant shit.

This commit is contained in:
Zed A. Shaw 2026-08-25 13:51:22 -04:00
parent 2431cf8c97
commit 47bd233722
6 changed files with 102 additions and 70 deletions

View file

@ -213,16 +213,23 @@ Config setup() {
},
};
// REFACTOR: really this should be done somewhere else
for(auto& model : config.models) {
model.connect_shader(config.shader);
}
return config;
}
void draw_popcorn(Config& config, size_t model_i, size_t model_pos, glm::mat4& projection, glm::mat4& view)
void draw_models(Config& config, size_t model_i, size_t model_pos, glm::mat4& projection, glm::mat4& view)
{
glm::vec3 objectColor = {1.0, 0.94, 0.78};
config.shader.applyMaterial(config.cubeMaterial);
float time = glfwGetTime();
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, popcorn_positions[model_pos]);
model = glm::rotate(model, glm::radians(time * 10.0f), glm::vec3(1.0f, 0.3f, 0.5f));
config.shader.setMat4("model", model);
@ -256,7 +263,7 @@ void render(GLFWwindow* window, Config& config) {
config.shader.applyLighting(config.light);
for(size_t i = 0; i < CUBE_COUNT; i++) {
draw_popcorn(config, 0, i, projection, view);
draw_models(config, 0, i, projection, view);
}
glfwSwapBuffers(window);