]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/vslider.cpp
Cache widget parts in meshes
[libs/gltk.git] / source / vslider.cpp
index 93e485ab6b77844039dda3646531af8ee70721fa..a32e484906c19b0944599a47f8b0932adde24b0b 100644 (file)
@@ -1,5 +1,5 @@
 #include <msp/gl/matrix.h>
-#include <msp/gl/transform.h>
+#include <msp/gl/meshbuilder.h>
 #include "graphic.h"
 #include "part.h"
 #include "style.h"
@@ -28,7 +28,7 @@ void VSlider::autosize()
        }
 }
 
-void VSlider::render_special(const Part &part) const
+void VSlider::rebuild_special(const Part &part, CachedPart &cache)
 {
        if(part.get_name()=="slider")
        {
@@ -39,10 +39,12 @@ void VSlider::render_special(const Part &part) const
                Geometry pgeom = part.get_geometry();
                align.apply(pgeom, geom, part.get_margin());
 
-               GL::push_matrix();
-               GL::translate(pgeom.x, pgeom.y, 0);
-               part.get_graphic(state)->render(pgeom.w, pgeom.h);
-               GL::pop_matrix();
+               cache.texture = part.get_graphic(state)->get_texture();
+               cache.clear_mesh();
+
+               GL::MeshBuilder bld(*cache.mesh);
+               bld.matrix() *= GL::Matrix::translation(pgeom.x, pgeom.y, 0);
+               part.get_graphic(state)->build(pgeom.w, pgeom.h, bld);
        }
 }