Skip to content
Alexander Orzechowski edited this page Oct 18, 2015 · 11 revisions

This is essentially a wrapper for shaders in WebGL. It is ether a VERTEX_SHADER or a FRAGMENT_SHADER to be pared by a Tessellator.Program.

  • NOTE: This is a resource so it includes a .dispose() function. This shader is added to the global list of resources located in the main Tessellator context.

###Constructor

  • Tessellator.Shader(Tessellator tessellator, <optional>Tessellator.Constant type)
    This will create a shader with the passed Tessellator to be the context that the shader will run appon. A shader created with 'Tessellator A' will not work with a Tessellator.Program from 'Tessellator B'. The type is ether a Tessellator.VERTEX_SHADER or a Tessellator.FRAGMENT_SHADER constant. If omitted, then the type will have to be set by the .create() function later.

###Functions

  • .create(Tessellator.Constant type)
    The supplied type value must be a Tessellator.VERTEX_SHADER or a Tessellator.FRAGMENT_SHADER constant. This will tell the shader what type it is. This needs to be called before passing the code to the shader. The type may also be passed in the constructor so calling this function may not be needed.
  • NOTE: you may reset the exciting type that this shader is set with as long as the shader has not compiled yet.
  • THROWS: if the shader is already complied and ready

  • .isReady()
  • RETURNS: a boolean that is true if the shader is ready to be used.
  • NOTE: a shader can be added to a Tessellator.Program even though the shader is not ready. It will simply wait for the shader until it is ready.

  • .load(String source)
    This shader will compile the source code passed at this point, the shader is ready. If this shader was previously disposed, the .disposed flag is cleared and the shader recreated.
  • NOTE: .source will be set with the source string object passed.
  • SEE: .getSource()
  • THROWS: if the source object is null.

  • .loadDOM(DOMElement dom)
    this will acquire the text from the dom element pass it to the .load() function.
  • SEE: .load()

  • .loadRemote(String url)
    This will load the url and pass resource to the .load() function.
  • SEE: .load()

  • .getSource()
  • RETURNS: the source code of the shader if it is available.
  • NOTE: if the shader is not compiled (.load() was not called) this will return null.
  • SEE: .load()

  • .dispose()
    this will release all resources associated with this shader. When done using this shader, call this function or else the shader will never be removed from graphics memory. If you call .load() then the shader will be recreated as if the object was not disposed. If the resource is already disposed or no resource was created, this function will have no effect.
  • NOTE: The ready state of the shader is cleared.
  • SEE: .load()

  • .disposable
    This variable dictates whether this shader can be disposed by inheritance. For example: if I call Tessellator.Program.dispose() and if the .disposable flag is set to false, it will call .dispose() and dispose this object. It does not matter what this variable is set to if you call this function yourself.
  • SEE: .disposed
  • DEFAULT: true

  • .disposed
    This is a flag set to true if this resource is disposed. Calling .dispose() will set this flag to true.
  • DEFAULT: false
  • SEE: .dispose()

  • .type
    This value is set to whatever was passed within the constructor or with the .create() function.
  • SEE: .create()

###Internal


  • .onProgramLoad[Tessellator.Shader shader]
    This is a function that will be called by a Tessellator.Program when the program that has this shader linked is loaded and ready.
  • DEFAULT: empty function
  • SEE: Tessellator.Program

  • .setReady()
  • RETURN: the ready state of this shader.
  • SEE: .isReady()
Clone this wiki locally