Moving on to cubemaps.
This commit is contained in:
parent
9c75238461
commit
87c513b9f0
113 changed files with 15511 additions and 0 deletions
82
24-cubemaps/src/scene.hpp
Normal file
82
24-cubemaps/src/scene.hpp
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
#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 "framebuffer.hpp"
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
struct Thing {
|
||||
std::string name;
|
||||
Model& model;
|
||||
Material& material;
|
||||
components::Position position;
|
||||
components::Rotation rotation;
|
||||
float scale;
|
||||
float distance = 0;
|
||||
};
|
||||
|
||||
struct Scene {
|
||||
Shader shader;
|
||||
Screen screen;
|
||||
FrameBuffer framebuffer;
|
||||
|
||||
std::unordered_map<std::string, components::Material> materials;
|
||||
Camera camera;
|
||||
components::Lighting light;
|
||||
std::unordered_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},
|
||||
screen{.shader={config.screen_shader.vertex_path, config.screen_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(
|
||||
thing.model,
|
||||
models.at(thing.model),
|
||||
materials.at(thing.material),
|
||||
thing.position,
|
||||
thing.rotation,
|
||||
thing.scale);
|
||||
}
|
||||
|
||||
shader.use();
|
||||
shader.setInt("texture1", 0);
|
||||
shader.apply_lighting(light);
|
||||
|
||||
framebuffer.init();
|
||||
screen.init();
|
||||
}
|
||||
|
||||
void update();
|
||||
void draw_thing(Shader& with_shader, Thing& thing);
|
||||
void render(GLFWwindow* window);
|
||||
void cleanup();
|
||||
void spawn(const std::string& name, components::Position& position, components::Rotation& rotation);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue