hmi.graphics.opengl
Class GLSL

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

public class GLSL
extends Object

A few static utility methods for loading and compiling GLSL vertex and fragment shaders


Constructor Summary
GLSL()
           
 
Method Summary
static int compileShader(GLRenderContext gl, String[] shaderText, int shaderType)
          Compiles a shader program text, and returns the shader handle.
static int createShaderProgram(GLRenderContext gl, String[] vertexShaderText, String[] fragmentShaderText)
          Compiles vertex/frament program texts, allocates a shader program, attaches the compiles vertex and fragment shaders t the rogram, and links the program.
static int createShaderProgram(GLRenderContext gl, String vertexShaderText, String fragmentShaderText)
          Compiles vertex/frament program texts, allocates a shader program, attaches the compiles vertex and fragment shaders t the rogram, and links the program.
static int loadShaderProgram(GLRenderContext gl, 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.
static String loadShaderText(Resources resources, String shaderName)
          Loads a shader text from file, and returns the shadre program text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GLSL

public GLSL()
Method Detail

compileShader

public static int compileShader(GLRenderContext gl,
                                String[] shaderText,
                                int shaderType)
Compiles a shader program text, and returns the shader handle. If an error occurs, -1 is returned.


createShaderProgram

public static int createShaderProgram(GLRenderContext gl,
                                      String vertexShaderText,
                                      String fragmentShaderText)
Compiles vertex/frament program texts, allocates a shader program, attaches the compiles vertex and fragment shaders t the rogram, and links the program. The program handle is returned. If an error occurs, -1 is returned.


createShaderProgram

public static int createShaderProgram(GLRenderContext gl,
                                      String[] vertexShaderText,
                                      String[] fragmentShaderText)
Compiles vertex/frament program texts, allocates a shader program, attaches the compiles vertex and fragment shaders t the rogram, and links the program. The program handle is returned. If an error occurs, -1 is returned.


loadShaderText

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


loadShaderProgram

public static int loadShaderProgram(GLRenderContext gl,
                                    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.