Class Glsl150ShaderGenerator

Direct Known Subclasses:
Glsl300ShaderGenerator

public class Glsl150ShaderGenerator extends Glsl100ShaderGenerator
This shader Generator can generate Vertex and Fragment shaders from ShaderNodes for GLSL 1.5
  • Constructor Details

    • Glsl150ShaderGenerator

      public Glsl150ShaderGenerator(AssetManager assetManager)
      Creates a Glsl150ShaderGenerator
      Parameters:
      assetManager - the assetmanager
  • Method Details

    • getLanguageAndVersion

      protected String getLanguageAndVersion(Shader.ShaderType type)
      Description copied from class: ShaderGenerator
      returns the language + version of the shader should be something like "GLSL100" for glsl 1.0 "GLSL150" for glsl 1.5.
      Overrides:
      getLanguageAndVersion in class Glsl100ShaderGenerator
      Parameters:
      type - the shader type for which the version should be returned.
      Returns:
      the shaderLanguage and version.
    • declareAttribute

      protected void declareAttribute(StringBuilder source, ShaderNodeVariable var)
      Declares an attribute in glsl 1.5 attributes are prefixed with the "in" keyword and not the "attribute" keyword
      Overrides:
      declareAttribute in class Glsl100ShaderGenerator
      Parameters:
      source - the StringBuilder to use
      var - the variable to declare as an attribute
    • declareVarying

      protected void declareVarying(StringBuilder source, ShaderNodeVariable var, boolean input)
      Declares a varying in glsl 1.5 varying are prefixed with the "in" or "out" keyword and not the "varying" keyword. "in" is used for Fragment shader (maybe Geometry shader later) "out" is used for Vertex shader (maybe Geometry shader later)
      Overrides:
      declareVarying in class Glsl100ShaderGenerator
      Parameters:
      source - the StringBuilder to use
      var - the variable to declare as a varying
      input - a boolean set to true if the varying is an input. This in not used in this implementation, but can be used in overriding implementations.
    • generateUniforms

      protected void generateUniforms(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type)
      Description copied from class: ShaderGenerator
      generates the uniforms declaration for a shader of the given type.
      Overrides:
      generateUniforms in class Glsl100ShaderGenerator
      Parameters:
      source - the source StringBuilder to append generated code.
      info - the ShaderGenerationInfo.
      type - the shader type the uniforms have to be generated for.
    • generateStartOfMainSection

      protected void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type)
      generates the start of the shader main section. this method is responsible of appending the "void main(){" in the shader and declaring all global outputs of the shader Shader outputs are declared and initialized inside the main section Fragment shader outputs are declared before the "void main(){" with the "out" keyword. After the "void main(){", the vertex output are declared and initialized and the fragment outputs are declared.
      Overrides:
      generateStartOfMainSection in class Glsl100ShaderGenerator
      Parameters:
      source - the StringBuilder to append generated code.
      info - the ShaderGenerationInfo.
      type - the shader type the section has to be generated for.
    • generateEndOfMainSection

      protected void generateEndOfMainSection(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type)
      Generates the end of the shader main section. This method is responsible for appending the last "}" in the shader and mapping all global outputs of the shader. outputs are assigned to built in glsl output. then the main section is closed This code accounts for multi render target and correctly output to gl_FragData if several output are declared for the fragment shader only vertex shader output are mapped here, since fragment shader outputs must have been mapped in the main section.
      Overrides:
      generateEndOfMainSection in class Glsl100ShaderGenerator
      Parameters:
      source - the StringBuilder to append generated code.
      info - the ShaderGenerationInfo.
      type - the shader type the section has to be generated for.
    • initVariable

      protected void initVariable(StringBuilder source, ShaderNodeVariable var, String initValue)
      Append a variable initialization to the code
      Parameters:
      source - the StringBuilder to use
      var - the variable to initialize
      initValue - the init value to assign to the variable