Maven module :un.engine : engine-opengl :
Class : un.engine.opengl.shader.ShaderTemplate
Extends/Implements : -
Subclasses : -

A shader template represent an empty shader file.
Textures,materials, lights,... will fill it with various elements :
- uniform
- in/out variables
- functions
- ...

The generated shader will have the form :

{layouts}
{uniforms}
{structures}
in inModel {
{variables_in}
} inData;
out outModel {
{variables_out}
} outData;
{variables_ws}
{functions}

main(){
{operations}
}

@author Johann Sorel


Variables : SHADER_VERTEX, SHADER_TESS_CONTROL, SHADER_TESS_EVAL, SHADER_GEOMETRY, SHADER_FRAGMENT
Functions : ShaderTemplate, ShaderTemplate, getStructures, getLayouts, getUniforms, getVariablesIn, getVariablesWs, getVariablesOut, getFunctions, getOperations, append, replaceTexts, replaceTexts, getShaderType, getMinGLSLVersion, setMinGLSLVersion, isModified, reset, makeUnique, addLayout, addUniform, addStructure, addVariableIn, addVariableWs, addVariableOut, addFunction, addOperation, loadFromChars, load, load, createFromChars, create, create, toCharacters


public int SHADER_VERTEX

public int SHADER_TESS_CONTROL

public int SHADER_TESS_EVAL

public int SHADER_GEOMETRY

public int SHADER_FRAGMENT


public void ShaderTemplate (int type)

public void ShaderTemplate (ShaderTemplate toCopy)

public Sequence getStructures ()

public Sequence getLayouts ()

public Sequence getUniforms ()

public ArraySequenceSet getVariablesIn ()

public ArraySequenceSet getVariablesWs ()

public ArraySequenceSet getVariablesOut ()

public Sequence getFunctions ()

public Sequence getOperations ()


Append given template instruction in this template.
param  other
public void append (ShaderTemplate other)


Loops on all instructions replacing key text by value text in the dictionary.
This can be used to fill variables inserted in the template.
param  replacement
public void replaceTexts (Dictionary replacement)


Loops on all instructions replacing key text by value text in the dictionary.
This can be used to fill variables inserted in the template.
public void replaceTexts (Chars oldc, Chars newc)


Get the shader type, one of SHADER_*** constants.
return  int, shader type
public int getShaderType ()


Get the minimum GLSL version this actor needs.
Value is expected to be the same as the first line in a GLSL program.
Example : #110, #300, #400
return  minimum required version of GLSL
public int getMinGLSLVersion ()

public void setMinGLSLVersion (int minGlslVersion)


return  true is modifications have been applied on this shader template
public boolean isModified ()


Clear the template of all registered elements.
Returning it to it's original empty form.
public void reset ()


Generate a unique variable name, this reduce the risk of variable
name clash in the shader.
param  name
return  Chars
public Chars makeUnique (Chars name)

public void addLayout (Chars code)

public void addUniform (Chars code)

public void addStructure (Chars code)

public void addVariableIn (Chars code)

public void addVariableWs (Chars code)

public void addVariableOut (Chars code)

public void addFunction (Chars code)

public void addOperation (Chars code)

public void loadFromChars (Chars text, int type)

public void load (Chars path, int type)

public void load (Path p, int type)


Load template from text program template
param  text
param  type
return  ShaderTemplate
throws  un.api.io.IOException
public ShaderTemplate createFromChars (Chars text, int type)


Load template from given path.
param  path
param  type
return  ShaderTemplate
throws  un.api.io.IOException
public ShaderTemplate create (Chars path, int type)


Load template from given path.
param  p
param  type
return  ShaderTemplate
throws  un.api.io.IOException
public ShaderTemplate create (Path p, int type)


Generate the shader code.
param  previousStage : name of the previous stage
return  Chars
public Chars toCharacters (int previousStage)