private void EnableAttributes(ShaderProgram shader, Dictionary <object, VertexAttribute> attributes, int bufferID) { foreach (KeyValuePair <object, VertexAttribute> a in attributes) { int location = -1; if (a.Key is string) { location = shader.GetAttribute((string)a.Key); } else { location = (int)a.Key; } GL.EnableVertexAttribArray(location); GL.BindBuffer(BufferTarget.ArrayBuffer, bufferID); if (a.Value.type == VertexAttribPointerType.Int) { GL.VertexAttribIPointer(location, a.Value.size, VertexAttribIntegerType.Int, a.Value.stride, new System.IntPtr(a.Value.offset)); } else { GL.VertexAttribPointer(location, a.Value.size, a.Value.type, a.Value.normalized, a.Value.stride, a.Value.offset); } if (a.Value.instance) { GL.VertexAttribDivisor(location, a.Value.divisor); } } }
private void DisableAttributes(ShaderProgram shader, Dictionary <object, VertexAttribute> attributes) { foreach (KeyValuePair <object, VertexAttribute> a in attributes) { int location = -1; if (a.Key is string) { location = shader.GetAttribute((string)a.Key); } else { location = (int)a.Key; } GL.DisableVertexAttribArray(location); } }