This allows seamless switching of programs using almost same data but performing different artifacts.
A used ShaderState is attached to the current GL context
and can be retrieved via getShaderState(GL).
| Modifier and Type | Field and Description |
|---|---|
| private final HashMap | |
| private final HashMap | |
| private final HashMap | |
| private final HashMap | |
| private final HashMap | |
| private final HashMap | |
| public static final boolean | |
| private final ArrayList | |
| private final ArrayList | |
| private boolean | |
| private ShaderProgram | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final Object | Returns: the previous mapped object or null if noneAttach user object for the given name to this ShaderState. |
| public synchronized boolean | Returns: true if shader program was attached, otherwise false (already attached)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. |
| public void | bindAttribLocation(final GL2ES2 gl, final int location, final String name)
Binds a shader attribute to a location. |
| public void | bindAttribLocation(final GL2ES2 gl, final int location, final GLArrayData data)
Binds a shader |
| public synchronized void | |
| public final Object | Returns: the previous mapped object or null if nonename of the mapped object to detach name)
|
| public void | disableAllVertexAttributeArrays(final GL2ES2 gl, final boolean removeFromState)
Disables all vertex attribute arrays. |
| private boolean | |
| public boolean | Returns: false, if the name is not found, otherwise trueDisables a vertex attribute array
This method retrieves the the location via |
| public boolean | Returns: false, if the name is not found, otherwise trueDisables a vertex attribute array
This method uses the |
| private boolean | |
| public boolean | Returns: false, if the name is not found, otherwise trueEnables a vertex attribute array. |
| public boolean | Returns: false, if the name is not found, otherwise trueEnables a vertex attribute array, usually invoked by |
| public final Object | getAttachedObject(final String name)
Returns the attached user object for the given name to this ShaderState. |
| public int | Returns: -1 if there is no such attribute available, otherwise >= 0Gets the location of a shader attribute with given |
| public int | Returns: -1 if there is no such attribute available, otherwise >= 0Validates and returns the location of a shader attribute. |
| public GLArrayData | Returns: the GLArrayData object, null if not previously set.Get the previous cached vertex attribute data. |
| public int | Returns: -1 if there is no such attribute available, otherwise >= 0Gets the cached location of a shader attribute. |
| public final int | Returns: -1 if there is no such uniform available, otherwise >= 0Gets the cached location of the shader uniform. |
| public GLUniformData | Returns: the GLUniformData object, null if not previously set.Get the uniform data, previously set. |
| public final int | Returns: -1 if there is no such attribute available, otherwise >= 0Gets the location of a shader uniform with given |
| public int | Returns: -1 if there is no such attribute available, otherwise >= 0Validates and returns the location of a shader uniform. |
| public boolean | |
| public boolean | |
| public final boolean | |
| public final boolean | Returns: true if theGLArrayData attribute is enable
|
| public boolean | |
| public void | ownAttribute(final GLArrayData
the attribute, final boolean GLArrayData which lifecycle shall be managedtrue if owning shall be performs, false if disowning. own)Binds or unbinds the |
| public boolean | |
| public boolean | |
| public void | ownUniform(final GLUniformData
the uniform)GLUniformData which lifecycle shall be managedBind the |
| public synchronized void | |
| public void | releaseAllAttributes(final GL2ES2 gl)
Releases all mapped vertex attribute data, disables all enabled attributes and loses all indices |
| public synchronized void | |
| public void | |
| private final void | |
| private final void | |
| private final void | resetAllUniforms(final GL2ES2 gl)
Reset all previously mapped uniform data Uniform data and location is bound to the program, hence both are updated. |
| private final void | |
| private final void | |
| public void | |
| public ShaderProgram | |
| public StringBuilder | |
| public String | |
| public boolean | Returns: false, if the location could not be determined, otherwise trueSet the uniform data, if it's location is valid, i.e. ≥ 0. |
| public synchronized void | |
| public boolean | |
| public boolean | Returns: false, if the location could not be determined, otherwise trueSet the |
| activeAttribDataMap | back to summary |
|---|---|
| private final HashMap<String, GLArrayData> activeAttribDataMap | |
| activeAttribLocationMap | back to summary |
|---|---|
| private final HashMap<String, Integer> activeAttribLocationMap | |
| activedAttribEnabledMap | back to summary |
|---|---|
| private final HashMap<String, Boolean> activedAttribEnabledMap | |
| activeUniformDataMap | back to summary |
|---|---|
| private final HashMap<String, GLUniformData> activeUniformDataMap | |
| activeUniformLocationMap | back to summary |
|---|---|
| private final HashMap<String, Integer> activeUniformLocationMap | |
| attachedObjectsByString | back to summary |
|---|---|
| private final HashMap<String, Object> attachedObjectsByString | |
| DEBUG | back to summary |
|---|---|
| public static final boolean DEBUG | |
| managedAttributes | back to summary |
|---|---|
| private final ArrayList<GLArrayData> managedAttributes | |
| managedUniforms | back to summary |
|---|---|
| private final ArrayList<GLUniformData> managedUniforms | |
| resetAllShaderData | back to summary |
|---|---|
| private boolean resetAllShaderData | |
| shaderProgram | back to summary |
|---|---|
| private ShaderProgram shaderProgram | |
| verbose | back to summary |
|---|---|
| private boolean verbose | |
| ShaderState | back to summary |
|---|---|
| public ShaderState() | |
| attachObject | back to summary |
|---|---|
| public final Object attachObject(final String name, final Object obj) Attach user object for the given name to this ShaderState. Returns the previously set object or null.
| |
| attachShaderProgram | back to summary |
|---|---|
| public synchronized boolean attachShaderProgram(final GL2ES2 gl, final ShaderProgram prog, final boolean enable) throws GLException 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. [Re]sets all data and use program in case of a program switch. Use program,
| |
| bindAttribLocation | back to summary |
|---|---|
| public void bindAttribLocation(final GL2ES2 gl, final int location, final String name) Binds a shader attribute to a location.
Multiple names can be bound to one location.
The value will be cached and can be retrieved via
| |
| bindAttribLocation | back to summary |
|---|---|
| public void bindAttribLocation(final GL2ES2 gl, final int location, final GLArrayData data) Binds a shader
| |
| destroy | back to summary |
|---|---|
| public synchronized void destroy(final GL2ES2 gl) | |
| detachObject | back to summary |
|---|---|
| public final Object detachObject(final String name) | |
| disableAllVertexAttributeArrays | back to summary |
|---|---|
| public void disableAllVertexAttributeArrays(final GL2ES2 gl, final boolean removeFromState) Disables all vertex attribute arrays. Their enabled stated will be removed from this state only if 'removeFromState' is true. This method purpose is more for debugging. | |
| disableVertexAttribArray | back to summary |
|---|---|
| private boolean disableVertexAttribArray(final GL2ES2 gl, final String name, int location) | |
| disableVertexAttribArray | back to summary |
|---|---|
| public boolean disableVertexAttribArray(final GL2ES2 gl, final String name) Disables a vertex attribute array
This method retrieves the the location via
| |
| disableVertexAttribArray | back to summary |
|---|---|
| public boolean disableVertexAttribArray(final GL2ES2 gl, final GLArrayData data) Disables a vertex attribute array
This method uses the
| |
| enableVertexAttribArray | back to summary |
|---|---|
| private boolean enableVertexAttribArray(final GL2ES2 gl, final String name, int location) | |
| enableVertexAttribArray | back to summary |
|---|---|
| public boolean enableVertexAttribArray(final GL2ES2 gl, final String name) Enables a vertex attribute array.
This method retrieves the the location via
| |
| enableVertexAttribArray | back to summary |
|---|---|
| public boolean enableVertexAttribArray(final GL2ES2 gl, final GLArrayData data) Enables a vertex attribute array, usually invoked by
| |
| getAttachedObject | back to summary |
|---|---|
| public final Object getAttachedObject(final String name) Returns the attached user object for the given name to this ShaderState. | |
| getAttribLocation | back to summary |
|---|---|
| public int getAttribLocation(final GL2ES2 gl, final String name) Gets the location of a shader attribute with given
| |
| getAttribLocation | back to summary |
|---|---|
| public int getAttribLocation(final GL2ES2 gl, final GLArrayData data) Validates and returns the location of a shader attribute.
| |
| getAttribute | back to summary |
|---|---|
| public GLArrayData getAttribute(final String name) Get the previous cached vertex attribute data.
| |
| getCachedAttribLocation | back to summary |
|---|---|
| public int getCachedAttribLocation(final String name) Gets the cached location of a shader attribute.
| |
| getCachedUniformLocation | back to summary |
|---|---|
| public final int getCachedUniformLocation(final String name) Gets the cached location of the shader uniform.
| |
| getUniform | back to summary |
|---|---|
| public GLUniformData getUniform(final String name) Get the uniform data, previously set.
| |
| getUniformLocation | back to summary |
|---|---|
| public final int getUniformLocation(final GL2ES2 gl, final String name) Gets the location of a shader uniform with given
The current shader program (
| |
| getUniformLocation | back to summary |
|---|---|
| public int getUniformLocation(final GL2ES2 gl, final GLUniformData data) Validates and returns the location of a shader uniform.
The current shader program (
| |
| inUse | back to summary |
|---|---|
| public boolean inUse() | |
| isActiveAttribute | back to summary |
|---|---|
| public boolean isActiveAttribute(final GLArrayData attribute) | |
| isVertexAttribArrayEnabled | back to summary |
|---|---|
public final boolean isVertexAttribArrayEnabled(final String name)
| |
| isVertexAttribArrayEnabled | back to summary |
|---|---|
public final boolean isVertexAttribArrayEnabled(final GLArrayData data)
| |
| linked | back to summary |
|---|---|
| public boolean linked() | |
| ownAttribute | back to summary |
|---|---|
| public void ownAttribute(final GLArrayData attribute, final boolean own) Binds or unbinds the If an attribute location is cached (ie The attribute will be destroyed with The data will not be transfered to the GPU, use The data will also be
| |
| ownsAttribute | back to summary |
|---|---|
| public boolean ownsAttribute(final GLArrayData attribute) | |
| ownsUniform | back to summary |
|---|---|
| public boolean ownsUniform(final GLUniformData uniform) | |
| ownUniform | back to summary |
|---|---|
| public void ownUniform(final GLUniformData uniform) Bind the If a uniform location is cached it is promoted to the The attribute will be destroyed with The data will not be transfered to the GPU, use
| |
| release | back to summary |
|---|---|
| public synchronized void release(final GL2ES2 gl, final boolean destroyBoundAttributes, final boolean destroyShaderProgram, final boolean destroyShaderCode) | |
| releaseAllAttributes | back to summary |
|---|---|
| public void releaseAllAttributes(final GL2ES2 gl) Releases all mapped vertex attribute data, disables all enabled attributes and loses all indices | |
| releaseAllData | back to summary |
|---|---|
| public synchronized void releaseAllData(final GL2ES2 gl) | |
| releaseAllUniforms | back to summary |
|---|---|
| public void releaseAllUniforms(final GL2ES2 gl) Releases all mapped uniform data and loses all indices | |
| relocateAttribute | back to summary |
|---|---|
| private final void relocateAttribute(final GL2ES2 gl, final GLArrayData attribute) | |
| resetAllAttributes | back to summary |
|---|---|
| private final void resetAllAttributes(final GL2ES2 gl) Reset all previously enabled mapped vertex attribute data. Attribute data is bound to the GL state, i.e. VBO data itself will not be updated. Attribute location and it's data assignment is bound to the program, hence both are updated. Note Such update could only be prevented, if tracking am attribute/program dirty flag.
| |
| resetAllUniforms | back to summary |
|---|---|
| private final void resetAllUniforms(final GL2ES2 gl) Reset all previously mapped uniform data Uniform data and location is bound to the program, hence both are updated. Note Such update could only be prevented, if tracking a uniform/program dirty flag.
| |
| setAllAttributes | back to summary |
|---|---|
| private final void setAllAttributes(final GL2ES2 gl) preserves the attribute location .. (program not linked) | |
| setAttribute | back to summary |
|---|---|
| private final void setAttribute(final GL2ES2 gl, final GLArrayData attribute) | |
| setVerbose | back to summary |
|---|---|
| public void setVerbose(final boolean v) | |
| shaderProgram | back to summary |
|---|---|
| public ShaderProgram shaderProgram() | |
| toString | back to summary |
|---|---|
| public StringBuilder toString(StringBuilder sb, final boolean alsoUnlocated) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| uniform | back to summary |
|---|---|
| public boolean uniform(final GL2ES2 gl, final GLUniformData data) Set the uniform data, if it's location is valid, i.e. ≥ 0.
This method uses the
| |
| useProgram | back to summary |
|---|---|
| public synchronized void useProgram(final GL2ES2 gl, final boolean on) throws GLException Turns the shader program on or off.
| |
| verbose | back to summary |
|---|---|
| public boolean verbose() | |
| vertexAttribPointer | back to summary |
|---|---|
| public boolean vertexAttribPointer(final GL2ES2 gl, final GLArrayData data) Set the
This method uses the
| |