blob: 220df09f5b73b75b0e30d60488aebaca73b9f2db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#pragma once
#include "Rendering/Texture.h"
#include "Core/Log.h"
#include <glad/glad.h>
namespace Donut
{
class OpenGLTexture2D
: public Texture2D
{
public:
OpenGLTexture2D(uint32_t width, uint32_t height);
OpenGLTexture2D(const std::string& path);
virtual ~OpenGLTexture2D();
virtual uint32_t GetWidth() const override { return m_Width; }
virtual uint32_t GetHeight() const override { return m_Height; }
virtual uint32_t GetRendererID() const override { return m_RendererID; }
virtual void SetData(void* data, uint32_t size) override;
virtual void Bind(uint32_t slot = 0) const override;
virtual void BindAsImage(uint32_t slot = 0, bool readOnly = false) const override;
virtual bool operator==(const Texture& other) const override
{
return m_RendererID == other.GetRendererID();
}
private:
std::string m_Path;
uint32_t m_Width, m_Height;
uint32_t m_RendererID;
GLenum m_InternalFormat, m_DataFormat;
};
class OpenGLCubemapTexture
: public CubemapTexture
{
public:
OpenGLCubemapTexture(uint32_t width, uint32_t height);
OpenGLCubemapTexture(const std::string& path);
virtual ~OpenGLCubemapTexture();
virtual uint32_t GetWidth() const override { return m_Width; }
virtual uint32_t GetHeight() const override { return m_Height; }
virtual uint32_t GetRendererID() const override { return m_RendererID; }
virtual void SetData(void* data, uint32_t size) override;
virtual void Bind(uint32_t slot = 0) const override;
virtual void BindAsImage(uint32_t slot = 0, bool readOnly = false) const override;
virtual bool operator==(const Texture& other) const override
{
return m_RendererID == other.GetRendererID();
}
private:
void LoadHDRI(const std::string& path);
void ConvertEquirectangularToCubemap(float* hdrData, int width, int height);
std::string m_Path;
uint32_t m_Width, m_Height;
uint32_t m_RendererID;
GLenum m_InternalFormat, m_DataFormat;
};
}
|