use of com.gempukku.libgdx.graph.shader.field.ArrayShaderFieldType in project gdx-graph by MarcinSc.
the class GraphModelUtil method getShaderVertexAttributes.
public static VertexAttributes getShaderVertexAttributes(GraphModels graphModels, String tag) {
ObjectMap<String, PropertySource> shaderProperties = graphModels.getShaderProperties(tag);
if (shaderProperties == null)
throw new GdxRuntimeException("Unable to locate shader with tag: " + tag);
Array<VertexAttribute> vertexAttributeArray = new Array<>(VertexAttribute.class);
for (ObjectMap.Entry<String, PropertySource> shaderProperty : shaderProperties) {
PropertySource propertySource = shaderProperty.value;
PropertyLocation propertyLocation = propertySource.getPropertyLocation();
if (propertyLocation == PropertyLocation.Attribute) {
ShaderFieldType shaderFieldType = propertySource.getShaderFieldType();
if (shaderFieldType instanceof ArrayShaderFieldType) {
int arraySize = ((ArrayShaderFieldType) shaderFieldType).getArrayLength();
for (int i = 0; i < arraySize; i++) {
vertexAttributeArray.add(new VertexAttribute(1024, shaderFieldType.getNumberOfComponents(), propertySource.getAttributeName(i)));
}
} else {
vertexAttributeArray.add(new VertexAttribute(1024, shaderFieldType.getNumberOfComponents(), propertySource.getAttributeName()));
}
}
}
return new VertexAttributes(vertexAttributeArray.toArray());
}
Aggregations