de.grogra.imp3d.glsl.utility
Class GLSLShader

java.lang.Object
  extended by de.grogra.imp3d.glsl.utility.GLSLShader
All Implemented Interfaces:
GLSLOpenGLObject
Direct Known Subclasses:
GLSLManagedShader

public abstract class GLSLShader
extends java.lang.Object
implements GLSLOpenGLObject

Base for all complete shaders like

Author:
Konni Hartmann

Constructor Summary
GLSLShader(OpenGLState glState)
           
 
Method Summary
 void activateShader(OpenGLState glState, GLSLDisplay disp, java.lang.Object data)
          Only public method.
 void cleanup(OpenGLState glState, boolean javaonly)
           
 void deleteShader(javax.media.opengl.GL gl, boolean javaonly)
          Remove OpenGL side of this shader
protected abstract  java.lang.String[] getFragmentShader(java.lang.Object data)
           
 GLSLShader getInstance()
          For "hardcompiled" Shaders this method should return a new instance
 int getShaderProgramNumber()
          Getter for Shader Programnumber
protected  java.lang.String[] getVertexShader(java.lang.Object data)
           
 java.lang.Class instanceFor()
           
 boolean needsRecompilation(java.lang.Object data)
          Return false if Shader depends only on Uniforms
protected static void printProgramInfoLog(javax.media.opengl.GL gl, int program)
          Same as printShaderInfoLog only for Programs.
protected  void setupDynamicUniforms(javax.media.opengl.GL gl, GLSLDisplay disp, java.lang.Object data, int shaderNo)
          Function that loads uniforms of the represented Shader.
protected  void setupShader(javax.media.opengl.GL gl, GLSLDisplay disp, java.lang.Object data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GLSLShader

public GLSLShader(OpenGLState glState)
Method Detail

activateShader

public void activateShader(OpenGLState glState,
                           GLSLDisplay disp,
                           java.lang.Object data)
Only public method. Use this to activate (and compile) this Shader for use in rendering.

Parameters:
gl -
disp -
sh -
s -

cleanup

public void cleanup(OpenGLState glState,
                    boolean javaonly)
Specified by:
cleanup in interface GLSLOpenGLObject

deleteShader

public void deleteShader(javax.media.opengl.GL gl,
                         boolean javaonly)
Remove OpenGL side of this shader

Parameters:
gl -

getFragmentShader

protected abstract java.lang.String[] getFragmentShader(java.lang.Object data)
Parameters:
sh -
Returns:

getInstance

public GLSLShader getInstance()
For "hardcompiled" Shaders this method should return a new instance

Returns:

getShaderProgramNumber

public int getShaderProgramNumber()
Getter for Shader Programnumber

Returns:
the OpenGL id of the associated shader-program-id

getVertexShader

protected java.lang.String[] getVertexShader(java.lang.Object data)
Parameters:
sh -
Returns:

instanceFor

public java.lang.Class instanceFor()
Returns:
Class represented by this Shader

needsRecompilation

public boolean needsRecompilation(java.lang.Object data)
Return false if Shader depends only on Uniforms

Parameters:
s - Associated Shader
Returns:
true, if Sourcecode needs to be regenerated and recompiled

printProgramInfoLog

protected static void printProgramInfoLog(javax.media.opengl.GL gl,
                                          int program)
Same as printShaderInfoLog only for Programs.

Parameters:
gl -
program -

setupDynamicUniforms

protected void setupDynamicUniforms(javax.media.opengl.GL gl,
                                    GLSLDisplay disp,
                                    java.lang.Object data,
                                    int shaderNo)
Function that loads uniforms of the represented Shader.

Parameters:
gl -
disp - GLSLDisplay that tries using this shader
data - The GroIMP-Shader-Object represented by this shader.

setupShader

protected void setupShader(javax.media.opengl.GL gl,
                           GLSLDisplay disp,
                           java.lang.Object data)
Parameters:
gl -
disp -
s -