org.deegree.rendering.r3d.opengl.rendering
Class ShaderProgram
java.lang.Object
org.deegree.rendering.r3d.opengl.rendering.ShaderProgram
public class ShaderProgram
- extends java.lang.Object
Compiles, attaches and links shader (vertex and fragment) shaders to a OpenGL shader program.
- Version:
- $Revision: 22364 $, $Date: 2010-02-03 12:58:11 +0100 (Mi, 03. Feb 2010) $
- Author:
- Rutger Bezema, last edited by: $Author: rbezema $
Method Summary |
boolean |
attachShader(javax.media.opengl.GL gl,
int shaderId)
|
int |
createFragmentShader(javax.media.opengl.GL glContext,
java.lang.String fragmentShaderSource)
|
int |
createVertexShader(javax.media.opengl.GL glContext,
java.lang.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 |
ShaderProgram
public ShaderProgram()
createVertexShader
public int createVertexShader(javax.media.opengl.GL glContext,
java.lang.String vertexShaderSource)
throws java.lang.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:
java.lang.RuntimeException
- if the shader could not be compiled or linked.
createFragmentShader
public int createFragmentShader(javax.media.opengl.GL glContext,
java.lang.String fragmentShaderSource)
throws java.lang.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:
java.lang.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 java.lang.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:
java.lang.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.