Skip to content
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);

Constructor

  • RenderMatrix(RendererAbstract renderer, <optional>RenderMatrix parent)
    Constructs a new RenderMatrix
    • ARGUMENT renderer: The Renderer that this Tessellator.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.

###Properties


  • .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()


  • .depthMask(boolean value)
    This is the equivalent to the WebglRenderingContext.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






  • .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()



  • .copy(<optional>Tessellator.RendererAbstract renderer)
    Creates a copy of this Tessellator.RenderMatrix that inherits all the properties defined it the current Tessellator.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 current Tessellator context.
  • NOTE: This is inherited from the renderer argument in the constructor.

  • .renderer The renderer this Tessellator.RenderMatrix is handeling.
  • NOTE: This is set by the constructor.

###Internal

  • .copyMatrix(RenderMatrix matrix)
    This will configure this Tessellator.RenderMatrix's properties that were inherited from the provided RenderMatrix classed passed by an argument.
    • ARGUMENT matrix: The Tessellator.RenderMatrix whose properties should be inherited from.

  • .dirty(<optional>String key)
    This will notify the Tessellator.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 the Tessellator.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 the RenderMatrix that it is about to need to reset the state of WebGL because it is about to render. This is called by the Tessellator.Object class.


  • .unifyAll()
    This will get called by a Tessellator.Object to tell the current Tessellator.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.

Clone this wiki locally