]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/partcache.cpp
Use size_t to represent counts and indices
[libs/gltk.git] / source / partcache.cpp
index 3c3fbb169e3e2c20b707f20b6bdb25f656fc94fd..77b51d2cbc2096a101eb941b20e45f6b23568c6a 100644 (file)
@@ -6,21 +6,29 @@ using namespace std;
 namespace Msp {
 namespace GLtk {
 
-CachedPart::CachedPart():
-       part(0),
-       texture(0),
-       mesh(0)
-{ }
+CachedPart::CachedPart(CachedPart &&other):
+       part(other.part),
+       texture(other.texture),
+       mesh(other.mesh)
+{
+       other.mesh = nullptr;
+}
 
-CachedPart::~CachedPart()
+CachedPart &CachedPart::operator=(CachedPart &&other)
 {
        delete mesh;
+       part = other.part;
+       texture = other.texture;
+       mesh = other.mesh;
+       other.mesh = nullptr;
+       return *this;
 }
 
+CachedPart::~CachedPart()
+{
+       delete mesh;
+}
 
-PartCache::PartCache():
-       rebuilding(false)
-{ }
 
 void PartCache::begin_rebuild()
 {
@@ -75,7 +83,7 @@ GL::Mesh &PartCache::create_mesh(const Part &part, const GL::Texture2D &tex)
        {
                current = parts.insert(next, CachedPart());
                current->texture = &tex;
-               current->mesh = new GL::Mesh((GL::TEXCOORD2, GL::COLOR4_UBYTE, GL::VERTEX2));
+               current->mesh = new GL::Mesh((GL::TEXCOORD2, GL::COLOR4,GL::UNSIGNED_BYTE, GL::VERTEX2));
        }
        else
                current->mesh->clear();