]> git.tdb.fi Git - libs/gltk.git/blob - source/partcache.h
Add consistency checks to PartCache
[libs/gltk.git] / source / partcache.h
1 #ifndef MSP_GLTK_PARTCACHE_H_
2 #define MSP_GLTK_PARTCACHE_H_
3
4 #include <msp/gl/mesh.h>
5 #include <msp/gl/texture2d.h>
6
7 namespace Msp {
8 namespace GLtk {
9
10 class Part;
11
12 struct CachedPart
13 {
14         const Part *part;
15         const GL::Texture2D *texture;
16         GL::Mesh *mesh;
17
18         CachedPart();
19         ~CachedPart();
20 };
21
22 class PartCache
23 {
24 public:
25         typedef std::list<CachedPart> PartList;
26
27 private:
28         bool rebuilding;
29         PartList parts;
30         PartList::iterator next;
31         PartList::iterator current;
32
33 public:
34         PartCache();
35
36         void begin_rebuild();
37         void insert_special(const Part &);
38         GL::Mesh &create_mesh(const Part &, const GL::Texture2D &);
39         void end_rebuild();
40
41         const PartList &get_parts() const { return parts; }
42 };
43
44 } // namespace GLtk
45 } // namespace Msp
46
47 #endif