]> git.tdb.fi Git - libs/gl.git/blob - source/backends/opengl/texture2d_backend.h
5de1079537daf16dd08248ca1d3712844223913d
[libs/gl.git] / source / backends / opengl / texture2d_backend.h
1 #ifndef MSP_GL_TEXTURE2D_BACKEND_H_
2 #define MSP_GL_TEXTURE2D_BACKEND_H_
3
4 #include "texture.h"
5
6 namespace Msp {
7 namespace GL {
8
9 class Buffer;
10
11 class OpenGLTexture2D: public Texture
12 {
13 protected:
14         class AsyncTransfer: public NonCopyable
15         {
16         protected:
17                 Buffer *pixel_buffer = 0;
18
19                 AsyncTransfer() = default;
20                 AsyncTransfer(AsyncTransfer &&);
21                 AsyncTransfer &operator=(AsyncTransfer &&);
22                 ~AsyncTransfer();
23
24                 void *allocate();
25                 void finalize();
26         };
27
28         class AsyncLoader;
29
30         OpenGLTexture2D();
31
32         void allocate();
33         void sub_image(unsigned, int, int, unsigned, unsigned, const void *);
34         void sub_image(unsigned, int, int, unsigned, unsigned, const Buffer &, unsigned);
35
36 public:
37         virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
38         virtual std::size_t get_data_size() const;
39         virtual void unload();
40 };
41
42 using Texture2DBackend = OpenGLTexture2D;
43
44 } // namespace GL
45 } // namespace Msp
46
47 #endif