|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectunc.cdva.graphics.models.ShaderProgram
public class ShaderProgram
Encapsulate a shader program. Load the source files of the shaders, compile them, link them, and activate them to alter the T&L of the rendering pipeline Do not use if you don't have a video card that supports vertex programs
Field Summary | |
---|---|
int |
fragmentObject
Fragment program id |
javax.media.opengl.GL |
gl
Open GL context |
int |
shaderObject
Program id |
java.lang.String[] |
sourceFragment
Source of the fragment program |
int[] |
sourceFragmentLength
Lengths of lines of the fragment program source |
java.lang.String[] |
sourceVertex
Source of the vertex program |
int[] |
sourceVertexLength
Lengths of lines of the vertex program source |
java.util.Hashtable<java.lang.String,float[]> |
uniformVariables
List of the uniform variables used by the program |
int |
vertexObject
Vertex program id |
Constructor Summary | |
---|---|
ShaderProgram(javax.media.opengl.GL gl)
Init an empty shader program |
|
ShaderProgram(java.lang.String vertexShader,
java.lang.String fragmentShader,
javax.media.opengl.GL gl)
Init a shader program, and load the source of the vertex and fragment program |
Method Summary | |
---|---|
void |
addUniformVariable(java.lang.String name,
float[] values)
Add a uniform variable to the program |
void |
compileShader()
Compile the vertex and fragment program, then link the shader program |
int[] |
computeLengths(java.lang.String[] source)
Compute the length of the lines of a source code |
void |
destroy()
Remove the shader program from the GPU memory |
java.lang.String[] |
loadSource(java.lang.String file)
Load a source file from the hard drive |
void |
printShaderLog(int object)
Display the compilation/linking log |
void |
removeUniformVariable(java.lang.String name)
Remove a uniform variable |
void |
setSourceFragment(java.lang.String fragmentFile)
|
void |
setSourceVertex(java.lang.String vertexFile)
|
void |
setUniformVariables()
Send the uniform variables to the GPU |
void |
stopUsing()
Deactivate the shader program |
java.lang.String |
toString()
|
void |
use()
Activate the shader program |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public java.lang.String[] sourceVertex
public int[] sourceVertexLength
public java.lang.String[] sourceFragment
public int[] sourceFragmentLength
public java.util.Hashtable<java.lang.String,float[]> uniformVariables
public javax.media.opengl.GL gl
public int shaderObject
public int vertexObject
public int fragmentObject
Constructor Detail |
---|
public ShaderProgram(javax.media.opengl.GL gl)
gl
- OpenGL contextpublic ShaderProgram(java.lang.String vertexShader, java.lang.String fragmentShader, javax.media.opengl.GL gl)
vertexShader
- vertex program source code pathfragmentShader
- fragmen program source code pathgl
- OpenGL contextMethod Detail |
---|
public void compileShader()
public void use()
public void stopUsing()
public void destroy()
public void printShaderLog(int object)
object
- id of the object you want to display the logpublic int[] computeLengths(java.lang.String[] source)
source
- source code
public java.lang.String[] loadSource(java.lang.String file)
file
- path of the source file
public void setSourceFragment(java.lang.String fragmentFile)
fragmentFile
- Path of the fragment file to load.public void setSourceVertex(java.lang.String vertexFile)
vertexFile
- Path of the vertex file to load.public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public void addUniformVariable(java.lang.String name, float[] values)
name
- name of the varialevalues
- values of the variablepublic void removeUniformVariable(java.lang.String name)
name
- name of the variablepublic void setUniformVariables()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |