Search in sources :

Example 1 with RenderCallbackPrivateData

use of com.gempukku.libgdx.graph.plugin.callback.RenderCallbackPrivateData in project gdx-graph by MarcinSc.

the class RenderCallbackPipelineNodeProducer method createNodeForSingleInputs.

@Override
public PipelineNode createNodeForSingleInputs(JsonValue data, ObjectMap<String, String> inputTypes, ObjectMap<String, String> outputTypes) {
    final String callbackId = data.getString("callbackId", null);
    final ObjectMap<String, PipelineNode.FieldOutput<?>> result = new ObjectMap<>();
    final DefaultFieldOutput<RenderPipeline> output = new DefaultFieldOutput<>(PipelineFieldType.RenderPipeline);
    result.put("output", output);
    return new SingleInputsPipelineNode(result) {

        private PipelineDataProvider pipelineDataProvider;

        private RenderCallbackPrivateData renderCallbackData;

        @Override
        public void initializePipeline(PipelineDataProvider pipelineDataProvider) {
            renderCallbackData = pipelineDataProvider.getPrivatePluginData(RenderCallbackPrivateData.class);
            this.pipelineDataProvider = pipelineDataProvider;
        }

        @Override
        public void executeNode(PipelineRenderingContext pipelineRenderingContext, PipelineRequirementsCallback pipelineRequirementsCallback) {
            final PipelineNode.FieldOutput<Boolean> processorEnabled = (PipelineNode.FieldOutput<Boolean>) inputs.get("enabled");
            final PipelineNode.FieldOutput<RenderPipeline> renderPipelineInput = (PipelineNode.FieldOutput<RenderPipeline>) inputs.get("input");
            RenderPipeline renderPipeline = renderPipelineInput.getValue();
            boolean enabled = processorEnabled == null || processorEnabled.getValue();
            if (enabled) {
                RenderCallback callback = renderCallbackData.getRenderCallback(callbackId);
                callback.renderCallback(renderPipeline, pipelineDataProvider, pipelineRenderingContext, pipelineRequirementsCallback);
            }
            output.setValue(renderPipeline);
        }
    };
}
Also used : RenderCallbackPrivateData(com.gempukku.libgdx.graph.plugin.callback.RenderCallbackPrivateData) PipelineRenderingContext(com.gempukku.libgdx.graph.pipeline.producer.PipelineRenderingContext) RenderCallback(com.gempukku.libgdx.graph.plugin.callback.RenderCallback) ObjectMap(com.badlogic.gdx.utils.ObjectMap) RenderPipeline(com.gempukku.libgdx.graph.pipeline.RenderPipeline)

Aggregations

ObjectMap (com.badlogic.gdx.utils.ObjectMap)1 RenderPipeline (com.gempukku.libgdx.graph.pipeline.RenderPipeline)1 PipelineRenderingContext (com.gempukku.libgdx.graph.pipeline.producer.PipelineRenderingContext)1 RenderCallback (com.gempukku.libgdx.graph.plugin.callback.RenderCallback)1 RenderCallbackPrivateData (com.gempukku.libgdx.graph.plugin.callback.RenderCallbackPrivateData)1