Top Fields Constructors Methods
com.jogamp.opengl.util.glsl

public Class ShaderProgram

extends Object
Class Inheritance
Imports
com.jogamp.opengl.*, com.jogamp.common.os.Platform, java.util.HashSet, .Iterator, java.io.PrintStream

Field Summary

Modifier and TypeField and Description
private final HashSet<ShaderCode>
private final HashSet<ShaderCode>
private final int
private static int
private boolean
private boolean
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public synchronized void
add(final ShaderCode shaderCode)

Adds a new shader to this program.

public synchronized boolean

Returns:

true if the shader was successfully added, false if compilation failed.
add
(final GL2ES2 gl, final ShaderCode shaderCode, final PrintStream verboseOut)

Adds a new shader to a this non running program.

public synchronized boolean
contains(final ShaderCode shaderCode)

public synchronized void
destroy(final GL2ES2 gl)

Detaches all shader codes and deletes the program.

public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
private static synchronized int
public synchronized ShaderCode
getShader(final int id)

Warning slow O(n) operation ..

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public int
id()

returns the uniq shader id as an integer

public final synchronized boolean

Returns:

true if shader program is valid, i.e. not zero
init
(final GL2ES2 gl)

Creates the empty GL program object using GL2ES2#glCreateProgram(), if not already created.

public boolean
public boolean
public synchronized void
public int
program()

Returns the shader program name, which is non zero if valid.

public synchronized void
release(final GL2ES2 gl)

Detaches all shader codes and deletes the program, but leaves the shader code intact.

public synchronized void
release(final GL2ES2 gl, final boolean destroyShaderCode)

Detaches all shader codes and deletes the program.

public synchronized boolean

Returns:

true if all steps are valid, shader compilation, attachment and linking; otherwise false.
replaceShader
(final GL2ES2 gl, final ShaderCode
the to be replace Shader
oldShader
,
final ShaderCode
the new ShaderCode
newShader
,
final PrintStream
the optional verbose output stream
verboseOut
)

Replace a shader in a program and re-links the program.

public StringBuilder
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public synchronized void
useProgram(final GL2ES2 gl, boolean on)

public synchronized boolean
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

allShaderCodeback to summary
private final HashSet<ShaderCode> allShaderCode
attachedShaderCodeback to summary
private final HashSet<ShaderCode> attachedShaderCode
idback to summary
private final int id
nextIDback to summary
private static int nextID
programInUseback to summary
private boolean programInUse
programLinkedback to summary
private boolean programLinked
shaderProgramback to summary
private int shaderProgram

Constructor Detail

ShaderProgramback to summary
public ShaderProgram()

Method Detail

addback to summary
public synchronized void add(final ShaderCode shaderCode) throws GLException

Adds a new shader to this program.

This command does not compile and attach the shader, use add(GL2ES2, ShaderCode) for this purpose.

addback to summary
public synchronized boolean add(final GL2ES2 gl, final ShaderCode shaderCode, final PrintStream verboseOut)

Adds a new shader to a this non running program.

Compiles and attaches the shader, if not done yet.

Returns:boolean

true if the shader was successfully added, false if compilation failed.

containsback to summary
public synchronized boolean contains(final ShaderCode shaderCode)
destroyback to summary
public synchronized void destroy(final GL2ES2 gl)

Detaches all shader codes and deletes the program. Destroys the shader codes as well. Calls release(gl, true)

See Also
release(GL2ES2, boolean)
equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getNextIDback to summary
private static synchronized int getNextID()
getShaderback to summary
public synchronized ShaderCode getShader(final int id)

Warning slow O(n) operation ..

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
idback to summary
public int id()

returns the uniq shader id as an integer

initback to summary
public final synchronized boolean init(final GL2ES2 gl)

Creates the empty GL program object using GL2ES2#glCreateProgram(), if not already created.

Returns:boolean

true if shader program is valid, i.e. not zero

inUseback to summary
public boolean inUse()
linkedback to summary
public boolean linked()
notifyNotInUseback to summary
public synchronized void notifyNotInUse()
programback to summary
public int program()

Returns the shader program name, which is non zero if valid.

releaseback to summary
public synchronized void release(final GL2ES2 gl)

Detaches all shader codes and deletes the program, but leaves the shader code intact. Calls release(gl, false)

See Also
release(GL2ES2, boolean)
releaseback to summary
public synchronized void release(final GL2ES2 gl, final boolean destroyShaderCode)

Detaches all shader codes and deletes the program. If destroyShaderCode is true it destroys the shader codes as well.

replaceShaderback to summary
public synchronized boolean replaceShader(final GL2ES2 gl, final ShaderCode oldShader, final ShaderCode newShader, final PrintStream verboseOut)

Replace a shader in a program and re-links the program.

Parameters
oldShader:ShaderCode

the to be replace Shader

newShader:ShaderCode

the new ShaderCode

verboseOut:PrintStream

the optional verbose output stream

Returns:boolean

true if all steps are valid, shader compilation, attachment and linking; otherwise false.

See Also
ShaderState#glEnableVertexAttribArray, ShaderState#glDisableVertexAttribArray, ShaderState#glVertexAttribPointer, ShaderState#getVertexAttribPointer, ShaderState#glReleaseAllVertexAttributes, ShaderState#glResetAllVertexAttributes
toStringback to summary
public StringBuilder toString(StringBuilder sb)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
useProgramback to summary
public synchronized void useProgram(final GL2ES2 gl, boolean on)
validateProgramback to summary
public synchronized boolean validateProgram(final GL2ES2 gl, final PrintStream verboseOut)

Performs GL2ES2#glValidateProgram(int) via ShaderUtil#isProgramExecStatusValid(GL, int, PrintStream).

See Also
ShaderUtil#isProgramExecStatusValid(GL, int, PrintStream)