Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
texture.h
1#ifndef OE_RENDER_TEXTURE_H
2#define OE_RENDER_TEXTURE_H
3
4#include <string>
5#include <vector>
6#include <functional>
7#include <glm/vec4.hpp>
8#include "../util/byte_array.h"
9#include "../util/non_copyable.h"
10#include "../common.h"
11
12namespace oe::scene
13{
14 class Material;
15}
16
17namespace oe::render
18{
19 class Shader;
20 class TextureManager;
21 class Framebuffer;
22
27 {
28 public:
29 Texture(
30 const int32_t width,
31 const int32_t height,
32 const uint8_t* data,
33 const int32_t nb_channels = 0, // Used as hint to fill formats/type if no other argument provided after
34 const int32_t internal_format = 0,
35 const int32_t format = 0,
36 const int32_t type = 0,
37 const uint8_t max_mips = 1
38 );
39
47 Texture(const std::string& filename, const bool& is_srgb = false, const uint8_t max_mips = 1);
48
53 const uint32_t width,
54 const uint32_t height,
55 const std::function<glm::vec4(const uint32_t i, const uint32_t j)> generator,
56 const uint8_t max_mips = 1
57 );
58
63 const uint32_t width,
64 const uint32_t height,
65 const oe::scene::Material& generator,
66 const int32_t nb_channels = 0,
67 const int32_t internal_format = 0,
68 const int32_t format = 0,
69 const int32_t type = 0,
70 const uint8_t max_mips = 1
71 );
72
73 static Texture* generateFromCompressed(
74 const int32_t compression,
75 const int32_t width,
76 const int32_t height,
77 const int32_t data_size,
78 const uint8_t* data
79 );
80
81 virtual void use(const uint8_t& layer);
82
83 virtual void enableBilinearFiltering(bool enabled = true);
84
85 virtual void generateMipMaps();
86
87 void clampToEdge();
88 void wrapRepeat();
89
90 void fillTextureData(const ByteArray& data, const unsigned int& face, const unsigned int& mip_level);
91
95 ByteArray fetchTextureData(const unsigned int& face, const unsigned int& mip_level);
96
97 unsigned int getWidth() const { return _width; }
98 unsigned int getHeight() const { return _height; }
99
100 // Todo put private / protected (Needed by dynamic cubemap)
101 unsigned int getHandle() const { return _internal_id; }
102
103 int getImageInternalFormat() const { return _internal_format; }
104
105 int getImageFormat() const { return _format; }
106 int getImageType() const { return _type; }
107
108 virtual ~Texture();
109 protected:
110 Texture();
111
112 Texture(const Texture&) = delete;
113 Texture& operator=(const Texture&) = delete;
114
115 void _generate_texture
116 (
117 const int32_t width,
118 const int32_t height,
119 const uint8_t* data,
120 const int32_t nb_channels = 0,
121 const int32_t internal_format = 0,
122 const int32_t format = 0,
123 const int32_t type = 0,
124 const uint8_t max_mips = 1
125 );
126
127 //virtual void init();
128 //virtual void clean();
129
130 uint32_t _internal_id = 0;
131
132 int32_t _width;
133 int32_t _height;
134
135 int _internal_format = 0;
136
137 // Might be removed (_format / _type depends on image to fill and not need to be stored)
138 int _format = 0;
139 int _type = 0;
140
141 friend class Framebuffer;
142 };
143}
144
145#endif
Definition texture.h:27
Texture(const uint32_t width, const uint32_t height, const oe::scene::Material &generator, const int32_t nb_channels=0, const int32_t internal_format=0, const int32_t format=0, const int32_t type=0, const uint8_t max_mips=1)
Texture(const std::string &filename, const bool &is_srgb=false, const uint8_t max_mips=1)
Texture(const uint32_t width, const uint32_t height, const std::function< glm::vec4(const uint32_t i, const uint32_t j)> generator, const uint8_t max_mips=1)
ByteArray fetchTextureData(const unsigned int &face, const unsigned int &mip_level)
Render agnostic material.
Definition material.h:26
Prevent class to be copied.
Definition non_copyable.h:12
Render related abstractions (Shader, Framebuffer, Cubemaps, Textures)
Definition opengl.h:10
Scene related management (Render-agnostic Geometry, Manger, etc...)
Definition debug.h:19