public int SetVertexAttributes(VertexBuffer[] vertexBuffers, int previousAttributesBound, int baseVertexOffset) { int totalSlotsBound = 0; for (int i = 0; i < VBLayoutsBySlot.Length; i++) { OpenGLESMaterialVertexInput input = VBLayoutsBySlot[i]; ((OpenGLESVertexBuffer)vertexBuffers[i]).Apply(); for (int slot = 0; slot < input.Elements.Length; slot++) { OpenGLESMaterialVertexInputElement element = input.Elements[slot]; int actualSlot = totalSlotsBound + slot; GL.EnableVertexAttribArray(actualSlot); Utilities.CheckLastGLES3Error(); int baseVertexOffsetBytes = baseVertexOffset * input.VertexSizeInBytes; GL.VertexAttribPointer(actualSlot, element.ElementCount, element.Type, element.Normalized, input.VertexSizeInBytes, element.Offset + baseVertexOffsetBytes); Utilities.CheckLastGLES3Error(); GL.VertexAttribDivisor(actualSlot, element.InstanceStepRate); Utilities.CheckLastGLES3Error(); } totalSlotsBound += input.Elements.Length; } for (int extraSlot = totalSlotsBound; extraSlot < previousAttributesBound; extraSlot++) { GL.DisableVertexAttribArray(extraSlot); Utilities.CheckLastGLES3Error(); } return(totalSlotsBound); }
public OpenGLESMaterialVertexInput(VertexInputDescription genericInput) { VertexSizeInBytes = genericInput.VertexSizeInBytes; Elements = new OpenGLESMaterialVertexInputElement[genericInput.Elements.Length]; int offset = 0; for (int i = 0; i < Elements.Length; i++) { var genericElement = genericInput.Elements[i]; Elements[i] = new OpenGLESMaterialVertexInputElement(genericElement, offset); offset += genericElement.SizeInBytes; } }