lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
Loading...
Searching...
No Matches
skybox.hpp
Go to the documentation of this file.
1
13
14#pragma once
15
18#include "lmgl/scene/camera.hpp"
19
20#include <glad/glad.h>
21#include <glm/glm.hpp>
22
23#include <memory>
24#include <string>
25#include <vector>
26
27namespace lmgl {
28
29namespace scene {
30
38class Cubemap {
39 public:
50 static std::shared_ptr<Cubemap> from_faces(const std::vector<std::string> &faces);
51
61 static std::shared_ptr<Cubemap> from_equirectangular(const std::string &path);
62
68 ~Cubemap();
69
77 void bind(unsigned int slot = 0) const;
78
84 inline unsigned int get_id() const { return m_renderer_id; }
85
86 private:
87
89 Cubemap() = default;
90
100 bool load_faces(const std::vector<std::string> &faces);
101
110 bool load_equirectangular(const std::string &path);
111
113 unsigned int m_renderer_id = 0;
114};
115
122class Skybox {
123 public:
124
134 Skybox(std::shared_ptr<Cubemap> cubemap, const std::string &shader_path = "shaders/skybox.glsl");
135
137 ~Skybox();
138
147 void render(std::shared_ptr<Camera> camera);
148
156 inline void set_cubemap(std::shared_ptr<Cubemap> cubemap) { m_cubemap = cubemap; }
157
163 inline std::shared_ptr<Cubemap> get_cubemap() const { return m_cubemap; }
164
170 inline void set_exposure(float exposure) { m_exposure = exposure; }
171
177 inline float get_exposure() const { return m_exposure; }
178
184 inline std::shared_ptr<renderer::Shader> get_shader() const { return m_shader; }
185
186 private:
187
193 void init_cube_geometry();
194
196 std::shared_ptr<Cubemap> m_cubemap;
197
199 std::shared_ptr<renderer::Shader> m_shader;
200
202 std::shared_ptr<renderer::VertexArray> m_vao;
203
205 float m_exposure = 1.0f;
206
208 unsigned int m_vbo = 0;
209};
210
211} // namespace lmgl
212
213} // namespace scene
Declaration of the Camera class for managing viewport and projection.
Represents a cubemap texture for skybox rendering.
Definition skybox.hpp:38
void bind(unsigned int slot=0) const
Binds the cubemap texture to a specified texture slot.
Definition skybox.cpp:174
unsigned int get_id() const
Retrieves the OpenGL texture ID of the cubemap.
Definition skybox.hpp:84
~Cubemap()
Destructor for the Cubemap class.
Definition skybox.cpp:35
static std::shared_ptr< Cubemap > from_faces(const std::vector< std::string > &faces)
Creates a Cubemap from six face images.
Definition skybox.cpp:15
static std::shared_ptr< Cubemap > from_equirectangular(const std::string &path)
Creates a Cubemap from an equirectangular image.
Definition skybox.cpp:27
~Skybox()
Destructor for the Skybox class.
Definition skybox.cpp:190
std::shared_ptr< Cubemap > get_cubemap() const
Retrieves the cubemap texture used by the skybox.
Definition skybox.hpp:163
float get_exposure() const
Retrieves the exposure level for the skybox rendering.
Definition skybox.hpp:177
Skybox(std::shared_ptr< Cubemap > cubemap, const std::string &shader_path="shaders/skybox.glsl")
Constructs a Skybox with the given cubemap and shader.
Definition skybox.cpp:181
void set_exposure(float exposure)
Sets the exposure level for the skybox rendering.
Definition skybox.hpp:170
void render(std::shared_ptr< Camera > camera)
Renders the skybox using the specified camera.
Definition skybox.cpp:250
std::shared_ptr< renderer::Shader > get_shader() const
Retrieves the shader used for rendering the skybox.
Definition skybox.hpp:184
void set_cubemap(std::shared_ptr< Cubemap > cubemap)
Sets the cubemap texture for the skybox.
Definition skybox.hpp:156
Namespace for scene-related classes and functions.
Definition camera.cpp:7
Forward declarations for Assimp Material structure.
Definition model_loader.cpp:12
Declaration of the Shader class for managing shader programs in OpenGL.
Declaration of the VertexArray class for managing Vertex Array Objects (VAOs) in OpenGL.