org.deegree.rendering.r3d.opengl.rendering
Class ShaderProgram

java.lang.Object
  extended by org.deegree.rendering.r3d.opengl.rendering.ShaderProgram

public class ShaderProgram
extends Object

Compiles, attaches and links shader (vertex and fragment) shaders to a OpenGL shader program.

Version:
$Revision: 30126 $, $Date: 2011-03-22 11:11:00 +0100 (Tue, 22 Mar 2011) $
Author:
Rutger Bezema, last edited by: $Author: aschmitz $

Constructor Summary
ShaderProgram()
           
 
Method Summary
 boolean attachShader(javax.media.opengl.GL gl, int shaderId)
           
 int createFragmentShader(javax.media.opengl.GL glContext, String fragmentShaderSource)
           
 int createVertexShader(javax.media.opengl.GL glContext, String vertexShaderSource)
           
 boolean detachShader(javax.media.opengl.GL gl, int shaderId)
           
 void disable(javax.media.opengl.GL gl)
          Disables this shader program and set the context to use the fixed shaders (0).
 int getOGLId()
           
 boolean isShaderIdValid(javax.media.opengl.GL gl, int shaderId)
           
 boolean linkProgram(javax.media.opengl.GL gl)
          Link this program with all it's attached shaders.
 boolean useProgram(javax.media.opengl.GL gl)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShaderProgram

public ShaderProgram()
Method Detail

createVertexShader

public int createVertexShader(javax.media.opengl.GL glContext,
                              String vertexShaderSource)
                       throws RuntimeException
Parameters:
glContext - the context for which this shader program was created.
vertexShaderSource - the program to attach and link against this open gl program.
Returns:
the id of the linked vertex shader.
Throws:
RuntimeException - if the shader could not be compiled or linked.

createFragmentShader

public int createFragmentShader(javax.media.opengl.GL glContext,
                                String fragmentShaderSource)
                         throws RuntimeException
Parameters:
glContext - the context for which this shader program was created.
fragmentShaderSource - the program to attach and link against this open gl program.
Returns:
the id of the linked vertex shader.
Throws:
RuntimeException - if the shader could not be compiled or linked.

useProgram

public boolean useProgram(javax.media.opengl.GL gl)
Parameters:
gl - context to enable this shader program for.
Returns:
true if the program is in use.

isShaderIdValid

public boolean isShaderIdValid(javax.media.opengl.GL gl,
                               int shaderId)
Parameters:
gl - the open gl context for which the given shader id should be valid.
shaderId - a vertex or fragment shader id to be tested.
Returns:
true if this shader program is valid and the open gl context thinks the given shader id is a valid shader id.

attachShader

public boolean attachShader(javax.media.opengl.GL gl,
                            int shaderId)
Parameters:
gl - the context of this shader program.
shaderId - to attach to this program.
Returns:
true iff this program and the given shader id are valid and the id could be attached to the program (attaching is not linking!).

linkProgram

public boolean linkProgram(javax.media.opengl.GL gl)
                    throws RuntimeException
Link this program with all it's attached shaders.

Parameters:
gl -
Returns:
true if the linkage was successful and the validation was positive.
Throws:
RuntimeException - if an OGL exception occurred.

detachShader

public boolean detachShader(javax.media.opengl.GL gl,
                            int shaderId)
Parameters:
gl - the context of this shader program.
shaderId - to be detached from this program.
Returns:
true iff the current program id and the given shaderId are valid and the shader could be detached from this program.

getOGLId

public int getOGLId()
Returns:
the ogl id of the this program.

disable

public void disable(javax.media.opengl.GL gl)
Disables this shader program and set the context to use the fixed shaders (0).

Parameters:
gl - context to be set.


Copyright © 2011. All Rights Reserved.