Shader program. More...
Public Member Functions | |
void | AttachShader (string sObjectName) |
Attach a ShaderObject to this ShaderProgram by its name. | |
void | AttachShader (ShaderObject sObject) |
Attach a ShaderObject to this ShaderProgram. | |
void | Bind (RenderContext ctx) |
Bind this ShaderProgram. | |
override void | Create (RenderContext ctx) |
Create this ShaderProgram. | |
void | DefineSymbol (string def) |
Set a preprocessor symbol controlling the source compilation. | |
override void | Delete (RenderContext ctx) |
Delete this ShaderProgram. | |
void | DetachShader (string sObjectName) |
Detach an attached ShaderObject from this ShaderProgram by its name. | |
void | DetachShader (ShaderObject sObject) |
Detach an attached ShaderObject from this ShaderProgram. | |
void | ForceRelink () |
Requires to relink this ShaderProgram. | |
bool | IsActiveInput (string uName) |
Determine whether an input is active or not. | |
bool | IsActiveUniform (string uName) |
Determine whether an uniform is active or not. | |
bool | IsAttachedShader (string sObjectName) |
Check the attachment state of a ShaderObject on this ShaderProgram by its name. | |
bool | IsAttachedShader (ShaderObject sObject) |
Check the attachment state of a ShaderObject on this ShaderProgram. | |
bool | IsDefinedSymbol (string sym) |
Check whether a specific preprocessor symbol is defined. | |
void | Link (RenderContext ctx, IEnumerable< IShaderState > sStates) |
Link this ShaderProgram. | |
void | SetInput (RenderContext ctx, BufferObject iObject, string iVariable, int stride, int offset) |
Set shader program inputs. | |
void | SetInput (RenderContext ctx, BufferObject iObject, string iVariable, int stride) |
Set shader program inputs. | |
void | SetInput (RenderContext ctx, BufferObject iObject, string iVariable) |
Set shader program inputs. | |
void | SetInput< T > (RenderContext ctx, BufferObject iObject, int offset) |
void | SetInput< T > (RenderContext ctx, BufferObject iObject) |
void | SetUniform (RenderContext ctx, string uName, Texture tex, int texUnit) |
Set uniform state variable (sampler1D, sampler2D, sampler3D, samplerCube variable). | |
void | SetUniform (RenderContext ctx, string uName, Matrix4x4 m) |
Set uniform state variable (mat4 variable). | |
void | SetUniform (RenderContext ctx, string uName, Vertex4f v) |
Set uniform state variable (vec4 variable). | |
void | SetUniform (RenderContext ctx, string uName, Vertex3f v) |
Set uniform state variable (vec3 variable). | |
void | SetUniform (RenderContext ctx, string uName, int i) |
Set uniform state variable (integer variable). | |
void | Unbind (RenderContext ctx) |
Unbind this ShaderProgram. | |
void | UndefineAllSymbols () |
Unset every preprocessor symbol controlling the source compilation. | |
void | UndefineSymbol (string sym) |
Unset a preprocessor symbol controlling the source compilation. | |
Static Public Member Functions | |
static ShaderProgram | GetShaderProgram (string sName) |
Obtain precompiled shader object instance. | |
static void | RegisterShaderProgram (string sName, ShaderProgram sProgram) |
Register a ShaderProgram by name for future creations. | |
Properties | |
string[] | Defines [get] |
Symbols definitions to control source code compilation. | |
bool | IsLinked [get] |
Property to determine program linkage status. | |
int | RequiredGLSLVersion [get, set] |
Required OpenGL Shading Language version for this ShaderProgram. |
Shader program.
ShaderProgram automatically determine the text of the program using the shader objects attached (and their dependencies). The text shall be compiled and then linked all toghether to obtain an effective ShaderProgram instance.
Once linked, a ShaderProgram has an active set of uniforms and an active set of inputs. Only the uniform symbols and input symbols with possible access are considered active.
Uniforms are shader program symbols which are constant during the shader program executions over a single primitive. They are preserved between different shader program executions, and they are lost if the shader program has been relinked.
Inputs are shader program symbols which are variable during the shader program execution. A shader program input is represented by a BufferObject instance; every active input in the shader program must be linked with a BufferObject, and every BufferObject must have the same items count BufferObject.ItemsCount.
void Derm.Render.ShaderProgram.AttachShader | ( | string | sObjectName | ) |
Attach a ShaderObject to this ShaderProgram by its name.
sObjectName |
void Derm.Render.ShaderProgram.AttachShader | ( | ShaderObject | sObject | ) |
Attach a ShaderObject to this ShaderProgram.
sObject |
void Derm.Render.ShaderProgram.Bind | ( | RenderContext | ctx | ) |
Bind this ShaderProgram.
ctx | A RenderContext used for binding. |
override void Derm.Render.ShaderProgram.Create | ( | RenderContext | ctx | ) | [virtual] |
void Derm.Render.ShaderProgram.DefineSymbol | ( | string | def | ) |
Set a preprocessor symbol controlling the source compilation.
def | A System.String representing the symbol string. |
Specific preprocessor symbols can be defined in order to control the shader's source code compilation. Setting a symbol, in the end, results in a source line of the form: define SYMBOL_NAME
This allow to have shader sources dependent on specific preprocessor symbols, which can be activated or not depending on the wanted result.
override void Derm.Render.ShaderProgram.Delete | ( | RenderContext | ctx | ) | [virtual] |
void Derm.Render.ShaderProgram.DetachShader | ( | string | sObjectName | ) |
Detach an attached ShaderObject from this ShaderProgram by its name.
sObjectName |
void Derm.Render.ShaderProgram.DetachShader | ( | ShaderObject | sObject | ) |
Detach an attached ShaderObject from this ShaderProgram.
sObject |
void Derm.Render.ShaderProgram.ForceRelink | ( | ) |
Requires to relink this ShaderProgram.
static ShaderProgram Derm.Render.ShaderProgram.GetShaderProgram | ( | string | sName | ) | [static] |
Obtain precompiled shader object instance.
sName |
bool Derm.Render.ShaderProgram.IsActiveInput | ( | string | uName | ) |
Determine whether an input is active or not.
uName | A System.String which specify the input name. |
bool Derm.Render.ShaderProgram.IsActiveUniform | ( | string | uName | ) |
Determine whether an uniform is active or not.
uName | A System.String which specify the uniform name. |
bool Derm.Render.ShaderProgram.IsAttachedShader | ( | string | sObjectName | ) |
Check the attachment state of a ShaderObject on this ShaderProgram by its name.
sObjectName |
bool Derm.Render.ShaderProgram.IsAttachedShader | ( | ShaderObject | sObject | ) |
bool Derm.Render.ShaderProgram.IsDefinedSymbol | ( | string | sym | ) |
Check whether a specific preprocessor symbol is defined.
sym | A System.String representing the symbol string. |
void Derm.Render.ShaderProgram.Link | ( | RenderContext | ctx, | |
IEnumerable< IShaderState > | sStates | |||
) |
Link this ShaderProgram.
ctx | A RenderContext used for linking this ShaderProgram. | |
sStates | A IShaderState used for define this ShaderProgram object compilation symbols. |
Generate shader program source code, compile and link it. After a successfull link, obtain every information about active uniform and input variables.
This routine generate the source code of each attached ShaderObject instance and compile it. This step is performed only if really required (tendentially every shader object is already compiled).
After having compiled every attached shader object, it's performed the linkage between shader objects. After this process the ShaderProgram instance can be bound to issue rendering commands.
static void Derm.Render.ShaderProgram.RegisterShaderProgram | ( | string | sName, | |
ShaderProgram | sProgram | |||
) | [static] |
Register a ShaderProgram by name for future creations.
sName | ||
sProgram |
void Derm.Render.ShaderProgram.SetInput | ( | RenderContext | ctx, | |
BufferObject | iObject, | |||
string | iVariable, | |||
int | stride, | |||
int | offset | |||
) |
Set shader program inputs.
ctx |
|
This routine (with also its overloads) can be stored in a vertex array object.
void Derm.Render.ShaderProgram.SetInput | ( | RenderContext | ctx, | |
BufferObject | iObject, | |||
string | iVariable, | |||
int | stride | |||
) |
Set shader program inputs.
ctx |
|
The input offset is defaulted to 0. This routine (with also its overloads) can be stored in a vertex array object.
void Derm.Render.ShaderProgram.SetInput | ( | RenderContext | ctx, | |
BufferObject | iObject, | |||
string | iVariable | |||
) |
Set shader program inputs.
ctx |
|
The input offset and stride are defaulted to 0. This routine (with also its overloads) can be stored in a vertex array object.
void Derm.Render.ShaderProgram.SetInput< T > | ( | RenderContext | ctx, | |
BufferObject | iObject, | |||
int | offset | |||
) |
T | : | struct |
void Derm.Render.ShaderProgram.SetInput< T > | ( | RenderContext | ctx, | |
BufferObject | iObject | |||
) |
T | : | struct |
void Derm.Render.ShaderProgram.SetUniform | ( | RenderContext | ctx, | |
string | uName, | |||
Texture | tex, | |||
int | texUnit | |||
) |
Set uniform state variable (sampler1D, sampler2D, sampler3D, samplerCube variable).
ctx | A RenderContext used for operations. | |
uName | A System.String specifying the variable name in the shader source. | |
m | A Texture holding the uniform variabile data (the texture name). |
void Derm.Render.ShaderProgram.SetUniform | ( | RenderContext | ctx, | |
string | uName, | |||
Matrix4x4 | m | |||
) |
Set uniform state variable (mat4 variable).
ctx | A RenderContext used for operations. | |
uName | A System.String specifying the variable name in the shader source. | |
m | A Matrix4x4 holding the uniform variabile data. |
void Derm.Render.ShaderProgram.SetUniform | ( | RenderContext | ctx, | |
string | uName, | |||
Vertex4f | v | |||
) |
Set uniform state variable (vec4 variable).
ctx | A RenderContext used for operations. | |
uName | A System.String specifying the variable name in the shader source. | |
v | A Vertex3f holding the uniform variabile data. |
void Derm.Render.ShaderProgram.SetUniform | ( | RenderContext | ctx, | |
string | uName, | |||
Vertex3f | v | |||
) |
Set uniform state variable (vec3 variable).
ctx | A RenderContext used for operations. | |
uName | A System.String specifying the variable name in the shader source. | |
v | A Vertex3f holding the uniform variabile data. |
void Derm.Render.ShaderProgram.SetUniform | ( | RenderContext | ctx, | |
string | uName, | |||
int | i | |||
) |
Set uniform state variable (integer variable).
ctx | A RenderContext used for operations. | |
uName | A System.String specifying the variable name in the shader source. | |
v | A Vertex3f holding the uniform variabile data. |
void Derm.Render.ShaderProgram.Unbind | ( | RenderContext | ctx | ) |
Unbind this ShaderProgram.
ctx | A RenderContext used for binding. |
void Derm.Render.ShaderProgram.UndefineAllSymbols | ( | ) |
Unset every preprocessor symbol controlling the source compilation.
void Derm.Render.ShaderProgram.UndefineSymbol | ( | string | sym | ) |
Unset a preprocessor symbol controlling the source compilation.
sym | A System.String representing the symbol string. |
string [] Derm.Render.ShaderProgram.Defines [get] |
Symbols definitions to control source code compilation.
bool Derm.Render.ShaderProgram.IsLinked [get] |
Property to determine program linkage status.
int Derm.Render.ShaderProgram.RequiredGLSLVersion [get, set] |
Required OpenGL Shading Language version for this ShaderProgram.