Setup for day 17.
This commit is contained in:
parent
d3169d3eca
commit
187bf4c1d1
84 changed files with 14784 additions and 0 deletions
64
17-refactor-bug-fix/src/scene.hpp
Normal file
64
17-refactor-bug-fix/src/scene.hpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#pragma once
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "shader.hpp"
|
||||
#include "model.hpp"
|
||||
#include "shader.hpp"
|
||||
#include "model.hpp"
|
||||
#include "camera.hpp"
|
||||
#include "components.hpp"
|
||||
#include <vector>
|
||||
|
||||
struct Thing {
|
||||
Model& model;
|
||||
components::Position position;
|
||||
Material& material;
|
||||
};
|
||||
|
||||
struct Scene {
|
||||
Shader shader;
|
||||
Shader light_shader;
|
||||
std::map<std::string, components::Material> materials;
|
||||
Camera camera;
|
||||
components::Lighting light;
|
||||
std::map<std::string, Model> models;
|
||||
std::vector<Thing> things;
|
||||
|
||||
float deltaTime = 0.0f;
|
||||
float lastFrame = 0.0f;
|
||||
|
||||
Scene(components::Scene& config):
|
||||
shader{config.shader.vertex_path, config.shader.frag_path},
|
||||
light_shader{config.light_shader.vertex_path, config.shader.frag_path},
|
||||
materials{config.materials},
|
||||
camera{
|
||||
.position=config.camera.position,
|
||||
.front=config.camera.front,
|
||||
.up=config.camera.up,
|
||||
.direction=config.camera.direction,
|
||||
.movement_speed=config.camera.movement_speed,
|
||||
},
|
||||
light{config.light}
|
||||
{
|
||||
for(auto& [name, model] : config.models) {
|
||||
models.try_emplace(name, model.directory, model.model_path);
|
||||
}
|
||||
|
||||
for(auto& thing : config.things) {
|
||||
things.emplace_back(
|
||||
models.at(thing.model),
|
||||
thing.position,
|
||||
materials.at(thing.material));
|
||||
}
|
||||
}
|
||||
|
||||
void updateDelta();
|
||||
void configure();
|
||||
void draw_model(Model& scene_model, Material& material, glm::mat4& projection, glm::mat4& view, glm::vec3& position);
|
||||
void render(GLFWwindow* window);
|
||||
void cleanup();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue