public virtual int GetAttributeIndex(VertexElementSemantic semantic, int index) { int res = this.customAttribues[(int)semantic - 1, index]; if (res == NullCustomAttributesIndex) { string attString = this.GetAttributeSemanticString(semantic); int attrib = GL.GetAttribLocation(this.glProgramHandle, attString); GLES2Config.GlCheckError(this); //sadly position is a special case if (attrib == NotFoundCustomAttributesIndex && semantic == VertexElementSemantic.Position) { attrib = GL.GetAttribLocation(this.glProgramHandle, "position"); GLES2Config.GlCheckError(this); } //for uv and other case the index is a part of the name if (attrib == NotFoundCustomAttributesIndex) { string attStringWithSemantic = attString + index.ToString(); attrib = GL.GetAttribLocation(this.glProgramHandle, attStringWithSemantic); GLES2Config.GlCheckError(this); } //update customAttributes with the index we found (or didnt' find) this.customAttribues[(int)semantic - 1, index] = attrib; res = attrib; } return(res); }
public override int GetAttributeIndex(Graphics.VertexElementSemantic semantic, int index) { int res = customAttribues[(int)semantic - 1, index]; if (res == NullCustomAttributesIndex) { int handle = vertexProgram.GLSLProgram.GLProgramHandle; string attString = GetAttributeSemanticString(semantic); int attrib = GL.GetAttribLocation(handle, attString); GLES2Config.GlCheckError(this); if (attrib == NotFoundCustomAttributesIndex && semantic == VertexElementSemantic.Position) { attrib = GL.GetAttribLocation(handle, "position"); GLES2Config.GlCheckError(this); } if (attrib == NotFoundCustomAttributesIndex) { string attStringWithSemantic = attString + index.ToString(); attrib = GL.GetAttribLocation(handle, attStringWithSemantic); GLES2Config.GlCheckError(this); } customAttribues[(int)semantic - 1, index] = attrib; res = attrib; } return(res); }