]> git.tdb.fi Git - libs/gl.git/blob - source/bufferable.h
Alter the working logic of Bufferable to avoid some problems
[libs/gl.git] / source / bufferable.h
1 #ifndef MSP_GL_BUFFERABLE_H_
2 #define MSP_GL_BUFFERABLE_H_
3
4 namespace Msp {
5 namespace GL {
6
7 class Buffer;
8
9 class Bufferable
10 {
11 protected:
12         Buffer *buffer;
13         unsigned buffer_offset;
14         Bufferable *next_in_buffer;
15         Bufferable *prev_in_buffer;
16         mutable bool dirty;
17
18         Bufferable();
19 public:
20         virtual ~Bufferable();
21
22         void use_buffer(Buffer *, Bufferable * = 0);
23 private:
24         void unlink_from_buffer();
25
26 protected:
27         virtual unsigned get_data_size() const = 0;
28
29         void update_buffer_offset();
30         virtual void offset_changed() { }
31
32         void update_buffer_data() const;
33         virtual void upload_data() const = 0;
34 };
35
36 } // namespace GL
37 } // namespace Msp
38
39 #endif