]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/partcache.h
Add API declarations
[libs/gltk.git] / source / partcache.h
index b856f9da47a486151f3a10b62c51f1f0c60fb02c..9dc71bf184c8652de6b5e4939a8bab9224a2f512 100644 (file)
@@ -3,19 +3,53 @@
 
 #include <msp/gl/mesh.h>
 #include <msp/gl/texture2d.h>
+#include "mspgltk_api.h"
 
 namespace Msp {
 namespace GLtk {
 
+class Part;
+
 struct CachedPart
 {
+       const Part *part;
        const GL::Texture2D *texture;
        GL::Mesh *mesh;
 
        CachedPart();
        ~CachedPart();
+};
+
+class MSPGLTK_API PartCache
+{
+public:
+       class Rebuild
+       {
+       private:
+               PartCache &cache;
+
+       public:
+               Rebuild(PartCache &c): cache(c) { cache.begin_rebuild(); }
+               ~Rebuild() { cache.end_rebuild(); }
+       };
+
+       typedef std::list<CachedPart> PartList;
+
+private:
+       bool rebuilding;
+       PartList parts;
+       PartList::iterator next;
+       PartList::iterator current;
+
+public:
+       PartCache();
+
+       void begin_rebuild();
+       void insert_special(const Part &);
+       GL::Mesh &create_mesh(const Part &, const GL::Texture2D &);
+       void end_rebuild();
 
-       void clear_mesh();
+       const PartList &get_parts() const { return parts; }
 };
 
 } // namespace GLtk