use of com.gempukku.libgdx.graph.pipeline.RenderPipelineBuffer in project gdx-graph by MarcinSc.
the class UIRendererPipelineNodeProducer method createNodeForSingleInputs.
@Override
public PipelineNode createNodeForSingleInputs(JsonValue data, ObjectMap<String, String> inputTypes, ObjectMap<String, String> outputTypes) {
final String stageId = data.getString("id", "");
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 UIPluginPrivateData uiPluginData;
@Override
public void initializePipeline(PipelineDataProvider pipelineDataProvider) {
uiPluginData = pipelineDataProvider.getPrivatePluginData(UIPluginPrivateData.class);
}
@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");
final FieldOutput<Vector2> screenSizeInput = (FieldOutput<Vector2>) inputs.get("size");
RenderPipeline renderPipeline = renderPipelineInput.getValue();
boolean enabled = processorEnabled == null || processorEnabled.getValue();
Stage stage = uiPluginData.getStage(stageId);
if (enabled && stage != null) {
// Sadly need to switch off (and then on) the RenderContext
pipelineRenderingContext.getRenderContext().end();
RenderPipelineBuffer currentBuffer = renderPipeline.getDefaultBuffer();
int width = screenSizeInput != null ? MathUtils.round(screenSizeInput.getValue().x) : currentBuffer.getWidth();
int height = screenSizeInput != null ? MathUtils.round(screenSizeInput.getValue().y) : currentBuffer.getHeight();
int screenWidth = stage.getViewport().getScreenWidth();
int screenHeight = stage.getViewport().getScreenHeight();
if (screenWidth != width || screenHeight != height)
stage.getViewport().update(width, height, true);
currentBuffer.beginColor();
stage.draw();
currentBuffer.endColor();
pipelineRenderingContext.getRenderContext().begin();
}
output.setValue(renderPipeline);
}
};
}
Aggregations