Euphoria
texture.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "core/image.h"
4 #include "render/gltypes.h"
5 #include "io/vfs.h"
6 
7 
8 namespace eu::core
9 {
10  struct Image;
11 }
12 
13 namespace eu::render
14 {
15  enum class TextureWrap
16  {
17  repeat,
20  };
21 
23  {
24  nearest,
25  linear
26  };
27 
28  enum class FilterMinification
29  {
30  nearest,
31  linear
32  // todo(Gustav): add mipmap
33  };
34 
36  {
38 
41 
44 
47 
51  };
52 
53  struct TextureId
54  {
55  public:
56  TextureId();
57  ~TextureId();
58 
59  TextureId(const TextureId& other) = delete;
60  void operator=(const TextureId&) = delete;
61  TextureId(TextureId&& other) = delete;
62  void operator=(TextureId&&) = delete;
63 
64  [[nodiscard]] bool
65  is_currently_bound() const;
66 
67  [[nodiscard]] gl::Uint
68  get_id() const;
69 
70  private:
71  gl::Uint id;
72  };
73 
74  void
75  use(const TextureId* texture);
76 
77  struct Texture2 : public TextureId
78  {
79  public:
80  Texture2();
81  ~Texture2() = default;
82 
83  Texture2(const Texture2& other) = delete;
84  void operator=(const Texture2&) = delete;
85  Texture2(Texture2&& other) = delete;
86  void operator=(Texture2&&) = delete;
87 
88  void
90  (
91  int width,
92  int height,
93  const unsigned char* pixel_data,
94  gl::Int internal_format,
95  gl::Uint image_format,
96  const Texture2dLoadData& data
97  );
98 
99  void
101  (
102  const core::Image& image,
103  core::AlphaLoad alpha,
104  const Texture2dLoadData& data
105  );
106 
107  void
109  (
110  io::FileSystem* fs,
111  const io::FilePath& path,
112  core::AlphaLoad alpha,
113  const Texture2dLoadData& data
114  );
115 
116  int width;
117  int height;
118  };
119 
120 }
AlphaLoad
Definition: image.h:139
unsigned int Uint
Definition: gltypes.h:6
void use(const ShaderProgram *shader)
Definition: shader.cc:114
FilterMagnification
Definition: texture.h:23
FilterMinification
Definition: texture.h:29
Texture2(Texture2 &&other)=delete
void load_from_file(io::FileSystem *fs, const io::FilePath &path, core::AlphaLoad alpha, const Texture2dLoadData &data)
Definition: texture.cc:189
void operator=(Texture2 &&)=delete
Texture2(const Texture2 &other)=delete
void operator=(const Texture2 &)=delete
void load_from_image(const core::Image &image, core::AlphaLoad alpha, const Texture2dLoadData &data)
Definition: texture.cc:208
void load_from_pixels(int width, int height, const unsigned char *pixel_data, gl::Int internal_format, gl::Uint image_format, const Texture2dLoadData &data)
Definition: texture.cc:151
Texture2dLoadData & set_wrap(TextureWrap v)
Definition: texture.cc:82
Texture2dLoadData & set_filter_magnification(FilterMagnification v)
Definition: texture.cc:90
FilterMagnification magnification
Definition: texture.h:50
Texture2dLoadData & set_filter_minification(FilterMinification v)
Definition: texture.cc:98
FilterMinification minification
Definition: texture.h:49
TextureId(const TextureId &other)=delete
gl::Uint get_id() const
Definition: texture.cc:118
TextureId(TextureId &&other)=delete
void operator=(TextureId &&)=delete
bool is_currently_bound() const
Definition: texture.cc:125
void operator=(const TextureId &)=delete