Derm.Render.ShaderProgram Class Reference

Shader program. More...

Inheritance diagram for Derm.Render.ShaderProgram:
Derm.Render.RenderObject Derm.Render.IRenderObject Derm.Render.IReferenced

List of all members.

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.

Detailed Description

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.


Member Function Documentation

void Derm.Render.ShaderProgram.AttachShader ( string  sObjectName  ) 

Attach a ShaderObject to this ShaderProgram by its name.

Parameters:
sObjectName 
void Derm.Render.ShaderProgram.AttachShader ( ShaderObject  sObject  ) 

Attach a ShaderObject to this ShaderProgram.

Parameters:
sObject 
void Derm.Render.ShaderProgram.Bind ( RenderContext  ctx  ) 

Bind this ShaderProgram.

Parameters:
ctx A RenderContext used for binding.
override void Derm.Render.ShaderProgram.Create ( RenderContext  ctx  )  [virtual]

Create this ShaderProgram.

Parameters:
ctx 

Implements Derm.Render.RenderObject.

void Derm.Render.ShaderProgram.DefineSymbol ( string  def  ) 

Set a preprocessor symbol controlling the source compilation.

Parameters:
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]

Delete this ShaderProgram.

Parameters:
ctx 

Implements Derm.Render.RenderObject.

void Derm.Render.ShaderProgram.DetachShader ( string  sObjectName  ) 

Detach an attached ShaderObject from this ShaderProgram by its name.

Parameters:
sObjectName 
void Derm.Render.ShaderProgram.DetachShader ( ShaderObject  sObject  ) 

Detach an attached ShaderObject from this ShaderProgram.

Parameters:
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.

Parameters:
sName 
Returns:
It returns a ShaderObject instance already compiled.
bool Derm.Render.ShaderProgram.IsActiveInput ( string  uName  ) 

Determine whether an input is active or not.

Parameters:
uName A System.String which specify the input name.
Returns:
It returns true in the case the input named uName is active.
bool Derm.Render.ShaderProgram.IsActiveUniform ( string  uName  ) 

Determine whether an uniform is active or not.

Parameters:
uName A System.String which specify the uniform name.
Returns:
bool Derm.Render.ShaderProgram.IsAttachedShader ( string  sObjectName  ) 

Check the attachment state of a ShaderObject on this ShaderProgram by its name.

Parameters:
sObjectName 
Returns:
bool Derm.Render.ShaderProgram.IsAttachedShader ( ShaderObject  sObject  ) 

Check the attachment state of a ShaderObject on this ShaderProgram.

Parameters:
sObject 
Returns:
bool Derm.Render.ShaderProgram.IsDefinedSymbol ( string  sym  ) 

Check whether a specific preprocessor symbol is defined.

Parameters:
sym A System.String representing the symbol string.
Returns:
It returns true in the case the symbol is defined, otherwise it returns false.
void Derm.Render.ShaderProgram.Link ( RenderContext  ctx,
IEnumerable< IShaderState sStates 
)

Link this ShaderProgram.

Parameters:
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.

Parameters:
sName 
sProgram 
void Derm.Render.ShaderProgram.SetInput ( RenderContext  ctx,
BufferObject  iObject,
string  iVariable,
int  stride,
int  offset 
)

Set shader program inputs.

Parameters:
ctx 
Template Parameters:
T 
Parameters:
ctx A RenderContext used for binding input variable with buffer objects.
iObject A BufferObject containing the varying data.
iVariable A System.String indicating the input variable, in other words the variable name which receive a value of an element of iObject .
stride A System.Int32 specifying the offset (in basic machine units) from an element and the next one (both stored in the BufferObject iObject .
offset A System.Int32 specifying the offset (in basic machine units) from the beginning of the BufferObject for accessing to the first input element.

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.

Parameters:
ctx 
Template Parameters:
T 
Parameters:
ctx A RenderContext used for binding input variable with buffer objects.
iObject A BufferObject containing the varying data.
iVariable A System.String indicating the input variable, in other words the variable name which receive a value of an element of iObject .
stride A System.Int32 specifying the offset (in basic machine units) from an element and the next one (both stored in the BufferObject iObject .

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.

Parameters:
ctx 
Template Parameters:
T 
Parameters:
ctx A RenderContext used for binding input variable with buffer objects.
iObject A BufferObject containing the varying data.
iVariable A System.String indicating the input variable, in other words the variable name which receive a value of an element of iObject .
stride A System.Int32 specifying the offset (in basic machine units) from an element and the next one (both stored in the BufferObject iObject .

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 
)
Type Constraints
T :struct 
void Derm.Render.ShaderProgram.SetInput< T > ( RenderContext  ctx,
BufferObject  iObject 
)
Type Constraints
T :struct 
void Derm.Render.ShaderProgram.SetUniform ( RenderContext  ctx,
string  uName,
Texture  tex,
int  texUnit 
)

Set uniform state variable (sampler1D, sampler2D, sampler3D, samplerCube variable).

Parameters:
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).

Parameters:
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).

Parameters:
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).

Parameters:
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).

Parameters:
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.

Parameters:
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.

Parameters:
sym A System.String representing the symbol string.

Property Documentation

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.



Services powered by Get Deus Ex Render Machina at SourceForge.net. Fast, secure and Free Open Source software downloads