All Classes Files Functions Variables Typedefs Pages
Texture.hpp
Go to the documentation of this file.
1 #pragma once
2 
10 #include "GLObject.hpp"
11 #include "HotTexture.fpp"
12 #include "TexFormat.hpp"
13 #include "TexParam.hpp"
14 #include "Texture.fpp"
15 #include "TextureUnits.hpp"
16 #include "TexType.hpp"
17 #include "../config/BaseProxy.hpp"
18 #include "../util/Vector.hpp"
19 
20 #include <GL/glew.h>
21 #include <functional>
22 #include <vector>
23 
24 namespace lumina {
25 
30 class TextureInterface : public GLObject {
31 public:
32  virtual ~TextureInterface() = default;
33 
34  virtual void prePrime(int texUnit) = 0;
35  virtual void postPrime(int texUnit) = 0;
36 };
37 
38 
46 template <TexType TT>
47 class Texture : public TextureInterface {
48 public:
49  TexParam params;
50 
51  Texture();
52  ~Texture();
53 
63  void create(Vec2i dimension, TexFormat format, void *data = nullptr);
64  void prime(int texUnit, std::function<void(HotTexture<TT>&)> func);
65 
66  GLuint nativeHandle() const;
67  TexFormat getFormat() const;
68 
69 
70 private:
71  GLuint m_handle;
72  Vec2i m_dimension;
73  TexParam m_activeParams;
74  TexFormat m_format;
75 
76  void prePrime(int texUnit) final;
77  void postPrime(int texUnit) final;
78 
79  void bind(int texUnit);
80  void unbind(int texUnit);
81 
82  void applyParams(bool force = false);
83  void applyFilterMode();
84  void applyWrapMode();
85  void applyMipMaps();
86 
87  GLenum glType() const;
88  void createStorage(Vec2i dim,
89  GLint internalFormat,
90  GLenum format,
91  GLenum type,
92  void* data);
93 
94  friend HotTexture<TT>;
95 };
96 
97 } // namespace lumina
98 
99 #include "Texture.tpp"
void create(Vec2i dimension, TexFormat format, void *data=nullptr)
Creates internal storage for the texture.
Definition: Texture.cpp:11
Represents an OpenGL texture.
Definition: Texture.fpp:7
Definition: GLObject.hpp:37
Definition: TexParam.hpp:17
Definition: HotTexture.fpp:7
Interface for all texture types (2D, 3D, Cube).
Definition: Texture.hpp:30