use of io.xol.chunkstories.api.rendering.vertex.AttributeSource in project chunkstories by Hugobros3.
the class AttributesConfigurationImplementation method setup.
public void setup(RenderingInterface renderingInterface) {
ShaderGL shaderProgram = (ShaderGL) renderingInterface.currentShader();
Set<Integer> unusedAttributes = enabledVertexAttributes;
enabledVertexAttributes = new HashSet<Integer>(enabledVertexAttributes);
for (Entry<String, AttributeSource> e : attributes.entrySet()) {
String attributeName = e.getKey();
AttributeSource attributeSource = e.getValue();
int attributeLocation = shaderProgram.getVertexAttributeLocation(attributeName);
if (attributeLocation == -1)
continue;
unusedAttributes.remove(attributeLocation);
// Enable only when it wasn't
if (enabledVertexAttributes.add(attributeLocation))
glEnableVertexAttribArray(attributeLocation);
attributeSource.setup(attributeLocation);
}
// Disable and forget about unused ones
for (int unused : unusedAttributes) {
glDisableVertexAttribArray(unused);
enabledVertexAttributes.remove(unused);
}
}
Aggregations