Interface ProgramBuilder

All Known Implementing Classes:
ProgramBuilder.Abstract

public interface ProgramBuilder
Shader program pipeline builder utility class.

This class is used to generate linked shader programs in a "builder" way. Mostly useful for small applications and test applications, not necessarily for large enterprise applications that may employ better methods for shader loading and assembly.

All of these methods can be called outside of the graphics thread except create().

Depending on implementation version, some methods may not be supported or available, and will throw UnsupportedOperationException if so.

  • Method Details

    • attributeLocation

      ProgramBuilder attributeLocation(String attributeName, int locationId)
      Binds an attribute name to a specific location index.
      Parameters:
      attributeName - the attribute name.
      locationId - the location id.
      Returns:
      this builder.
    • fragmentDataLocation

      ProgramBuilder fragmentDataLocation(String attributeName, int index)
      Binds a fragment output attribute name to a specific output color index.
      Parameters:
      attributeName - the attribute name.
      index - the index.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if binding locations is unavailable in this version.
    • transformFeedbackVaryingNames

      ProgramBuilder transformFeedbackVaryingNames(FeedbackBufferType type, String... variableNames)
      Sets the transform feedback varying variables for the bound shader program, assuming that what is being built is a "transform feedback"-viable shader program, which entails a vertex shader
      Parameters:
      type - the feedback output type.
      variableNames - the names of the varying variables.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if binding varyings for transform is unavailable in this version.
    • setShader

      ProgramBuilder setShader(ShaderType type, File file)
      Sets a shader program and a shader source.
      Parameters:
      type - the shader type.
      file - the source file.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if the shader type is unavailable in this version.
    • setShader

      ProgramBuilder setShader(ShaderType type, File file, Charset encoding)
      Sets a shader program and a shader source.
      Parameters:
      type - the shader type.
      file - the source file.
      encoding - the file encoding type.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if the shader type is unavailable in this version.
    • setShader

      ProgramBuilder setShader(ShaderType type, InputStream in)
      Sets a shader program and a shader source.
      Parameters:
      type - the shader type.
      in - the input stream to read from.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if the provided shader type is unavailable in this version.
    • setShader

      ProgramBuilder setShader(ShaderType type, InputStream in, Charset encoding)
      Sets a shader program and a shader source.
      Parameters:
      type - the shader type.
      in - the input stream to read from.
      encoding - the file encoding type.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if the provided shader type is unavailable in this version.
    • setShader

      ProgramBuilder setShader(ShaderType type, Reader reader)
      Sets a shader program and a shader source.
      Parameters:
      type - the shader type.
      reader - the reader to read from.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if the provided shader type is unavailable in this version.
    • setShader

      ProgramBuilder setShader(ShaderType type, String source)
      Sets a shader program and a shader source.
      Parameters:
      type - the shader type.
      source - the string that contains the source code.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if the provided shader type is unavailable in this version.
    • setShader

      ProgramBuilder setShader(ShaderType type, Supplier<String> source)
      Sets a shader program and a shader source.
      Parameters:
      type - the shader type.
      source - the source code supplier.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if the provided shader type is unavailable in this version.
    • setListener

      ProgramBuilder setListener(ProgramBuilder.Listener listener)
      Sets a log listener to listen for builder events.
      Parameters:
      listener - the listener to set.
      Returns:
      this builder.
    • create

      OGLProgram create()
      Creates the program.
      Returns:
      the shader program created.
      Throws:
      GraphicsException - if the program could not be created.