Class GLShaderProgram

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class GLShaderProgram
    extends java.lang.Object
    implements java.io.Closeable
    OpenGL shader program
    • Constructor Summary

      Constructors 
      Constructor Description
      GLShaderProgram​(java.lang.String vertexShaderSource, java.lang.String fragmentShaderSource)
      Create a new insance of GLShaderProgram
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close resources
      int getAttributeLocation​(java.lang.String attributeName)
      Find in shader program an attribute by name and return attribute ID
      int getProgramId()
      Get OpenGL shader program Id
      int getUniformLocation​(java.lang.String uniformName)
      Find in shader program an uniform by name and return uniform ID
      void setUniformMat4​(int uniform, float[] mat4, int offset)  
      void setUniformTexture​(int uniform, int texture)  
      void setUniformVec2​(int uniform, float[] vec2, int offset)  
      void setUniformVec2​(int uniform, float x, float y)  
      void setUniformVec4​(int uniform, float[] vec4, int offset)  
      static void unuse()
      Stop using any previously used shader program
      void use()
      Use current shader program
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GLShaderProgram

        public GLShaderProgram​(java.lang.String vertexShaderSource,
                               java.lang.String fragmentShaderSource)
        Create a new insance of GLShaderProgram
        Parameters:
        vertexShaderSource - vertex shader program
        fragmentShaderSource - fragment shader program
    • Method Detail

      • close

        public void close()
        Close resources
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • use

        public void use()
        Use current shader program
      • unuse

        public static void unuse()
        Stop using any previously used shader program
      • getProgramId

        public int getProgramId()
        Get OpenGL shader program Id
        Returns:
        shader program id
      • getAttributeLocation

        public int getAttributeLocation​(java.lang.String attributeName)
        Find in shader program an attribute by name and return attribute ID
        Returns:
        found attrib Id or -1 in case of error
      • getUniformLocation

        public int getUniformLocation​(java.lang.String uniformName)
        Find in shader program an uniform by name and return uniform ID
        Returns:
        found uniform Id or -1 in case of error
      • setUniformTexture

        public void setUniformTexture​(int uniform,
                                      int texture)
      • setUniformMat4

        public void setUniformMat4​(int uniform,
                                   float[] mat4,
                                   int offset)
      • setUniformVec4

        public void setUniformVec4​(int uniform,
                                   float[] vec4,
                                   int offset)
      • setUniformVec2

        public void setUniformVec2​(int uniform,
                                   float x,
                                   float y)
      • setUniformVec2

        public void setUniformVec2​(int uniform,
                                   float[] vec2,
                                   int offset)