]> git.tdb.fi Git - libs/gl.git/blob - source/core/texture1d.h
Fix reflection of image types from Spir-V modules
[libs/gl.git] / source / core / texture1d.h
1 #ifndef MSP_GL_TEXTURE1D_H_
2 #define MSP_GL_TEXTURE1D_H_
3
4 #include <string>
5 #include "texture1d_backend.h"
6
7 namespace Msp {
8 namespace GL {
9
10 /**
11 One-dimensional texture, consisting of a single row of texels.
12 */
13 class Texture1D: public Texture1DBackend
14 {
15         friend Texture1DBackend;
16
17 public:
18         class Loader: public DataFile::DerivedObjectLoader<Texture1D, Texture::Loader>
19         {
20         public:
21                 Loader(Texture1D &);
22                 Loader(Texture1D &, Collection &);
23         private:
24                 void init();
25
26                 void storage(PixelFormat, unsigned);
27                 void storage_levels(PixelFormat, unsigned, unsigned);
28         };
29
30 private:
31         unsigned width = 0;
32         unsigned levels = 0;
33
34 public:
35         /** Sets storage format and size and allocates memory for the texture.  If
36         lv is zero, a complete mipmap pyramid is automatically created.  Storage
37         cannot be changed once set. */
38         void storage(PixelFormat, unsigned wd, unsigned lv = 0);
39
40         virtual void image(unsigned level, const void *);
41
42         /** Replaces a range of texels in the texture.  Allocated storage must
43         exist.  The image data is interpreted according to the storage format and
44         the range must be fully inside the selected mipmap level. */
45         void sub_image(unsigned level, unsigned x, unsigned wd, const void *);
46
47         virtual void image(const Graphics::Image &, unsigned = 0);
48
49         unsigned get_width() const { return width; }
50
51 private:
52         unsigned get_n_levels() const;
53         unsigned get_level_size(unsigned) const;
54 };
55
56 } // namespace GL
57 } // namespace Msp
58
59 #endif