|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.opengl.util.glsl.ShaderState
public class ShaderState
Field Summary | |
---|---|
protected HashMap |
attribMap2Idx
|
static boolean |
DEBUG
|
protected HashSet |
enabledVertexAttribArraySet
|
protected ShaderProgram |
shaderProgram
|
protected HashMap |
uniformMap2Data
|
protected HashMap |
uniformMap2Idx
|
protected boolean |
verbose
|
protected HashMap |
vertexAttribMap2Data
|
Constructor Summary | |
---|---|
ShaderState()
|
Method Summary | |
---|---|
void |
attachShaderProgram(GL2ES2 gl,
ShaderProgram prog)
Attach or switch a shader program Attaching a shader program the first time, as well as switching to another program on the fly, while managing all attribute and uniform data. |
void |
destroy(GL2ES2 gl)
Calls release(gl, true, true) |
protected int |
getAttribLocation(String name)
|
static ShaderState |
getCurrent()
Fetches the current shader state from the thread local storage (TLS) |
GLUniformData |
getUniform(String name)
Get the uniform data, previously set. |
protected int |
getUniformLocation(String name)
|
GLArrayData |
getVertexAttribPointer(String name)
Get the vertex attribute data, previously set. |
void |
glBindAttribLocation(GL2ES2 gl,
int index,
String name)
Binds an attribute to the shader. |
void |
glDisableAllVertexAttributeArrays(GL2ES2 gl,
boolean removeFromState)
Disables all vertex attribute arrays. |
boolean |
glDisableVertexAttribArray(GL2ES2 gl,
String name)
Disables a vertex attribute array Even if the attribute is not found in the current shader, it is removed from this state. |
boolean |
glEnableVertexAttribArray(GL2ES2 gl,
String name)
Enable a vertex attribute array Even if the attribute is not found in the current shader, it is stored in this state. |
int |
glGetAttribLocation(GL2ES2 gl,
String name)
Gets the index of a shader attribute. |
protected int |
glGetUniformLocation(GL2ES2 gl,
String name)
Gets the index of a shader uniform. |
void |
glReleaseAllUniforms(GL2ES2 gl)
Releases all mapped uniform data and loses all indices |
void |
glReleaseAllVertexAttributes(GL2ES2 gl)
Releases all mapped vertex attribute data, disables all enabled attributes and loses all indices |
void |
glResetAllUniforms(GL2ES2 gl)
Reset all previously mapped uniform data |
void |
glResetAllVertexAttributes(GL2ES2 gl)
Reset all previously enabled mapped vertex attribute data, incl enabling them |
boolean |
glUniform(GL2ES2 gl,
GLUniformData data)
Set the uniform data. |
void |
glUseProgram(GL2ES2 gl,
boolean on)
Turns the shader program on or off. Puts this ShaderState to to the thread local storage (TLS), if on is true . |
boolean |
glVertexAttribPointer(GL2ES2 gl,
GLArrayData data)
Set the vertex attribute data. |
boolean |
inUse()
|
boolean |
isVertexAttribArrayEnabled(String name)
|
boolean |
linked()
|
void |
release(GL2ES2 gl,
boolean releaseProgramToo,
boolean releaseShaderToo)
|
void |
releaseAllData(GL2ES2 gl)
Calls release(gl, false, false) |
void |
setVerbose(boolean v)
|
ShaderProgram |
shaderProgram()
|
String |
toString()
|
boolean |
verbose()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final boolean DEBUG
protected boolean verbose
protected ShaderProgram shaderProgram
protected HashMap attribMap2Idx
protected HashSet enabledVertexAttribArraySet
protected HashMap vertexAttribMap2Data
protected HashMap uniformMap2Idx
protected HashMap uniformMap2Data
Constructor Detail |
---|
public ShaderState()
Method Detail |
---|
public boolean verbose()
public void setVerbose(boolean v)
public static ShaderState getCurrent()
javax.media.opengl.glsl.ShaderState#glUseProgram(GL2ES2, boolean)
,
javax.media.opengl.glsl.ShaderState#getCurrent()
public void glUseProgram(GL2ES2 gl, boolean on)
on
is true
.
javax.media.opengl.glsl.ShaderState#glUseProgram(GL2ES2, boolean)
,
javax.media.opengl.glsl.ShaderState#getCurrent()
public boolean linked()
public boolean inUse()
public void attachShaderProgram(GL2ES2 gl, ShaderProgram prog)
public ShaderProgram shaderProgram()
public void destroy(GL2ES2 gl)
glReleaseAllVertexAttributes(javax.media.opengl.GL2ES2)
,
glReleaseAllUniforms(javax.media.opengl.GL2ES2)
,
release(GL2ES2, boolean, boolean)
public void releaseAllData(GL2ES2 gl)
glReleaseAllVertexAttributes(javax.media.opengl.GL2ES2)
,
glReleaseAllUniforms(javax.media.opengl.GL2ES2)
,
release(GL2ES2, boolean, boolean)
public void release(GL2ES2 gl, boolean releaseProgramToo, boolean releaseShaderToo)
glReleaseAllVertexAttributes(javax.media.opengl.GL2ES2)
,
glReleaseAllUniforms(javax.media.opengl.GL2ES2)
,
ShaderProgram.release(GL2ES2, boolean)
public void glBindAttribLocation(GL2ES2 gl, int index, String name)
GLException
- is the program is already linkedglBindAttribLocation(javax.media.opengl.GL2ES2, int, java.lang.String)
,
GL2ES2.glBindAttribLocation(int, int, java.lang.String)
,
glGetAttribLocation(javax.media.opengl.GL2ES2, java.lang.String)
,
GL2ES2.glGetAttribLocation(int, java.lang.String)
,
getAttribLocation(java.lang.String)
,
#glReplaceShader
public int glGetAttribLocation(GL2ES2 gl, String name)
GLException
- is the program is not linkedglBindAttribLocation(javax.media.opengl.GL2ES2, int, java.lang.String)
,
GL2ES2.glBindAttribLocation(int, int, java.lang.String)
,
glGetAttribLocation(javax.media.opengl.GL2ES2, java.lang.String)
,
GL2ES2.glGetAttribLocation(int, java.lang.String)
,
getAttribLocation(java.lang.String)
,
#glReplaceShader
protected int getAttribLocation(String name)
public boolean glEnableVertexAttribArray(GL2ES2 gl, String name)
GLException
- if the program is not in useglEnableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glDisableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glVertexAttribPointer(javax.media.opengl.GL2ES2, javax.media.opengl.GLArrayData)
,
#getVertexAttributePointer
,
glReleaseAllVertexAttributes(javax.media.opengl.GL2ES2)
,
glResetAllVertexAttributes(javax.media.opengl.GL2ES2)
,
#glReplaceShader
public boolean isVertexAttribArrayEnabled(String name)
public boolean glDisableVertexAttribArray(GL2ES2 gl, String name)
GLException
- if the program is not in useglEnableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glDisableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glVertexAttribPointer(javax.media.opengl.GL2ES2, javax.media.opengl.GLArrayData)
,
#getVertexAttributePointer
,
glReleaseAllVertexAttributes(javax.media.opengl.GL2ES2)
,
glResetAllVertexAttributes(javax.media.opengl.GL2ES2)
,
#glReplaceShader
public boolean glVertexAttribPointer(GL2ES2 gl, GLArrayData data)
data
- the GLArrayData's name must match the attributes one,
it's index will be set with the attribute's location,
if found.
GLException
- if the program is not in useglEnableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glDisableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glVertexAttribPointer(javax.media.opengl.GL2ES2, javax.media.opengl.GLArrayData)
,
#getVertexAttributePointer
,
glReleaseAllVertexAttributes(javax.media.opengl.GL2ES2)
,
glResetAllVertexAttributes(javax.media.opengl.GL2ES2)
,
#glReplaceShader
public GLArrayData getVertexAttribPointer(String name)
glEnableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glDisableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glVertexAttribPointer(javax.media.opengl.GL2ES2, javax.media.opengl.GLArrayData)
,
#getVertexAttributePointer
,
glReleaseAllVertexAttributes(javax.media.opengl.GL2ES2)
,
glResetAllVertexAttributes(javax.media.opengl.GL2ES2)
,
#glReplaceShader
public void glReleaseAllVertexAttributes(GL2ES2 gl)
GLException
- is the program is not in use but the shaderProgram is setglEnableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glDisableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glVertexAttribPointer(javax.media.opengl.GL2ES2, javax.media.opengl.GLArrayData)
,
#getVertexAttributePointer
,
glReleaseAllVertexAttributes(javax.media.opengl.GL2ES2)
,
glResetAllVertexAttributes(javax.media.opengl.GL2ES2)
,
glResetAllVertexAttributes(javax.media.opengl.GL2ES2)
,
#glReplaceShader
public void glDisableAllVertexAttributeArrays(GL2ES2 gl, boolean removeFromState)
GLException
- is the program is not in use but the shaderProgram is setglEnableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glDisableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glVertexAttribPointer(javax.media.opengl.GL2ES2, javax.media.opengl.GLArrayData)
,
#getVertexAttributePointer
,
glReleaseAllVertexAttributes(javax.media.opengl.GL2ES2)
,
glResetAllVertexAttributes(javax.media.opengl.GL2ES2)
,
glResetAllVertexAttributes(javax.media.opengl.GL2ES2)
,
#glReplaceShader
public void glResetAllVertexAttributes(GL2ES2 gl)
GLException
- is the program is not in useglEnableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glDisableVertexAttribArray(javax.media.opengl.GL2ES2, java.lang.String)
,
glVertexAttribPointer(javax.media.opengl.GL2ES2, javax.media.opengl.GLArrayData)
,
#getVertexAttributePointer
,
glReleaseAllVertexAttributes(javax.media.opengl.GL2ES2)
,
glResetAllVertexAttributes(javax.media.opengl.GL2ES2)
,
#glReplaceShader
protected int glGetUniformLocation(GL2ES2 gl, String name)
GLException
- is the program is not linkedglGetUniformLocation(javax.media.opengl.GL2ES2, java.lang.String)
,
GL2ES2.glGetUniformLocation(int, java.lang.String)
,
getUniformLocation(java.lang.String)
,
#glReplaceShader
protected int getUniformLocation(String name)
public boolean glUniform(GL2ES2 gl, GLUniformData data)
data
- the GLUniforms's name must match the uniform one,
it's index will be set with the uniforms's location,
if found.
GLException
- if the program is not in useglGetUniformLocation(javax.media.opengl.GL2ES2, java.lang.String)
,
GL2ES2.glGetUniformLocation(int, java.lang.String)
,
getUniformLocation(java.lang.String)
,
#glReplaceShader
public GLUniformData getUniform(String name)
public void glReleaseAllUniforms(GL2ES2 gl)
GLException
- is the program is not in usepublic void glResetAllUniforms(GL2ES2 gl)
GLException
- is the program is not in usepublic String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |