SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
OpenGLCubemapTexture.hpp
Go to the documentation of this file.
1#ifndef OPENGLCUBEMAPTEXTURE_HPP_
2#define OPENGLCUBEMAPTEXTURE_HPP_
3
4#include <Core/OSDef.hpp>
5#include <Runtime/Texture.hpp>
6#include <glad/glad.h>
7#include <array>
8#include <string>
9
10namespace Sleak {
11namespace RenderEngine {
12
13/// OpenGL cubemap texture, loadable from six face images, a panorama, or a procedural gradient.
14class ENGINE_API OpenGLCubemapTexture : public ::Sleak::Texture {
15public:
17 ~OpenGLCubemapTexture() override;
18
19 /// Load 6 face images: +X, -X, +Y, -Y, +Z, -Z
20 bool LoadCubemap(const std::array<std::string, 6>& facePaths);
21
22 /// Load from a single equirectangular panorama and convert to cubemap
23 bool LoadEquirectangular(const std::string& path, uint32_t faceSize = 512);
24
25 /// Generate a procedural gradient cubemap (top/mid/bottom colors)
26 bool LoadGradient(float topR, float topG, float topB,
27 float midR, float midG, float midB,
28 float botR, float botG, float botB,
29 uint32_t resolution = 64);
30
31 // Texture interface — LoadFromFile/LoadFromMemory not used for cubemaps
32 /// Unused for cubemaps; always returns false, load via LoadCubemap/LoadEquirectangular instead.
33 bool LoadFromMemory(const void* data, uint32_t width, uint32_t height,
34 TextureFormat format) override;
35 /// Unused for cubemaps; always returns false, load via LoadCubemap/LoadEquirectangular instead.
36 bool LoadFromFile(const std::string& filePath) override;
37
38 /// Binds the cubemap to a texture unit.
39 void Bind(uint32_t slot = 0) const override;
40 void Unbind() const override;
41
42 void SetFilter(TextureFilter filter) override;
43 void SetWrapMode(TextureWrapMode wrapMode) override;
44
45 uint32_t GetWidth() const override { return m_width; }
46 uint32_t GetHeight() const override { return m_height; }
47 TextureFormat GetFormat() const override { return m_format; }
48 TextureType GetType() const override { return TextureType::TextureCube; }
49
50 GLuint GetGLTexture() const { return m_texture; }
51
52private:
53 GLuint m_texture = 0;
54 uint32_t m_width = 0;
55 uint32_t m_height = 0;
57};
58
59} // namespace RenderEngine
60} // namespace Sleak
61
62#endif // OPENGLCUBEMAPTEXTURE_HPP_
int width
int height
bool LoadCubemap(const std::array< std::string, 6 > &facePaths)
Load 6 face images: +X, -X, +Y, -Y, +Z, -Z.
void Bind(uint32_t slot=0) const override
Binds the cubemap to a texture unit.
bool LoadFromMemory(const void *data, uint32_t width, uint32_t height, TextureFormat format) override
Unused for cubemaps; always returns false, load via LoadCubemap/LoadEquirectangular instead.
bool LoadFromFile(const std::string &filePath) override
Unused for cubemaps; always returns false, load via LoadCubemap/LoadEquirectangular instead.
bool LoadEquirectangular(const std::string &path, uint32_t faceSize=512)
Load from a single equirectangular panorama and convert to cubemap.
void SetWrapMode(TextureWrapMode wrapMode) override
void SetFilter(TextureFilter filter) override
bool LoadGradient(float topR, float topG, float topB, float midR, float midG, float midB, float botR, float botG, float botB, uint32_t resolution=64)
Generate a procedural gradient cubemap (top/mid/bottom colors).
TextureFormat
Definition Texture.hpp:10
TextureFilter
Definition Texture.hpp:28
TextureType
Definition Texture.hpp:20
TextureWrapMode
Definition Texture.hpp:43
Backend-facing rendering layer shared by the four graphics backends.
Root namespace for everything the engine exposes.
Definition Camera.hpp:10