]> git.tdb.fi Git - libs/gl.git/blob - source/core/texture1d.h
Create specialized versions of SPIR-V modules with default spec values
[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
33 public:
34         /** Sets storage format and size and allocates memory for the texture.  If
35         lv is zero, a complete mipmap pyramid is automatically created.  Storage
36         cannot be changed once set. */
37         void storage(PixelFormat, unsigned wd, unsigned lv = 0);
38
39         virtual void image(unsigned level, const void *);
40
41         /** Replaces a range of texels in the texture.  Allocated storage must
42         exist.  The image data is interpreted according to the storage format and
43         the range must be fully inside the selected mipmap level. */
44         void sub_image(unsigned level, unsigned x, unsigned wd, const void *);
45
46         virtual void image(const Graphics::Image &, unsigned = 0);
47
48         unsigned get_width() const { return width; }
49
50 private:
51         unsigned get_level_size(unsigned) const;
52 };
53
54 } // namespace GL
55 } // namespace Msp
56
57 #endif