Package gaiasky.util.gdx.shader
Class TessellationShaderProgram
java.lang.Object
gaiasky.util.gdx.shader.ExtShaderProgram
gaiasky.util.gdx.shader.TessellationShaderProgram
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringdefault name for color attributesstatic booleanflag indicating whether attributes invalid input: '&' uniforms must be present at all timesstatic final Stringdefault name for position attributesstatic Stringcode that is always added to every fragment shader code, typically used to inject a #version line.static Stringstatic Stringstatic Stringcode that is always added to the vertex shader code, typically used to inject a #version line.static final Stringdefault name for texture coordinates attributes, append texture unit number -
Constructor Summary
ConstructorsConstructorDescriptionTessellationShaderProgram(String vertexShader, String tessellationControlShader, String tessellationEvaluationShader, String fragmentShader) -
Method Summary
Modifier and TypeMethodDescriptionvoidbegin()Makes OpenGL ES 2.0 use this vertex and fragment shader pair.static voidclearAllShaderPrograms(com.badlogic.gdx.Application app) protected intvoiddisableVertexAttribute(int location) voiddisableVertexAttribute(String name) Disables the vertex attribute with the given namevoiddispose()Disposes all resources associated with this shader.voidenableVertexAttribute(int location) voidenableVertexAttribute(String name) Enables the vertex attribute with the given namevoidend()Disables this shader.intfetchUniformLocation(String name, boolean pedantic) intgetAttributeLocation(String name) String[]intgetAttributeSize(String name) intgetAttributeType(String name) getLog()static Stringstatic intintgetUniformLocation(String name) String[]intgetUniformSize(String name) intgetUniformType(String name) booleanhasAttribute(String name) booleanhasUniform(String name) static voidinvalidateAllShaderPrograms(com.badlogic.gdx.Application app) Invalidates all shaders so the next time they are used new handles are generatedbooleanvoidsetAttributef(String name, float value1, float value2, float value3, float value4) Sets the given attributevoidsetUniform1fv(int location, float[] values, int offset, int length) voidsetUniform1fv(String name, float[] values, int offset, int length) voidsetUniform2fv(int location, float[] values, int offset, int length) voidsetUniform2fv(String name, float[] values, int offset, int length) voidsetUniform3fv(int location, float[] values, int offset, int length) voidsetUniform3fv(String name, float[] values, int offset, int length) voidsetUniform4fv(int location, float[] values, int offset, int length) voidsetUniform4fv(String name, float[] values, int offset, int length) voidsetUniformf(int location, float value) voidsetUniformf(int location, float value1, float value2) voidsetUniformf(int location, float value1, float value2, float value3) voidsetUniformf(int location, float value1, float value2, float value3, float value4) voidsetUniformf(int location, com.badlogic.gdx.graphics.Color values) voidsetUniformf(int location, com.badlogic.gdx.math.Vector2 values) voidsetUniformf(int location, com.badlogic.gdx.math.Vector3 values) voidsetUniformf(String name, float value) Sets the uniform with the given name.voidsetUniformf(String name, float value1, float value2) Sets the uniform with the given name.voidsetUniformf(String name, float value1, float value2, float value3) Sets the uniform with the given name.voidsetUniformf(String name, float value1, float value2, float value3, float value4) Sets the uniform with the given name.voidsetUniformf(String name, com.badlogic.gdx.graphics.Color values) Sets the uniform with the given name.voidsetUniformf(String name, com.badlogic.gdx.math.Vector2 values) Sets the uniform with the given name.voidsetUniformf(String name, com.badlogic.gdx.math.Vector3 values) Sets the uniform with the given name.voidsetUniformi(int location, int value) voidsetUniformi(int location, int value1, int value2) voidsetUniformi(int location, int value1, int value2, int value3) voidsetUniformi(int location, int value1, int value2, int value3, int value4) voidsetUniformi(String name, int value) Sets the uniform with the given name.voidsetUniformi(String name, int value1, int value2) Sets the uniform with the given name.voidsetUniformi(String name, int value1, int value2, int value3) Sets the uniform with the given name.voidsetUniformi(String name, int value1, int value2, int value3, int value4) Sets the uniform with the given name.voidsetUniformMatrix(int location, com.badlogic.gdx.math.Matrix3 matrix) voidsetUniformMatrix(int location, com.badlogic.gdx.math.Matrix3 matrix, boolean transpose) voidsetUniformMatrix(int location, com.badlogic.gdx.math.Matrix4 matrix) voidsetUniformMatrix(int location, com.badlogic.gdx.math.Matrix4 matrix, boolean transpose) voidsetUniformMatrix(String name, com.badlogic.gdx.math.Matrix3 matrix) Sets the uniform matrix with the given name.voidsetUniformMatrix(String name, com.badlogic.gdx.math.Matrix3 matrix, boolean transpose) Sets the uniform matrix with the given name.voidsetUniformMatrix(String name, com.badlogic.gdx.math.Matrix4 matrix) Sets the uniform matrix with the given name.voidsetUniformMatrix(String name, com.badlogic.gdx.math.Matrix4 matrix, boolean transpose) Sets the uniform matrix with the given name.voidsetUniformMatrix3fv(String name, FloatBuffer buffer, int count, boolean transpose) Sets an array of uniform matrices with the given name.voidsetUniformMatrix4fv(int location, float[] values, int offset, int length) voidsetUniformMatrix4fv(String name, float[] values, int offset, int length) voidsetUniformMatrix4fv(String name, FloatBuffer buffer, int count, boolean transpose) Sets an array of uniform matrices with the given name.voidsetVertexAttribute(int location, int size, int type, boolean normalize, int stride, int offset) voidsetVertexAttribute(int location, int size, int type, boolean normalize, int stride, Buffer buffer) voidsetVertexAttribute(String name, int size, int type, boolean normalize, int stride, int offset) Sets the vertex attribute with the given name.voidsetVertexAttribute(String name, int size, int type, boolean normalize, int stride, Buffer buffer) Sets the vertex attribute with the given name.
-
Field Details
-
POSITION_ATTRIBUTE
default name for position attributes- See Also:
-
COLOR_ATTRIBUTE
default name for color attributes- See Also:
-
TEXCOORD_ATTRIBUTE
default name for texture coordinates attributes, append texture unit number- See Also:
-
pedantic
public static boolean pedanticflag indicating whether attributes invalid input: '&' uniforms must be present at all times -
prependVertexCode
code that is always added to the vertex shader code, typically used to inject a #version line. Note that this is added as-is, you should include a newline (`\n`) if needed. -
prependTessControlCode
-
prependTessEvaluationCode
-
prependFragmentCode
code that is always added to every fragment shader code, typically used to inject a #version line. Note that this is added as-is, you should include a newline (`\n`) if needed.
-
-
Constructor Details
-
TessellationShaderProgram
-
-
Method Details
-
createProgram
protected int createProgram()- Overrides:
createProgramin classExtShaderProgram
-
getLog
- Overrides:
getLogin classExtShaderProgram- Returns:
- the log info for the shader compilation and program linking stage. The shader needs to be bound for this method to have an effect.
-
isCompiled
public boolean isCompiled()- Overrides:
isCompiledin classExtShaderProgram- Returns:
- whether this ShaderProgram compiled successfully.
-
fetchUniformLocation
- Overrides:
fetchUniformLocationin classExtShaderProgram
-
setUniformi
Sets the uniform with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformiin classExtShaderProgram- Parameters:
name- the name of the uniformvalue- the value
-
setUniformi
public void setUniformi(int location, int value) - Overrides:
setUniformiin classExtShaderProgram
-
setUniformi
Sets the uniform with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformiin classExtShaderProgram- Parameters:
name- the name of the uniformvalue1- the first valuevalue2- the second value
-
setUniformi
public void setUniformi(int location, int value1, int value2) - Overrides:
setUniformiin classExtShaderProgram
-
setUniformi
Sets the uniform with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformiin classExtShaderProgram- Parameters:
name- the name of the uniformvalue1- the first valuevalue2- the second valuevalue3- the third value
-
setUniformi
public void setUniformi(int location, int value1, int value2, int value3) - Overrides:
setUniformiin classExtShaderProgram
-
setUniformi
Sets the uniform with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformiin classExtShaderProgram- Parameters:
name- the name of the uniformvalue1- the first valuevalue2- the second valuevalue3- the third valuevalue4- the fourth value
-
setUniformi
public void setUniformi(int location, int value1, int value2, int value3, int value4) - Overrides:
setUniformiin classExtShaderProgram
-
setUniformf
Sets the uniform with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformfin classExtShaderProgram- Parameters:
name- the name of the uniformvalue- the value
-
setUniformf
public void setUniformf(int location, float value) - Overrides:
setUniformfin classExtShaderProgram
-
setUniformf
Sets the uniform with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformfin classExtShaderProgram- Parameters:
name- the name of the uniformvalue1- the first valuevalue2- the second value
-
setUniformf
public void setUniformf(int location, float value1, float value2) - Overrides:
setUniformfin classExtShaderProgram
-
setUniformf
Sets the uniform with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformfin classExtShaderProgram- Parameters:
name- the name of the uniformvalue1- the first valuevalue2- the second valuevalue3- the third value
-
setUniformf
public void setUniformf(int location, float value1, float value2, float value3) - Overrides:
setUniformfin classExtShaderProgram
-
setUniformf
Sets the uniform with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformfin classExtShaderProgram- Parameters:
name- the name of the uniformvalue1- the first valuevalue2- the second valuevalue3- the third valuevalue4- the fourth value
-
setUniformf
public void setUniformf(int location, float value1, float value2, float value3, float value4) - Overrides:
setUniformfin classExtShaderProgram
-
setUniform1fv
- Overrides:
setUniform1fvin classExtShaderProgram
-
setUniform1fv
public void setUniform1fv(int location, float[] values, int offset, int length) - Overrides:
setUniform1fvin classExtShaderProgram
-
setUniform2fv
- Overrides:
setUniform2fvin classExtShaderProgram
-
setUniform2fv
public void setUniform2fv(int location, float[] values, int offset, int length) - Overrides:
setUniform2fvin classExtShaderProgram
-
setUniform3fv
- Overrides:
setUniform3fvin classExtShaderProgram
-
setUniform3fv
public void setUniform3fv(int location, float[] values, int offset, int length) - Overrides:
setUniform3fvin classExtShaderProgram
-
setUniform4fv
- Overrides:
setUniform4fvin classExtShaderProgram
-
setUniform4fv
public void setUniform4fv(int location, float[] values, int offset, int length) - Overrides:
setUniform4fvin classExtShaderProgram
-
setUniformMatrix
Sets the uniform matrix with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformMatrixin classExtShaderProgram- Parameters:
name- the name of the uniformmatrix- the matrix
-
setUniformMatrix
Sets the uniform matrix with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformMatrixin classExtShaderProgram- Parameters:
name- the name of the uniformmatrix- the matrixtranspose- whether the matrix should be transposed
-
setUniformMatrix
public void setUniformMatrix(int location, com.badlogic.gdx.math.Matrix4 matrix) - Overrides:
setUniformMatrixin classExtShaderProgram
-
setUniformMatrix
public void setUniformMatrix(int location, com.badlogic.gdx.math.Matrix4 matrix, boolean transpose) - Overrides:
setUniformMatrixin classExtShaderProgram
-
setUniformMatrix
Sets the uniform matrix with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformMatrixin classExtShaderProgram- Parameters:
name- the name of the uniformmatrix- the matrix
-
setUniformMatrix
Sets the uniform matrix with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformMatrixin classExtShaderProgram- Parameters:
name- the name of the uniformmatrix- the matrixtranspose- whether the uniform matrix should be transposed
-
setUniformMatrix
public void setUniformMatrix(int location, com.badlogic.gdx.math.Matrix3 matrix) - Overrides:
setUniformMatrixin classExtShaderProgram
-
setUniformMatrix
public void setUniformMatrix(int location, com.badlogic.gdx.math.Matrix3 matrix, boolean transpose) - Overrides:
setUniformMatrixin classExtShaderProgram
-
setUniformMatrix3fv
Sets an array of uniform matrices with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformMatrix3fvin classExtShaderProgram- Parameters:
name- the name of the uniformbuffer- buffer containing the matrix datatranspose- whether the uniform matrix should be transposed
-
setUniformMatrix4fv
Sets an array of uniform matrices with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformMatrix4fvin classExtShaderProgram- Parameters:
name- the name of the uniformbuffer- buffer containing the matrix datatranspose- whether the uniform matrix should be transposed
-
setUniformMatrix4fv
public void setUniformMatrix4fv(int location, float[] values, int offset, int length) - Overrides:
setUniformMatrix4fvin classExtShaderProgram
-
setUniformMatrix4fv
- Overrides:
setUniformMatrix4fvin classExtShaderProgram
-
setUniformf
Sets the uniform with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformfin classExtShaderProgram- Parameters:
name- the name of the uniformvalues- x and y as the first and second values respectively
-
setUniformf
public void setUniformf(int location, com.badlogic.gdx.math.Vector2 values) - Overrides:
setUniformfin classExtShaderProgram
-
setUniformf
Sets the uniform with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformfin classExtShaderProgram- Parameters:
name- the name of the uniformvalues- x, y and z as the first, second and third values respectively
-
setUniformf
public void setUniformf(int location, com.badlogic.gdx.math.Vector3 values) - Overrides:
setUniformfin classExtShaderProgram
-
setUniformf
Sets the uniform with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setUniformfin classExtShaderProgram- Parameters:
name- the name of the uniformvalues- r, g, b and a as the first through fourth values respectively
-
setUniformf
public void setUniformf(int location, com.badlogic.gdx.graphics.Color values) - Overrides:
setUniformfin classExtShaderProgram
-
setVertexAttribute
public void setVertexAttribute(String name, int size, int type, boolean normalize, int stride, Buffer buffer) Sets the vertex attribute with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setVertexAttributein classExtShaderProgram- Parameters:
name- the attribute namesize- the number of components, must be >= 1 and invalid input: '<'= 4type- the type, must be one of GL20.GL_BYTE, GL20.GL_UNSIGNED_BYTE, GL20.GL_SHORT, GL20.GL_UNSIGNED_SHORT,GL20.GL_FIXED, or GL20.GL_FLOAT. GL_FIXED will not work on the desktopnormalize- whether fixed point data should be normalized. Will not work on the desktopstride- the stride in bytes between successive attributesbuffer- the buffer containing the vertex attributes.
-
setVertexAttribute
public void setVertexAttribute(int location, int size, int type, boolean normalize, int stride, Buffer buffer) - Overrides:
setVertexAttributein classExtShaderProgram
-
setVertexAttribute
public void setVertexAttribute(String name, int size, int type, boolean normalize, int stride, int offset) Sets the vertex attribute with the given name. TheShaderProgrammust be bound for this to work.- Overrides:
setVertexAttributein classExtShaderProgram- Parameters:
name- the attribute namesize- the number of components, must be >= 1 and invalid input: '<'= 4type- the type, must be one of GL20.GL_BYTE, GL20.GL_UNSIGNED_BYTE, GL20.GL_SHORT, GL20.GL_UNSIGNED_SHORT,GL20.GL_FIXED, or GL20.GL_FLOAT. GL_FIXED will not work on the desktopnormalize- whether fixed point data should be normalized. Will not work on the desktopstride- the stride in bytes between successive attributesoffset- byte offset into the vertex buffer object bound to GL20.GL_ARRAY_BUFFER.
-
setVertexAttribute
public void setVertexAttribute(int location, int size, int type, boolean normalize, int stride, int offset) - Overrides:
setVertexAttributein classExtShaderProgram
-
begin
public void begin()Makes OpenGL ES 2.0 use this vertex and fragment shader pair. When you are done with this shader you have to callShaderProgram.end().- Overrides:
beginin classExtShaderProgram
-
end
public void end()Disables this shader. Must be called when one is done with the shader. Don't mix it with dispose, that will release the shader resources.- Overrides:
endin classExtShaderProgram
-
disableVertexAttribute
Disables the vertex attribute with the given name- Overrides:
disableVertexAttributein classExtShaderProgram- Parameters:
name- the vertex attribute name
-
disableVertexAttribute
public void disableVertexAttribute(int location) - Overrides:
disableVertexAttributein classExtShaderProgram
-
enableVertexAttribute
Enables the vertex attribute with the given name- Overrides:
enableVertexAttributein classExtShaderProgram- Parameters:
name- the vertex attribute name
-
enableVertexAttribute
public void enableVertexAttribute(int location) - Overrides:
enableVertexAttributein classExtShaderProgram
-
invalidateAllShaderPrograms
public static void invalidateAllShaderPrograms(com.badlogic.gdx.Application app) Invalidates all shaders so the next time they are used new handles are generated- Parameters:
app-
-
clearAllShaderPrograms
public static void clearAllShaderPrograms(com.badlogic.gdx.Application app) -
getManagedStatus
-
getNumManagedShaderPrograms
public static int getNumManagedShaderPrograms()- Returns:
- the number of managed shader programs currently loaded
-
setAttributef
Sets the given attribute- Overrides:
setAttributefin classExtShaderProgram- Parameters:
name- the name of the attributevalue1- the first valuevalue2- the second valuevalue3- the third valuevalue4- the fourth value
-
hasAttribute
- Overrides:
hasAttributein classExtShaderProgram- Parameters:
name- the name of the attribute- Returns:
- whether the attribute is available in the shader
-
getAttributeType
- Overrides:
getAttributeTypein classExtShaderProgram- Parameters:
name- the name of the attribute- Returns:
- the type of the attribute, one of
GL20.GL_FLOAT,GL20.GL_FLOAT_VEC2etc.
-
getAttributeLocation
- Overrides:
getAttributeLocationin classExtShaderProgram- Parameters:
name- the name of the attribute- Returns:
- the location of the attribute or -1.
-
getAttributeSize
- Overrides:
getAttributeSizein classExtShaderProgram- Parameters:
name- the name of the attribute- Returns:
- the size of the attribute or 0.
-
hasUniform
- Overrides:
hasUniformin classExtShaderProgram- Parameters:
name- the name of the uniform- Returns:
- whether the uniform is available in the shader
-
getUniformType
- Overrides:
getUniformTypein classExtShaderProgram- Parameters:
name- the name of the uniform- Returns:
- the type of the uniform, one of
GL20.GL_FLOAT,GL20.GL_FLOAT_VEC2etc.
-
getUniformLocation
- Overrides:
getUniformLocationin classExtShaderProgram- Parameters:
name- the name of the uniform- Returns:
- the location of the uniform or -1.
-
getUniformSize
- Overrides:
getUniformSizein classExtShaderProgram- Parameters:
name- the name of the uniform- Returns:
- the size of the uniform or 0.
-
getAttributes
- Overrides:
getAttributesin classExtShaderProgram- Returns:
- the attributes
-
getUniforms
- Overrides:
getUniformsin classExtShaderProgram- Returns:
- the uniforms
-
getVertexShaderSource
- Overrides:
getVertexShaderSourcein classExtShaderProgram- Returns:
- the source of the vertex shader
-
getFragmentShaderSource
- Overrides:
getFragmentShaderSourcein classExtShaderProgram- Returns:
- the source of the fragment shader
-
dispose
public void dispose()Description copied from class:ExtShaderProgramDisposes all resources associated with this shader. Must be called when the shader is no longer used.- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable- Overrides:
disposein classExtShaderProgram
-