-
Notifications
You must be signed in to change notification settings - Fork 1
RenderMatrix
Alexander Orzechowski edited this page Oct 21, 2015
·
2 revisions
The Tessellator.RenderMatrix
class handles the state of WebGL when rendering. When creating a new Renderer
you will need to know the functions of this class in order to change the state of WebGL. The Renderer
should automatically create this class for you so you don't need to know about the constructors.
The main use of the Tessellator.RenderMatrix
is to save and then later restore the state of WebGL unsing .copy()
will create a copy Tessellator.RenderMatrix
which is totally independent of the one that was copied from.
###Usage
var renderer = ...;
var obj1 = new Tessellator.Object(...);
var obj2 = new Tessellator.Object(...);
var matrix = new Tessellator.RenderMatrix(renderer);
//set our uniforms.
matrix.set("vector2", Tessellator.vec2(3, 7)):
matrix.set("floating", .5);
//render first object with "floating" uniform set to 0.5
obj1.render(matrix);
var matrix2 = matrix.copy();
matrix2.set("floating", 1.5);
//obj2 rendered with "floating" as 1.5
//obj2 is also rendered with "vector2" as (3, 7)
obj2.render(matrix2);
//obj2 rendered with "floating" uniform as 0.5
obj2.render(matrix);
-
RenderMatrix(RendererAbstract renderer, <optional>RenderMatrix parent)
Constructs a newRenderMatrix
- ARGUMENT renderer: The
Renderer
that thisTessellator.RenderMatrix
will handle. - ARGUMENT parent: This
RenderMatrix
will inherit any properties form the parent if it is present. Otherwise, it will configure to a default configuration. - NOTE: The
Renderer
's.configure()
function will be called from this constructor if no parent is present.
- ARGUMENT renderer: The
###Properties
-
.exists(String key)
Asks the currentTessellator.UniformManager
whether this uniform is defined and usable in theRenderer
'sTessellator.Program
. - ARGUMENT key: The name of the uniform in question.
- RETURN: A boolean that is set to true if the uniform exists.
-
.setn(String key, Object value)
Called "set new" function this will set the uniform only if it has not been defined yet (it's value fails a JavaScript if check). - ARGUMENT: The name of the uniform to be set.
-
.get(String key)
This will get the value of the uniform in question. - ARGUMNET key: The name of the uniform to get.
- NOTE: This will set the uniform's dirty state to true.
- SEE:
.dirty()
- RETURN: The uniform's value.
-
.has(String key)
Checks if the uniform in question is net set to undefined. - ARGUMENT key: The name of the uniform to preform the check on.
-
.gets(String key)
Gets the uniform's value without setting the uniform state to dirty. - ARGUMENT key: The name of the uniform to get.
- SEE:
.get()
- RETURN: The uniform's value.
-
.set(String key, Object value)
Sets the uniform's value and sets it state to dirty. - ARGUMENT key: The name of the uniform to set.
- ARGUMENT value: The value to set the uniform to.
- SEE:
.dirty()
-
.sets(String key, Object value)
Sets the uniforms value without setting it's state to dirty. - ARGUMENT key: The name of the uniform to set.
- ARGUMENT value: The value to set the uniform to.
- SEE:
.set()
-
.blendFunc(Array[2] value)
This is the equivalent to theWebglRenderingContext.blendFunc()
. It tells WebGL how it should blend the pixel it is processing depending on the source and destination. - ARGUMENT value: A two component array where the first one is the source specifier and the second is the destination specifier.
- SEE:
WebglRenderingContext
- DEFAULT:
Tessellator.BLEND_DEFAULT
-
.depthMask(boolean value)
This is the equivalent to theWebglRenderingContext.depthMask()
. It tells WebGL whether it should update the depth buffer when there are new things to draw. - ARGUMENT value: True if the depth buffer should be written to. False if it should be set to read only.
- SEE:
WebglRenderingContext
- DEFAULT:
true
-
.depthFunc(Constant value)
This is the equivalent to theWebglRenderingContext.depthFunc()
. It tells WebGL how it should write to the depth buffer. - ARGUMENT value: The function constant.
- SEE:
WebglRenderingContext
- DEFAULT:
Tessellator.LEQUAL
-
.lineWidth(float value)
This is the equivalent to theWebglRenderingContext.lineWidth()
. Tells WebGL how wide the lines should look when rendering withTessellator.LINES
- ARGUMENT value: The width of the lines.
- SEE:
WebglRenderingContext
- DEFAULT:
1
- NOTE: On machines using
ANGLE
as a backend for rendering, this may not work.
-
.addDefinition(String def)
When the current shader in use is aTessellator.ActiveProgram
then this function will become usable (or else this function will have no effect). - ARGUMENT: The name of the definition to
#define
in the shader. - SEE:
Tessellator.ActiveProgram.addDefinition()
-
.resetDefinitions()
When the current shader in use is aTessellator.ActiveProgram
then this function will become usable (or else this function will have no effect). This will remove all the definitions previously defined by.addDefinition()
- SEE:
Tessellator.ActiveProgram.resetDefinitions()
,.addDefinition()
-
.removeDefinition(String def)
When the current shader in use is aTessellator.ActiveProgram
then this function will become usable (or else this function will have no effect). - ARGUMENT: The name of the definition to remove.
- SEE:
Tessellator.ActiveProgram.removeDefinition()
,.addDefinition()
-
.isEnabled(Constant value)
Checks to see if the constant in question is enabled - ARGUMENT value: The value to check.
- RETURN: A boolean that is true if the constant is enabled.
-
.isEnabledDefined(Constant value)
Checks if the constant was previously defined - ARGUMENT value: The constant to check for.
- RETURN: A boolean set to true if the constant was ever enabled or disabled.
- SEE:
.enable()
,.disable()
-
.enable(Constant value)
This is the equivalent to theWebglRenderingContext.enable()
. It tells the rendering pipeline how it should render certain things. - SEE:
WebglRenderingContext
-
.disable(Constant value)
This is the equivalent to theWebglRenderingContext.disable()
. It tells the rendering pipeline how it should render certain things. - SEE:
WebglRenderingContext
-
.copy(<optional>Tessellator.RendererAbstract renderer)
Creates a copy of thisTessellator.RenderMatrix
that inherits all the properties defined it the currentTessellator.RenderMatrix
. - ARGUMENT renderer: If present, it will configure the new
Tessellator.RenderMatrix
with this renderer. If it is not present, it will configure it with the current renderer. - RETURN: The new
Tessellator.RenderMatrix
.
-
.tessellator
The currentTessellator
context. - NOTE: This is inherited from the renderer argument in the constructor.
-
.renderer
The renderer thisTessellator.RenderMatrix
is handeling. - NOTE: This is set by the constructor.
###Internal
-
.copyMatrix(RenderMatrix matrix)
This will configure thisTessellator.RenderMatrix
's properties that were inherited from the providedRenderMatrix
classed passed by an argument.- ARGUMENT matrix: The
Tessellator.RenderMatrix
whose properties should be inherited from.
- ARGUMENT matrix: The
-
.dirty(<optional>String key)
This will notify theTessellator.RenderMatrix
that a uniform value has been modified so that it will need to be sent to the graphics processor to be updated. When the time comes when it does need to update this modified uniform, it will notify theTessellator.UniformManager
. - ARGUMENT key: If this is present then the specified uniform in question will be set to need an update. If this argument is not present, then all known uniforms will be updated (all the ones that have been previously defined by the
.set()
function). - SEE:
.set()
,.get()
-
.preUnify()
This will tell theRenderMatrix
that it is about to need to reset the state of WebGL because it is about to render. This is called by theTessellator.Object
class.
-
.unify()
This will get called by aTessellator.Object
to tell the currentTessellator.UniformMananger
what uniforms need to be updated so that the appropriate ones are uploaded to the GPU. - SEE:
.dirty()
-
.unifyAll()
This will get called by aTessellator.Object
to tell the currentTessellator.UniformMananger
to update all the defined uniforms. This is done when switching programs so that the state is guaranteed to be correct. This will update everything despite whether the uniform is dirty or not defined by.dirty()
.
-
.unifyGLAttributes()
This will set the state of WebGL that do not depend on the current shader.
-
.uniformManager
TheTessellator.UniformManager
class that makes sure that all uniforms are uploaded to the GPU.
-
source
Tessellator-
renderers
RendererAbstract
ModelRenderer
BufferedRenderer FullScreenRenderer -
shaders
Shader
Program
RenderMatrix -
geometry
Object
-