- static Buffer CacheShapes(const Shape[] shapes) {
- Vertex[] v = [];
- float[4][] c = [];
- foreach (const Shape s; shapes) {
- const Vector2f[] vertices = s.GetVertices();
- foreach (const Vector2f vec; vertices) {
- v ~= Vertex(vec.x, vec.y);
- }
- const Color[] colors = s.GetColor();
- foreach (const Color col; colors) {
- c ~= col.GLConvert();
- }
- }
- writefln(" >> Vertices: %d, Colors: %d", v.length, c.length);
- Buffer b = new Buffer(Type.ArrayBuffer, 2);
- b[0].Cache(c.ptr, c.length * float.sizeof * 4);
- b[1].Cache(v);
- v.clear();
- c.clear();
- return b;
- }