/** * Starts a conditional block * @param condition the block condition * @param source the StringBuilder to use */ protected void startCondition(String condition, StringBuilder source) { if (condition != null) { appendIndent(source); source.append("#if "); source.append(condition); source.append("\n"); indent(); } }
/** * {@inheritDoc} * * if the declaration contains no code nothing is done, else it's appended */ @Override protected void generateDeclarativeSection(StringBuilder source, ShaderNode shaderNode, String nodeSource, ShaderGenerationInfo info) { if (nodeSource.replaceAll("\\n", "").trim().length() > 0) { nodeSource = updateDefinesName(nodeSource, shaderNode); source.append("\n"); unIndent(); startCondition(shaderNode.getCondition(), source); source.append(nodeSource); source.append("\n"); endCondition(shaderNode.getCondition(), source); indent(); } }
/** * {@inheritDoc} * * Shader outputs are declared and initialized inside the main section */ @Override protected void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { source.append("\n"); source.append("void main() {\n"); indent(); appendIndent(source); if (type == ShaderType.Vertex) { declareGlobalPosition(info, source); } else if (type == ShaderType.Fragment) { for (ShaderNodeVariable global : info.getFragmentGlobals()) { declareVariable(source, global, "vec4(1.0)"); } } source.append("\n"); }
/** * Starts a conditional block * @param condition the block condition * @param source the StringBuilder to use */ protected void startCondition(String condition, StringBuilder source) { if (condition != null) { appendIndent(source); source.append("#if "); source.append(condition); source.append("\n"); indent(); } }
/** * {@inheritDoc} * * Shader outputs are declared and initialized inside the main section */ @Override protected void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { source.append("\n"); source.append("void main() {\n"); indent(); appendIndent(source); if (type == ShaderType.Vertex) { declareGlobalPosition(info, source); } else if (type == ShaderType.Fragment) { for (ShaderNodeVariable global : info.getFragmentGlobals()) { declareVariable(source, global, "vec4(1.0)"); } } source.append("\n"); }
/** * {@inheritDoc} * * if the declaration contains no code nothing is done, else it's appended */ @Override protected void generateDeclarativeSection(StringBuilder source, ShaderNode shaderNode, String nodeSource, ShaderGenerationInfo info) { if (nodeSource.replaceAll("\\n", "").trim().length() > 0) { nodeSource = updateDefinesName(nodeSource, shaderNode); source.append("\n"); unIndent(); startCondition(shaderNode.getCondition(), source); source.append(nodeSource); source.append("\n"); endCondition(shaderNode.getCondition(), source); indent(); } }