public class GLSLProgram extends Object implements org.synthclipse.scripting.IDisposable
GLSLProgram
, apart from standard OpenGL features, also parses GLSL code
in search of
Uniform Controls
and Commands.
GLSLProgramFactory
.Constructor and Description |
---|
GLSLProgram(javax.media.opengl.GL3 gl,
File scriptFile,
org.synthclipse.core.parser.IParsingErrorHandler errorHandler,
org.synthclipse.core.IFileResolver fileResolver,
org.synthclipse.scripting.IScriptingController scriptingController)
Creates a new GLSLProgram.
|
GLSLProgram(javax.media.opengl.GL3 gl,
String name,
File scriptFile,
org.synthclipse.core.parser.IParsingErrorHandler errorHandler,
org.synthclipse.core.IFileResolver fileResolver,
org.synthclipse.scripting.IScriptingController scriptingController)
Creates a new GLSL program.
|
Modifier and Type | Method and Description |
---|---|
void |
applyUniforms()
Applies Uniform Controls' values to the program.
|
void |
attachShader(String path)
Attaches shader to the program.
|
void |
attachShader(String path,
int type)
Attaches shader to the program.
|
void |
attachShaderString(String shaderCode,
int type)
Attaches shader, contained in the
shaderCode , to the program. |
void |
dispose()
Releases resources.
|
org.synthclipse.core.gl.executor.GLSLExecutor |
getGLSLExecutor()
Returns internal program executor.
|
int |
getId()
Returns OpenGL's ID of the program.
|
String |
getName()
Returns porgram's name.
|
int |
getUniformLocation(String name)
Gets uniform's location.
|
void |
link()
Links the program.
|
boolean |
loadPreset(String presetName)
Loads preset.
|
void |
printActiveAttributes()
Prints active attributes.
|
void |
printActiveUniforms()
Prints active uniform variables.
|
String |
readProgramInfoLog()
Reads program's log.
|
void |
setName(String name)
Sets program's name.
|
void |
setUniform(int location,
boolean value)
Sets uniform variable with GLSL's type
bool . |
void |
setUniform(int location,
ColorRGB color)
Sets uniform variable with GLSL's type
vec3 . |
void |
setUniform(int location,
ColorRGBA color)
Sets uniform variable with GLSL's type
vec4 . |
void |
setUniform(int location,
double value)
Sets uniform variable with GLSL's type
double . |
void |
setUniform(int location,
float value)
Sets uniform variable with GLSL's type
float . |
void |
setUniform(int location,
float x,
float y)
Sets uniform variable with GLSL's type
vec2 . |
void |
setUniform(int location,
float x,
float y,
float z)
Sets uniform variable with GLSL's type
vec3 . |
void |
setUniform(int location,
float x,
float y,
float z,
float w)
Sets uniform variable with GLSL's type
vec4 . |
void |
setUniform(int location,
int value)
Sets uniform variable with GLSL's type
int . |
void |
setUniform(int location,
Matrix3f mat3)
Sets uniform variable with GLSL's type
mat3 . |
void |
setUniform(int location,
Matrix4f mat4)
Sets uniform variable with GLSL's type
mat4 . |
void |
setUniform(int location,
Vector2f v)
Sets uniform variable with GLSL's type
vec2 . |
void |
setUniform(int location,
Vector3f v)
Sets uniform variable with GLSL's type
vec3 . |
void |
setUniform(int location,
Vector4f v)
Sets uniform variable with GLSL's type
vec4 . |
void |
setUniform(String name,
boolean value)
Sets uniform variable with GLSL's type
bool . |
void |
setUniform(String name,
ColorRGB color)
Sets uniform variable with GLSL's type
vec3 . |
void |
setUniform(String name,
ColorRGBA color)
Sets uniform variable with GLSL's type
vec4 . |
void |
setUniform(String name,
double value)
Sets uniform variable with GLSL's type
double . |
void |
setUniform(String name,
float value)
Sets uniform variable with GLSL's type
float . |
void |
setUniform(String name,
float x,
float y)
Sets uniform variable with GLSL's type
vec2 . |
void |
setUniform(String name,
float x,
float y,
float z)
Sets uniform variable with GLSL's type
vec3 . |
void |
setUniform(String name,
float x,
float y,
float z,
float w)
Sets uniform variable with GLSL's type
vec4 . |
void |
setUniform(String name,
int value)
Sets uniform variable with GLSL's type
int . |
void |
setUniform(String name,
Matrix3f mat3)
Sets uniform variable with GLSL's type
mat3 . |
void |
setUniform(String name,
Matrix4f mat4)
Sets uniform variable with GLSL's type
mat4 . |
void |
setUniform(String name,
Vector2f v)
Sets uniform variable with GLSL's type
vec2 . |
void |
setUniform(String name,
Vector3f v)
Sets uniform variable with GLSL's type
vec3 . |
void |
setUniform(String name,
Vector4f v)
Sets uniform variable with GLSL's type
vec4 . |
void |
setUniformColor(int location,
float r,
float g,
float b)
Sets uniform variable with GLSL's type
vec3 and Uniform Control type: ColorRGB. |
void |
setUniformColor(int location,
float r,
float g,
float b,
float a)
Sets uniform variable with GLSL's type
vec4 and Uniform Control type: ColorRGBA. |
void |
setUniformColor(String name,
float r,
float g,
float b)
Sets uniform variable with GLSL's type
vec3 and Uniform Control type: ColorRGB. |
void |
setUniformColor(String name,
float r,
float g,
float b,
float a)
Sets uniform variable with GLSL's type
vec4 and Uniform Control type: ColorRGBA. |
void |
setUniformDouble(int location,
double value)
Sets uniform variable with GLSL's type
double . |
void |
setUniformDouble(String name,
double value)
Sets uniform variable with GLSL's type
double . |
void |
setUniformFloat(int location,
float value)
Sets uniform variable with GLSL's type
float . |
void |
setUniformFloat(String name,
float value)
Sets uniform variable with GLSL's type
float . |
void |
setUniformInt(int location,
int value)
Sets uniform variable with GLSL's type
int . |
void |
setUniformInt(String name,
int value)
Sets uniform variable with GLSL's type
int . |
void |
setUniformMatrix3(int location,
Matrix4f mat4)
Sets uniform variable with GLSL's type
mat3 . |
void |
setUniformMatrix3(String name,
Matrix4f mat4)
Sets uniform variable with GLSL's type
mat3 . |
String |
toString() |
void |
unuse()
This method is equivalent of using function
glUseProgram()
with
0 as the argument. |
void |
use()
This method is equivalent of using function
glUseProgram()
with this program's id as the argument.
|
boolean |
validate()
Validates the program.
|
public GLSLProgram(javax.media.opengl.GL3 gl, File scriptFile, org.synthclipse.core.parser.IParsingErrorHandler errorHandler, org.synthclipse.core.IFileResolver fileResolver, org.synthclipse.scripting.IScriptingController scriptingController)
GLSLProgramFactory.createProgram(String)
instead.public GLSLProgram(javax.media.opengl.GL3 gl, String name, File scriptFile, org.synthclipse.core.parser.IParsingErrorHandler errorHandler, org.synthclipse.core.IFileResolver fileResolver, org.synthclipse.scripting.IScriptingController scriptingController)
GLSLProgramFactory.createProgram(String)
instead.public void dispose()
dispose
in interface org.synthclipse.scripting.IDisposable
public void attachShader(String path) throws org.synthclipse.core.gl.GLObjectException, FileNotFoundException, org.synthclipse.core.parser.ParsingException, org.synthclipse.core.SynthclipseException
path
.path
- Path to a shader file.org.synthclipse.core.SynthclipseException
- If something unexpected happens.FileNotFoundException
- If file pointed by path
doesn't exist.org.synthclipse.core.parser.ParsingException
- If shader parsing error occurs.org.synthclipse.core.gl.GLObjectException
public void attachShader(String path, int type) throws org.synthclipse.core.SynthclipseException, FileNotFoundException, org.synthclipse.core.parser.ParsingException, org.synthclipse.core.gl.GLObjectException
path
- Path to a shader file.type
- The type should be one of the following constants:
gl.FRAGMENT_SHADER
gl.VERTEX_SHADER
gl.GEOMETRY_SHADER
gl.TESS_EVALUATION_SHADER
gl.TESS_CONTROL_SHADER
gl.COMPUTE_SHADER
org.synthclipse.core.SynthclipseException
- If the type
is not one of listed above,
or something unexpected happens.FileNotFoundException
- If file pointed by path
doesn't exist.org.synthclipse.core.parser.ParsingException
- If shader parsing error occurs.org.synthclipse.core.gl.GLObjectException
public void attachShaderString(String shaderCode, int type) throws org.synthclipse.core.SynthclipseException, org.synthclipse.core.parser.ParsingException, org.synthclipse.core.gl.GLObjectException
shaderCode
, to the program.shaderCode
- Shader code in a String form.type
- The type should be one of the following constants:
gl.FRAGMENT_SHADER
gl.VERTEX_SHADER
gl.GEOMETRY_SHADER
gl.TESS_EVALUATION_SHADER
gl.TESS_CONTROL_SHADER
gl.COMPUTE_SHADER
org.synthclipse.core.SynthclipseException
- If the type
is not one of listed above, or something unexpected happens.org.synthclipse.core.parser.ParsingException
- If shader parsing error occurs.org.synthclipse.core.gl.GLObjectException
public void link() throws org.synthclipse.core.SynthclipseException
org.synthclipse.core.SynthclipseException
- If program fails to link.public void applyUniforms()
public String getName()
program.getName();
program.name;
public void setName(String name)
program.setName("value");
program.name = "value";
public boolean loadPreset(String presetName)
presetName
- preset's namepresetName
exists, false otherwise.public org.synthclipse.core.gl.executor.GLSLExecutor getGLSLExecutor()
public int getId()
program.getId();
program.id;
public void use()
public void unuse()
0
as the argument.public String readProgramInfoLog()
public void printActiveUniforms()
public void printActiveAttributes()
public boolean validate()
public int getUniformLocation(String name)
name
- name of queried variablepublic void setUniform(int location, boolean value)
bool
.location
- uniform's locationvalue
- the value we want to setpublic void setUniform(String name, boolean value)
bool
.name
- uniform's namevalue
- the value we want to setpublic void setUniform(int location, int value)
int
.location
- uniform's locationvalue
- the value we want to setpublic void setUniform(String name, int value)
int
.name
- uniform's namevalue
- the value we want to setpublic void setUniformInt(int location, int value)
int
.location
- uniform's locationvalue
- the value we want to setpublic void setUniformInt(String name, int value)
int
.name
- uniform's namevalue
- the value we want to setpublic void setUniform(int location, float value)
float
.location
- uniform's locationvalue
- the value we want to setpublic void setUniform(String name, float value)
float
.name
- uniform's namevalue
- the value we want to setpublic void setUniformFloat(int location, float value)
float
.location
- uniform's locationvalue
- the value we want to setpublic void setUniformFloat(String name, float value)
float
.name
- uniform's namevalue
- the value we want to setpublic void setUniform(int location, double value)
double
.location
- uniform's locationvalue
- the value we want to setpublic void setUniform(String name, double value)
double
.name
- uniform's namevalue
- the value we want to setpublic void setUniformDouble(int location, double value)
double
.location
- uniform's locationvalue
- the value we want to setpublic void setUniformDouble(String name, double value)
double
.name
- uniform's namevalue
- the value we want to setpublic void setUniform(int location, float x, float y)
vec2
.location
- uniform's locationx
- X component of the vectory
- Y component of the vectorpublic void setUniform(String name, float x, float y)
vec2
.name
- uniform's namex
- X component of the vectory
- Y component of the vectorpublic void setUniform(int location, float x, float y, float z)
vec3
.location
- uniform's locationx
- X component of the vectory
- Y component of the vectorz
- Z component of the vectorpublic void setUniform(String name, float x, float y, float z)
vec3
.name
- uniform's namex
- X component of the vectory
- Y component of the vectorz
- Z component of the vectorpublic void setUniform(int location, float x, float y, float z, float w)
vec4
.location
- uniform's locationx
- X component of the vectory
- Y component of the vectorz
- Z component of the vectorw
- W component of the vectorpublic void setUniform(String name, float x, float y, float z, float w)
vec4
.name
- uniform's namex
- X component of the vectory
- Y component of the vectorz
- Z component of the vectorw
- W component of the vectorpublic void setUniform(int location, Vector2f v)
vec2
.location
- uniform's locationv
- the vector we want to setpublic void setUniform(String name, Vector2f v)
vec2
.name
- uniform's namev
- the vector we want to setpublic void setUniform(int location, Vector3f v)
vec3
.location
- uniform's locationv
- the vector we want to setpublic void setUniform(String name, Vector3f v)
vec3
.name
- uniform's namev
- the vector we want to setpublic void setUniform(int location, Vector4f v)
vec4
.location
- uniform's locationv
- the vector we want to setpublic void setUniform(String name, Vector4f v)
vec4
.name
- uniform's namev
- the vector we want to setpublic void setUniform(int location, ColorRGB color)
vec3
.location
- uniform's locationcolor
- Color RGB we want to setpublic void setUniform(String name, ColorRGB color)
vec3
.name
- uniform's namecolor
- Color RGB we want to setpublic void setUniform(int location, ColorRGBA color)
vec4
.location
- uniform's locationcolor
- Color RGBA we want to setpublic void setUniform(String name, ColorRGBA color)
vec4
.name
- uniform's namecolor
- Color RGBA we want to setpublic void setUniform(int location, Matrix3f mat3)
mat3
.location
- uniform's locationmat3
- the matrix 3x3 we want to setpublic void setUniform(String name, Matrix3f mat3)
mat3
.name
- uniform's namemat3
- the matrix 3x3 we want to setpublic void setUniform(int location, Matrix4f mat4)
mat4
.location
- uniform's locationmat4
- the matrix 4x4 we want to setpublic void setUniform(String name, Matrix4f mat4)
mat4
.name
- uniform's namemat4
- the matrix 4x4 we want to setpublic void setUniformMatrix3(int location, Matrix4f mat4)
mat3
.
It is the same as setUniform(int, Matrix3f)
but uses Matrix4f as source.location
- uniform's locationmat4
- the matrix 4x4 from which will be extracted a matrix 3x3 that we want essentially to setpublic void setUniformMatrix3(String name, Matrix4f mat4)
mat3
.
It is the same as setUniform(int, Matrix3f)
but uses Matrix4f as source.name
- uniform's namemat4
- the matrix 4x4 from which will be extracted a matrix 3x3 that we want essentially to setpublic void setUniformColor(String name, float r, float g, float b)
vec3
and Uniform Control type: ColorRGB.name
- uniform's namer
- r component of the colorg
- g component of the colorb
- b component of the vectorpublic void setUniformColor(int location, float r, float g, float b)
vec3
and Uniform Control type: ColorRGB.location
- uniform's locationr
- r component of the colorg
- g component of the colorb
- b component of the vectorpublic void setUniformColor(String name, float r, float g, float b, float a)
vec4
and Uniform Control type: ColorRGBA.name
- uniform's namer
- r component of the colorg
- g component of the colorb
- b component of the vectora
- a component of the vectorpublic void setUniformColor(int location, float r, float g, float b, float a)
vec4
and Uniform Control type: ColorRGBA.location
- uniform's locationr
- r component of the colorg
- g component of the colorb
- b component of the vectora
- a component of the vector