]> git.tdb.fi Git - libs/gltk.git/blob - source/partcache.h
Add API declarations
[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 #include "mspgltk_api.h"
7
8 namespace Msp {
9 namespace GLtk {
10
11 class Part;
12
13 struct CachedPart
14 {
15         const Part *part;
16         const GL::Texture2D *texture;
17         GL::Mesh *mesh;
18
19         CachedPart();
20         ~CachedPart();
21 };
22
23 class MSPGLTK_API PartCache
24 {
25 public:
26         class Rebuild
27         {
28         private:
29                 PartCache &cache;
30
31         public:
32                 Rebuild(PartCache &c): cache(c) { cache.begin_rebuild(); }
33                 ~Rebuild() { cache.end_rebuild(); }
34         };
35
36         typedef std::list<CachedPart> PartList;
37
38 private:
39         bool rebuilding;
40         PartList parts;
41         PartList::iterator next;
42         PartList::iterator current;
43
44 public:
45         PartCache();
46
47         void begin_rebuild();
48         void insert_special(const Part &);
49         GL::Mesh &create_mesh(const Part &, const GL::Texture2D &);
50         void end_rebuild();
51
52         const PartList &get_parts() const { return parts; }
53 };
54
55 } // namespace GLtk
56 } // namespace Msp
57
58 #endif