com.gempukku.libgdx.graph.plugin.sprites.SpriteShaderLoaderCallback Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of libgdx-graph Show documentation
Show all versions of libgdx-graph Show documentation
libGDX-graph runtime library for pipeline rendering
The newest version!
package com.gempukku.libgdx.graph.plugin.sprites;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.utils.JsonValue;
import com.gempukku.libgdx.graph.data.GraphConnection;
import com.gempukku.libgdx.graph.data.GraphNode;
import com.gempukku.libgdx.graph.data.GraphProperty;
import com.gempukku.libgdx.graph.data.GraphValidator;
import com.gempukku.libgdx.graph.data.NodeConfiguration;
import com.gempukku.libgdx.graph.loader.GraphDataLoaderCallback;
import com.gempukku.libgdx.graph.shader.GraphShaderBuilder;
import com.gempukku.libgdx.graph.shader.ShaderFieldType;
import com.gempukku.libgdx.graph.shader.config.GraphConfiguration;
import com.gempukku.libgdx.graph.shader.node.GraphShaderNodeBuilder;
public class SpriteShaderLoaderCallback extends GraphDataLoaderCallback {
private Texture defaultTexture;
private GraphConfiguration[] graphConfigurations;
public SpriteShaderLoaderCallback(Texture defaultTexture, GraphConfiguration... graphConfiguration) {
this.defaultTexture = defaultTexture;
graphConfigurations = graphConfiguration;
}
@Override
public void start() {
}
@Override
public SpriteGraphShader end() {
GraphValidator, GraphConnection, GraphProperty, ShaderFieldType> graphValidator = new GraphValidator<>();
GraphValidator.ValidationResult, GraphConnection, GraphProperty, ShaderFieldType> result = graphValidator.validateGraph(this, "end");
if (result.hasErrors())
throw new IllegalStateException("The graph contains errors, open it in the graph designer and correct them");
return GraphShaderBuilder.buildSpriteShader(defaultTexture, this, false);
}
@Override
protected ShaderFieldType getFieldType(String type) {
return ShaderFieldType.valueOf(type);
}
@Override
protected NodeConfiguration getNodeConfiguration(String type, JsonValue data) {
for (GraphConfiguration graphConfiguration : graphConfigurations) {
GraphShaderNodeBuilder graphShaderNodeBuilder = graphConfiguration.getGraphShaderNodeBuilder(type);
if (graphShaderNodeBuilder != null)
return graphShaderNodeBuilder.getConfiguration(data);
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy