private void Flush() { modelBuffer.Bind(); modelBuffer.SetData(itemPool, itemCount); foreach (var attribute in descriptor.AttributeFormats) { var value = attribute.Value; material.Program.Attribute(attribute.Key).VertexAttributePointer( value.ComponentCount, value.ComponentType, value.IsNormalized, value.Stride, value.Offset ); material.Program.Attribute(attribute.Key).EnableVertexAttributeArray(); } material.Program.Use(); if (material.Matrix4Uniforms != null) { foreach (var matrix in material.Matrix4Uniforms) { var m = matrix.Value; material.Program.Uniform(matrix.Key).Set(ref m); } } if (material.Int32Uniforms != null) { foreach (var pair in material.Int32Uniforms) { material.Program.Uniform(pair.Key).Set(pair.Value); } } indicesBuffer.Bind(); for (int i = 0; i < textureCount; i++) { material.Program.Uniform("uSampler" + i).Set(i); context.Textures[i] = textures[i]; } int offset = 0; int vertexCount = indicesCount; context.DrawElements(WebGLDrawMode.TRIANGLES, offset, WebGLType.UNSIGNED_SHORT, vertexCount); itemCount = 0; indicesCount = 0; textureCount = 0; Flushed?.Invoke(this, EventArgs.Empty); }