Class GLSLProgram


  • public class GLSLProgram
    extends Object
    Below is description of the GLSL program lifecycle, with Jzy3d methods, and underlying OpenGL methods.
    • load shaders with attachVertexShader() and attachFragmentShader()
      • glCreateShader
      • glShaderSource
      • glCompileShader
      • glGetShaderiv (verify status)
      • glGetShaderInfoLog (log errors)
    • link(gl) links the compiled shaders
      • glCreateProgram
      • glAttachShader
      • glLinkProgram
      • glGetProgramiv (verify status)
      • glGetProgramInfoLog (log errors)
      • glValidateProgram
    • bind(gl) mount the program @ rendering
      • glUseProgram
    • bindTextureRECT(gl)
    • unbind(gl) unmount the program @ rendering
      • glUseProgram(0)
    • destroy(gl)
      • glDeleteShader
      • glDeleteProgram
    • Constructor Detail

      • GLSLProgram

        public GLSLProgram()
    • Method Detail

      • link

        public void link​(com.jogamp.opengl.GL2 gl)
        Create a program and attach previously loaded and compiled shaders. Performs validation and warn according to program strictness.
      • bind

        public void bind​(com.jogamp.opengl.GL2 gl)
      • unbind

        public void unbind​(com.jogamp.opengl.GL2 gl)
      • destroy

        public void destroy​(com.jogamp.opengl.GL2 gl)
      • setUniform

        public void setUniform​(com.jogamp.opengl.GL2 gl,
                               String name,
                               float value)
      • setUniform

        public void setUniform​(com.jogamp.opengl.GL2 gl,
                               String name,
                               float[] values,
                               int count)
      • setTextureUnit

        public void setTextureUnit​(com.jogamp.opengl.GL2 gl,
                                   String texname,
                                   int texunit)
      • bindTexture

        public void bindTexture​(com.jogamp.opengl.GL2 gl,
                                int target,
                                String texname,
                                int texid,
                                int texunit)
      • bindTexture2D

        public void bindTexture2D​(com.jogamp.opengl.GL2 gl,
                                  String texname,
                                  int texid,
                                  int texunit)
      • bindTexture3D

        public void bindTexture3D​(com.jogamp.opengl.GL2 gl,
                                  String texname,
                                  int texid,
                                  int texunit)
      • bindTextureRECT

        public void bindTextureRECT​(com.jogamp.opengl.GL2 gl,
                                    String texname,
                                    int texid,
                                    int texunit)
      • loadAndCompileShaders

        public void loadAndCompileShaders​(com.jogamp.opengl.GL2 gl,
                                          ShaderFilePair files)
      • loadAndCompileVertexShader

        public void loadAndCompileVertexShader​(com.jogamp.opengl.GL2 gl,
                                               URL fileURL)
      • loadAndCompileVertexShader

        public void loadAndCompileVertexShader​(com.jogamp.opengl.GL2 gl,
                                               InputStream stream)
      • loadAndCompileVertexShader

        public void loadAndCompileVertexShader​(com.jogamp.opengl.GL2 gl,
                                               InputStream stream,
                                               URL infoURL)
        Parameters:
        gl -
        stream - shader source code ressource
        infoURL - only used as information for warnings if shader does not compile properly
      • loadAndCompileFragmentShader

        public void loadAndCompileFragmentShader​(com.jogamp.opengl.GL2 gl,
                                                 URL fileURL)
      • loadAndCompileFragmentShader

        public void loadAndCompileFragmentShader​(com.jogamp.opengl.GL2 gl,
                                                 InputStream stream)
      • loadAndCompileFragmentShader

        public void loadAndCompileFragmentShader​(com.jogamp.opengl.GL2 gl,
                                                 InputStream stream,
                                                 URL infoURL)
      • compileVertexShader

        public void compileVertexShader​(com.jogamp.opengl.GL2 gl,
                                        URL infoURL,
                                        String content)
      • compileFragmentShader

        public void compileFragmentShader​(com.jogamp.opengl.GL2 gl,
                                          URL infoURL,
                                          String content)
      • verifyShaderCompiled

        public void verifyShaderCompiled​(com.jogamp.opengl.GL2 gl,
                                         URL fileURL,
                                         int programId,
                                         String content)
      • verifyLinkStatus

        public void verifyLinkStatus​(com.jogamp.opengl.GL2 gl,
                                     int programId)
      • readErrors

        public String readErrors​(com.jogamp.opengl.GL2 gl,
                                 int iID)
      • validateProgram

        public void validateProgram​(com.jogamp.opengl.GL2 gl)
      • checkShaderLogInfo

        protected void checkShaderLogInfo​(com.jogamp.opengl.GL2 inGL,
                                          int inShaderObjectID)
      • warnScript

        protected void warnScript​(com.jogamp.opengl.GL2 gl,
                                  URL fileURL,
                                  String error,
                                  int compileStatus,
                                  int logLength,
                                  String content)
      • warnLink

        protected void warnLink​(com.jogamp.opengl.GL2 gl,
                                String error,
                                int linkStatus,
                                int logLength)
      • getProgramId

        public Integer getProgramId()