de.grogra.imp3d.glsl.utility
Class CachedShaderCollection

java.lang.Object
  extended by de.grogra.imp3d.glsl.utility.CachedShaderCollection

public class CachedShaderCollection
extends java.lang.Object

Interface for all GLSLShaders. Activates / compiles and deletes shaderprograms. Holds a list of all GLSLShaders.

Author:
Konni Hartmann

Constructor Summary
CachedShaderCollection()
           
 
Method Summary
 void deleteAll(OpenGLState glState, boolean javaonly)
          Remove all compiled Shaders from shaderCache and shaderMap.
 void findAndActivateShader(OpenGLState glState, GLSLDisplay disp, ShaderConfiguration sc, Shader s)
          Will obtain and activate a GLSLShader to emulate the input shaders behavior.
 GLSLManagedShader findShader(OpenGLState glState, GLSLDisplay disp, ShaderConfiguration sc, Shader s)
          Will obtain a GLSLShader to emulate the input shaders behavior.
 GLSLManagedShader getCacheEntry(OpenGLState glState, GLSLDisplay disp, ShaderConfiguration sc, java.lang.Object s)
          Retrieve the cached entry for a Configuration/Object-Pair.
 GLSLManagedShader getCurrentShader()
          Get current active GLSLShader.
 void removeUnusedShaders(OpenGLState glState)
          Removes unused GLSLShaders from shaderCache
 void setCurrentStamp(int stamp)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachedShaderCollection

public CachedShaderCollection()
Method Detail

deleteAll

public void deleteAll(OpenGLState glState,
                      boolean javaonly)
Remove all compiled Shaders from shaderCache and shaderMap.

Parameters:
glState -

findAndActivateShader

public void findAndActivateShader(OpenGLState glState,
                                  GLSLDisplay disp,
                                  ShaderConfiguration sc,
                                  Shader s)
Will obtain and activate a GLSLShader to emulate the input shaders behavior. Will cache instances of GLSLShaders inside shaderCache

Parameters:
glState - current GL instance
disp - active GLDisplay instance
s - shader that should be activated

findShader

public GLSLManagedShader findShader(OpenGLState glState,
                                    GLSLDisplay disp,
                                    ShaderConfiguration sc,
                                    Shader s)
Will obtain a GLSLShader to emulate the input shaders behavior. Will cache instances of GLSLShaders inside shaderCache

Parameters:
glState - current GL instance
disp - active GLDisplay instance
s - shader that should be activated

getCacheEntry

public GLSLManagedShader getCacheEntry(OpenGLState glState,
                                       GLSLDisplay disp,
                                       ShaderConfiguration sc,
                                       java.lang.Object s)
Retrieve the cached entry for a Configuration/Object-Pair. If no entry exists method will generate and store a new one

Parameters:
sc -
s -
Returns:
the fetched managed Shader

getCurrentShader

public GLSLManagedShader getCurrentShader()
Get current active GLSLShader. Will only work for managed Shaders. If a non managed Shader is active result is undefined.

Returns:
returns active shader as corresponding GLSLShaderManagedShader

removeUnusedShaders

public void removeUnusedShaders(OpenGLState glState)
Removes unused GLSLShaders from shaderCache

Parameters:
glState -

setCurrentStamp

public void setCurrentStamp(int stamp)