public IVertexArray GetGlVao() { if (!dirty) { return(glVertexArray); } if (glVertexArray == null) { glVertexArray = infra.GlContext.Create.VertexArray(); } glVertexArray.DisableVertexAttributesStartingFrom(0); var indexOfPosition = vertexSet.ElementInfos.IndexOf(x => x.CommonSemantic == CommonVertexSemantic.Position); var indexOfNormal = vertexSet.ElementInfos.IndexOf(x => x.CommonSemantic == CommonVertexSemantic.Normal); var indexOfTexCoord = vertexSet.ElementInfos.IndexOf(x => x.CommonSemantic == CommonVertexSemantic.TexCoord); if (indexOfPosition.HasValue) { SetVertexAttrF(0, indexOfPosition.Value, VertexAttributeDimension.Three, VertexAttribPointerType.Float); } if (indexOfNormal.HasValue) { SetVertexAttrF(1, indexOfNormal.Value, VertexAttributeDimension.Three, VertexAttribPointerType.Float); } if (indexOfTexCoord.HasValue) { SetVertexAttrF(2, indexOfTexCoord.Value, VertexAttributeDimension.Two, VertexAttribPointerType.Float); } if (vertexSet.IndicesInfo != null) { var arraySubrange = vertexSet.ArraySubranges[vertexSet.IndicesInfo.ArrayIndex]; var rawDataRes = arraySubrange.RawDataResource; var arrayCache = rawDataRes.CacheContainer.GetOrAddCache(Tuples.Pair(infra, rawDataRes), x => new RawDataResCache(x.First, x.Second)); var glBuffer = arrayCache.GetGlIndexBuffer(arraySubrange.StartOffset); glVertexArray.SetElementArrayBuffer(glBuffer); } else { glVertexArray.SetElementArrayBuffer(null); } dirty = false; return(glVertexArray); }