Class CompiledProgram
java.lang.Object
cz.fidentis.analyst.glsl.code.impl.CompiledProgram
- All Implemented Interfaces:
GlslProgram
A proxy object storing the information about a GLSL program compiled on GPU.
The class follow the Builder principles. Usage:
CompiledProgram program = new CompiledProgram(...) .addShader(shader1) .addShader(shader2) .addShader(shader3) .compile();
-
Constructor Summary
ConstructorsConstructorDescriptionCompiledProgram
(com.jogamp.opengl.GLContext glContext, GlslProgramDef programDef) Links existing shaders into a program. -
Method Summary
Modifier and TypeMethodDescriptionaddShader
(CompiledShader shader) Links program with the given shader.compile()
Compiles the program on GPU.boolean
Returns the GLSL program definition which was used to create this program.int
Returns the ID of the program in the OpenGL contextint
getUniformLocation
(String key) Returns ID of the given named uniform location in the OpenGL context.int
hashCode()
void
release()
Ask GPU to release the program from its memory.void
setMat4fVar
(String varName, float[] value) Sets the value to a uniformMatrix4fv
variable defined in the compiled program.void
setNumberVar
(String varName, Number value) Sets the value to a uniform1f
or1i
variable defined in the compiled program.void
setVec4fVar
(String varName, float v1, float v2, float v3, float v4) Sets the value to a uniform4f
variable defined in the compiled program.
-
Constructor Details
-
CompiledProgram
Links existing shaders into a program.- Parameters:
glContext
- OpenGL context. Must not benull
. Must be at least GL2.programDef
- The definition of the program to be compiled- Throws:
com.jogamp.opengl.GLException
- if the program initiation fails
-
-
Method Details
-
addShader
Links program with the given shader.- Parameters:
shader
- compiled shader to be added to the program- Returns:
- this object
-
compile
Compiles the program on GPU.- Returns:
- this object
- Throws:
com.jogamp.opengl.GLException
- if the compilation fails
-
release
public void release()Ask GPU to release the program from its memory. -
equals
-
hashCode
public int hashCode() -
getProgramId
public int getProgramId()Description copied from interface:GlslProgram
Returns the ID of the program in the OpenGL context- Specified by:
getProgramId
in interfaceGlslProgram
- Returns:
- program's ID
-
getProgramDef
Description copied from interface:GlslProgram
Returns the GLSL program definition which was used to create this program.- Specified by:
getProgramDef
in interfaceGlslProgram
- Returns:
- program's definition
-
getUniformLocation
Description copied from interface:GlslProgram
Returns ID of the given named uniform location in the OpenGL context.- Specified by:
getUniformLocation
in interfaceGlslProgram
- Parameters:
key
- name- Returns:
- ID of the given named uniform location in the OpenGL context or -1
-
setMat4fVar
Description copied from interface:GlslProgram
Sets the value to a uniformMatrix4fv
variable defined in the compiled program.- Specified by:
setMat4fVar
in interfaceGlslProgram
- Parameters:
varName
- variable name (seeGlslProgramDef
)value
- Value to be assigned
-
setNumberVar
Description copied from interface:GlslProgram
Sets the value to a uniform1f
or1i
variable defined in the compiled program.- Specified by:
setNumberVar
in interfaceGlslProgram
- Parameters:
varName
- variable name (seeGlslProgramDef
)value
- Value to be assigned. Must be either float or integer
-
setVec4fVar
Description copied from interface:GlslProgram
Sets the value to a uniform4f
variable defined in the compiled program.- Specified by:
setVec4fVar
in interfaceGlslProgram
- Parameters:
varName
- variable name (seeGlslProgramDef
)v1
- First value to be assignedv2
- Second value to be assignedv3
- Third value to be assignedv4
- Fourth value to be assigned
-