- static Buffer CacheShapes(const Shape[] shapes) {
- float[] values;
- foreach (const Shape s; shapes) {
- const Vector2f[] vertices = s.GetVertices();
- const Color[] colors = s.GetColor();
- const uint len = vertices.length;
- for (uint i = 0; i < len; ++i) {
- values ~= [vertices[i].x, vertices[i].y];
- if (i < colors.length) {
- values ~= colors[i].GLConvert();
- }
- }
- }
- Buffer b = new Buffer(Type.ArrayBuffer);
- b.Cache(&values[0], values.length * float.sizeof);
- values.clear();
- return b;
- }