SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Skybox.hpp
Go to the documentation of this file.
1#ifndef _SKYBOX_HPP_
2#define _SKYBOX_HPP_
3
4#include <Core/OSDef.hpp>
5#include <string>
6#include <array>
7#include <Memory/RefPtr.hpp>
8
9namespace Sleak {
10
11 namespace RenderEngine {
12 class BufferBase;
13 class Shader;
14 }
15 class Texture;
16
17 /// Renders the background sky as a cubemap, panorama, or procedural gradient.
18 /// @ingroup rendering
19 class ENGINE_API Skybox {
20 public:
21 /// Construct skybox from 6 cubemap face image paths
22 /// Order: +X, -X, +Y, -Y, +Z, -Z
23 explicit Skybox(const std::array<std::string, 6>& facePaths);
24
25 /// Construct skybox from a single equirectangular panorama image
26 explicit Skybox(const std::string& panoramaPath);
27
28 /// Construct skybox with procedural gradient (top, mid, bottom colors)
29 Skybox(float topR, float topG, float topB,
30 float midR, float midG, float midB,
31 float botR, float botG, float botB);
32
33 /// Default skybox: loads built-in sky panorama
34 Skybox();
35
36 ~Skybox();
37
38 /// Create GPU resources (shader, buffers, cubemap texture)
39 void Initialize();
40
41 /// Submit render commands for this frame
42 void Render();
43
44 bool IsInitialized() const { return m_initialized; }
45
46 /// Expose the underlying cubemap (used by IBL precompute).
47 /// May be null if gradient mode or load failed.
48 Texture* GetCubemapTexture() const { return m_cubemapTexture.get(); }
49
50 private:
51 /// Which construction path built this skybox, and so how Render() sources its imagery.
52 enum class SkyboxMode { Cubemap, Panorama, Gradient, Default };
53 SkyboxMode m_mode = SkyboxMode::Default;
54
55 // Cubemap face paths (for Cubemap mode)
56 std::array<std::string, 6> m_facePaths;
57
58 // Panorama path (for Panorama/Default mode)
59 std::string m_panoramaPath;
60
61 // Gradient colors (for Gradient mode)
62 float m_topR = 0.1f, m_topG = 0.3f, m_topB = 0.8f;
63 float m_midR = 0.5f, m_midG = 0.7f, m_midB = 1.0f;
64 float m_botR = 0.8f, m_botG = 0.85f, m_botB = 0.9f;
65
66 // GPU resources
67 RefPtr<RenderEngine::Shader> m_shader;
68 RefPtr<RenderEngine::BufferBase> m_vertexBuffer;
69 RefPtr<RenderEngine::BufferBase> m_indexBuffer;
70 RefPtr<RenderEngine::BufferBase> m_constantBuffer;
71 RefPtr<Texture> m_cubemapTexture;
72
73 bool m_initialized = false;
74 };
75
76} // namespace Sleak
77
78#endif
Backend-agnostic GPU buffer: vertex, index, constant, or resource view target.
Backend-agnostic compiled shader program.
Definition Shader.hpp:11
void Render()
Submit render commands for this frame.
Definition Skybox.cpp:123
bool IsInitialized() const
Definition Skybox.hpp:44
Texture * GetCubemapTexture() const
Definition Skybox.hpp:48
Skybox(const std::array< std::string, 6 > &facePaths)
Definition Skybox.cpp:20
void Initialize()
Create GPU resources (shader, buffers, cubemap texture).
Definition Skybox.cpp:40
Backend-facing rendering layer shared by the four graphics backends.
Root namespace for everything the engine exposes.
Definition Camera.hpp:10