internal int GetLayout(VertexDescription description, Shader shader) { if (!OpenGLCapabilities.VertexAttribBinding) { throw new PlatformNotSupportedException("VertexAttribBinding (separat vertex attributes) are not supported by the driver"); } int layout; if (inputLayoutPool.TryGetValue(description, out layout)) { return(layout); } layout = GL.GenVertexArray(); if (OpenGLCapabilities.DirectStateAccess == DirectStateAccess.None) { BindManager.VertexArray = layout; int offset = 0; VertexElement[] elements = description.GetElements(); for (int i = 0; i < description.ElementCount; i++) { if (offset > OpenGLCapabilities.MaxVertexAttribBindingOffset) { throw new PlatformNotSupportedException("offset is higher than maximum supportet offset."); } GL.EnableVertexAttribArray(i); GL.VertexAttribBinding(i, 0); GL.VertexAttribFormat(i, GetComponentsOf(elements[i].Type), VertexAttribType.Float, false, offset); offset += GetSizeOf(elements[i].Type); } } else if (OpenGLCapabilities.DirectStateAccess == DirectStateAccess.Extension) { int offset = 0; VertexElement[] elements = description.GetElements(); for (int i = 0; i < description.ElementCount; i++) { if (offset > OpenGLCapabilities.MaxVertexAttribBindingOffset) { throw new PlatformNotSupportedException("offset is higher than maximum supportet offset."); } Ext.EnableVertexArrayAttrib(layout, i); Ext.VertexArrayVertexAttribBinding(layout, i, elements[i].UsageIndex); Ext.VertexArrayVertexAttribFormat(layout, i, GetComponentsOf(elements[i].Type), (OpenTK.Graphics.OpenGL.ExtDirectStateAccess)VertexAttribType.Float, false, offset); offset += GetSizeOf(elements[i].Type); } } inputLayoutPool.Add(description, layout); return(layout); }