Package playn.core

Class GLProgram

java.lang.Object
playn.core.GLProgram
All Implemented Interfaces:
AutoCloseable, Closeable

public class GLProgram extends Object implements Closeable
Encapsulates a GL vertex and fragment shader program pair.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface react.Closeable

    Closeable.Set, Closeable.Util
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
    The GL id of this shader program.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GLProgram(GL20 gl, String vertexSource, String fragmentSource)
    Compiles and links the shader program described by vertexSource and fragmentSource.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Binds this shader program, in preparation for rendering.
    void
    Frees this program and associated compiled shaders.
    int
    Returns the attribute location with the specified name.
    int
    Returns the uniform location with the specified name.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • id

      public final int id
      The GL id of this shader program.
  • Constructor Details

    • GLProgram

      public GLProgram(GL20 gl, String vertexSource, String fragmentSource)
      Compiles and links the shader program described by vertexSource and fragmentSource.
      Throws:
      RuntimeException - if the program fails to compile or link.
  • Method Details

    • getUniformLocation

      public int getUniformLocation(String name)
      Returns the uniform location with the specified name.
    • getAttribLocation

      public int getAttribLocation(String name)
      Returns the attribute location with the specified name.
    • activate

      public void activate()
      Binds this shader program, in preparation for rendering.
    • close

      public void close()
      Frees this program and associated compiled shaders. The program must not be used after closure.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable