]> git.tdb.fi Git - libs/gl.git/blob - source/backends/opengl/buffer_backend.h
Add support for padding in vertex formats
[libs/gl.git] / source / backends / opengl / buffer_backend.h
1 #ifndef MSP_GL_BUFFER_BACKEND_H_
2 #define MSP_GL_BUFFER_BACKEND_H_
3
4 #include <msp/core/noncopyable.h>
5
6 namespace Msp {
7 namespace GL {
8
9 class OpenGLBuffer: public NonCopyable
10 {
11         friend class OpenGLPipelineState;
12         friend class OpenGLTexture2D;
13         friend class OpenGLVertexSetup;
14
15 protected:
16         unsigned id = 0;
17
18         static OpenGLBuffer *scratch_binding;
19
20         OpenGLBuffer();
21         OpenGLBuffer(OpenGLBuffer &&);
22         ~OpenGLBuffer();
23
24         void allocate();
25         void sub_data(size_t, size_t, const void *);
26
27         bool can_map() const { return true; }
28         void *map();
29         bool unmap();
30
31         void set_debug_name(const std::string &);
32
33         void bind_scratch();
34         static void unbind_scratch();
35 };
36
37 using BufferBackend = OpenGLBuffer;
38
39 } // namespace GL
40 } // namespace Msp
41
42 #endif