SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
OpenGLTexture.hpp
Go to the documentation of this file.
1#ifndef OPENGLTEXTURE_HPP_
2#define OPENGLTEXTURE_HPP_
3
4#include <Core/OSDef.hpp>
5#include <Runtime/Texture.hpp>
6#include <glad/glad.h>
7
8namespace Sleak {
9namespace RenderEngine {
10
11/// OpenGL 2D texture, loadable from disk or an in-memory pixel buffer.
12class ENGINE_API OpenGLTexture : public Texture {
13public:
15 ~OpenGLTexture() override;
16
17 /// Uploads raw pixel data as a new GL texture, generating mips.
18 bool LoadFromMemory(const void* data, uint32_t width, uint32_t height,
19 TextureFormat format) override;
20 /// Decodes an image file and uploads it as a new GL texture.
21 bool LoadFromFile(const std::string& filePath) override;
22
23 void Bind(uint32_t slot = 0) const override;
24 void Unbind() const override;
25
26 void SetFilter(TextureFilter filter) override;
27 void SetWrapMode(TextureWrapMode wrapMode) override;
28 void SetLodBias(float bias) override;
29 float GetLodBias() const override { return m_lodBias; }
30
31 uint32_t GetWidth() const override { return m_width; }
32 uint32_t GetHeight() const override { return m_height; }
33 TextureFormat GetFormat() const override { return m_format; }
34 TextureType GetType() const override { return TextureType::Texture2D; }
35
36 uint64_t GetImGuiTextureID() const override { return static_cast<uint64_t>(m_texture); }
37
38 GLuint GetGLTexture() const { return m_texture; }
39
40private:
41 GLuint m_texture = 0;
42 uint32_t m_width = 0;
43 uint32_t m_height = 0;
46 float m_lodBias = 0.0f;
47};
48
49} // namespace RenderEngine
50} // namespace Sleak
51
52#endif // OPENGLTEXTURE_HPP_
int width
int height
void SetFilter(TextureFilter filter) override
float GetLodBias() const override
void SetLodBias(float bias) override
TextureFormat GetFormat() const override
void Bind(uint32_t slot=0) const override
bool LoadFromMemory(const void *data, uint32_t width, uint32_t height, TextureFormat format) override
Uploads raw pixel data as a new GL texture, generating mips.
uint32_t GetHeight() const override
uint64_t GetImGuiTextureID() const override
TextureType GetType() const override
void SetWrapMode(TextureWrapMode wrapMode) override
uint32_t GetWidth() const override
bool LoadFromFile(const std::string &filePath) override
Decodes an image file and uploads it as a new GL texture.
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