com.jogamp.opengl.util.glsl
Class ShaderProgram

java.lang.Object
  extended by com.jogamp.opengl.util.glsl.ShaderProgram

public class ShaderProgram
extends Object


Constructor Summary
ShaderProgram()
           
 
Method Summary
 boolean add(GL2ES2 gl, ShaderCode shaderCode, PrintStream verboseOut)
          Adds a new shader to a this non running program.
 void add(ShaderCode shaderCode)
          Adds a new shader to this program.
 boolean contains(ShaderCode shaderCode)
           
 void destroy(GL2ES2 gl)
          Detaches all shader codes and deletes the program.
 boolean equals(Object obj)
           
 ShaderCode getShader(int id)
          Warning slow O(n) operation ..
 int hashCode()
           
 int id()
          returns the uniq shader id as an integer
 boolean init(GL2ES2 gl)
          Creates the empty GL program object using GL2ES2.glCreateProgram(), if not already created.
 boolean inUse()
           
 boolean link(GL2ES2 gl, PrintStream verboseOut)
          Links the shader code to the program.
 boolean linked()
           
 int program()
          Returns the shader program name, which is non zero if valid.
 void release(GL2ES2 gl)
          Detaches all shader codes and deletes the program, but leaves the shader code intact.
 void release(GL2ES2 gl, boolean destroyShaderCode)
          Detaches all shader codes and deletes the program.
 boolean replaceShader(GL2ES2 gl, ShaderCode oldShader, ShaderCode newShader, PrintStream verboseOut)
          Replace a shader in a program and re-links the program.
 String toString()
           
 StringBuilder toString(StringBuilder sb)
           
 void useProgram(GL2ES2 gl, boolean on)
           
 boolean validateProgram(GL2ES2 gl, PrintStream verboseOut)
          Performs GL2ES2.glValidateProgram(int) via ShaderUtil.isProgramExecStatusValid(GL, int, PrintStream).
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ShaderProgram

public ShaderProgram()
Method Detail

linked

public boolean linked()

inUse

public boolean inUse()

program

public int program()
Returns the shader program name, which is non zero if valid.


id

public int id()
returns the uniq shader id as an integer


destroy

public void destroy(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)

release

public void release(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)

release

public void release(GL2ES2 gl,
                    boolean destroyShaderCode)
Detaches all shader codes and deletes the program. If destroyShaderCode is true it destroys the shader codes as well.


add

public void add(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.

Throws:
GLException

contains

public boolean contains(ShaderCode shaderCode)

getShader

public ShaderCode getShader(int id)
Warning slow O(n) operation ..

Parameters:
id -
Returns:

init

public final boolean init(GL2ES2 gl)
Creates the empty GL program object using GL2ES2.glCreateProgram(), if not already created.

Parameters:
gl -
Returns:
true if shader program is valid, i.e. not zero

add

public boolean add(GL2ES2 gl,
                   ShaderCode shaderCode,
                   PrintStream verboseOut)
Adds a new shader to a this non running program.

Compiles and attaches the shader, if not done yet.

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

replaceShader

public boolean replaceShader(GL2ES2 gl,
                             ShaderCode oldShader,
                             ShaderCode newShader,
                             PrintStream verboseOut)
Replace a shader in a program and re-links the program.

Parameters:
gl -
oldShader - the to be replace Shader
newShader - the new ShaderCode
verboseOut - the optional verbose output stream
Returns:
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, ShaderState#glResetAllVertexAttributes, ShaderState#glResetAllVertexAttributes

link

public boolean link(GL2ES2 gl,
                    PrintStream verboseOut)
Links the shader code to the program.

Compiles and attaches the shader code to the program if not done by yet

Within this process, all GL resources (shader and program objects) are created if necessary.

Parameters:
gl -
verboseOut -
Returns:
true if program was successfully linked and is valid, otherwise false
See Also:
init(GL2ES2)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public StringBuilder toString(StringBuilder sb)

toString

public String toString()
Overrides:
toString in class Object

validateProgram

public boolean validateProgram(GL2ES2 gl,
                               PrintStream verboseOut)
Performs GL2ES2.glValidateProgram(int) via ShaderUtil.isProgramExecStatusValid(GL, int, PrintStream).

See Also:
ShaderUtil.isProgramExecStatusValid(GL, int, PrintStream)

useProgram

public void useProgram(GL2ES2 gl,
                       boolean on)


Copyright 2010 JogAmp Community.