public GlVertexArray(GlVertexBuffer <TVertex> vertices, GlIndexBuffer <TIndex> indices, Layout layout) { GlVbo = vertices; GlIbo = indices; Layout = layout; Handle = GL.GenVertexArray(); Bind(); Vbo.Bind(); Ibo.Bind(); int stride = 0; for (int i = 0; i < layout.Count; i++) { stride += Layout.GetSizeOf(layout[i].Type) * layout[i].Count; } int offset = 0; for (int i = 0; i < layout.Count; i++) { int location = layout.Shader.GetAttributeLocation(layout[i].AttributeName); GL.EnableVertexAttribArray(location); GL.VertexAttribPointer(location, layout[i].Count, GetAttribType(layout[i].Type), false, stride, offset); offset += Layout.GetSizeOf(layout[i].Type) * layout[i].Count; } }
public Renderer2D() { lastEntityOffset = 0; vao = new Vao(); vbo = new Vbo(BufferUsage.DynamicDraw, 100000); ibo = new Ibo(100000 * 6); // Set layouts for vbo vbo.PushLayout(new BufferLayout(2, VertexAttribType.Float, false)); // x, y vbo.PushLayout(new BufferLayout(4, VertexAttribType.Float, false)); // r, g, b, a vbo.PushLayout(new BufferLayout(2, VertexAttribType.Float, false)); // tx, ty vbo.PushLayout(new BufferLayout(1, VertexAttribType.Float, false)); // texture id }