hmi.graphics.opengl
Class GLShaderProgramLoader

java.lang.Object
  extended by hmi.graphics.opengl.GLShaderProgramLoader

public class GLShaderProgramLoader
extends Object

A few static utility methods for loading and compiling GLSL shaders


Field Summary
static String DEFAULT_SHADER_RESOURCE_DIR
           
private static ResourcePool pool
           
 
Constructor Summary
GLShaderProgramLoader()
           
 
Method Summary
static void addShaderDirectory(String dir)
          Adds the specified directory as one of the resource directories for GLShaders
static GLShaderProgram getGLShaderProgram(String resourceName)
          Tries to get a GLShader with the specified resource name.
private static GLShaderProgram readFromResourceFile(Resources resources, String shaderProgramName)
          Loads a shader program, consisting of a vertex shader and a fragment shader, from two files, located within a resources directory.
private static String readShaderFromResourceFile(Resources resources, String shaderName)
          Loads a shader text from file, and returns the shader program text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pool

private static ResourcePool pool

DEFAULT_SHADER_RESOURCE_DIR

public static final String DEFAULT_SHADER_RESOURCE_DIR
See Also:
Constant Field Values
Constructor Detail

GLShaderProgramLoader

public GLShaderProgramLoader()
Method Detail

addShaderDirectory

public static void addShaderDirectory(String dir)
Adds the specified directory as one of the resource directories for GLShaders


getGLShaderProgram

public static GLShaderProgram getGLShaderProgram(String resourceName)
Tries to get a GLShader with the specified resource name. GLShader objects found and loaded will be cached. The flip and rescale attributes are used when the texture is loaded for the first time (not when a cached version is retrieved). They denote whether the image should be flipped vertically (usually they should for OpenGL texturing), and whether a non-power-of-two image should be rescaled to the next power-of-two size. (Default is to rescale)


readShaderFromResourceFile

private static String readShaderFromResourceFile(Resources resources,
                                                 String shaderName)
Loads a shader text from file, and returns the shader program text. The shader is searched for inside a resources directory.


readFromResourceFile

private static GLShaderProgram readFromResourceFile(Resources resources,
                                                    String shaderProgramName)
Loads a shader program, consisting of a vertex shader and a fragment shader, from two files, located within a resources directory. The vertex shader is supposed to be in a file with name shaderProgramName.vs, the fragment shader in shaderProgramName.fs The GLSL program handle is returned, or -1 when some error occurs.