- unsigned gw=(fill_x ? geom.w : width);
- unsigned gh=(fill_y ? geom.h : height);
- align.apply(geom, gw, gh);
- graphic[state]->render(gw, gh);
+ if(!graphic[state])
+ {
+ cache.texture = 0;
+ return;
+ }
+
+ cache.texture = graphic[state]->get_texture();
+ cache.clear_mesh();
+
+ Geometry rgeom = geom;
+ align.apply(rgeom, parent, margin);
+ GL::MeshBuilder bld(*cache.mesh);
+ bld.matrix() *= GL::Matrix::translation(rgeom.x, rgeom.y, 0);
+ graphic[state]->build(rgeom.w, rgeom.h, bld);