Class representing a shader program. More...
Public Member Functions | |
ShaderProgram (string fileName) | |
Creates a shader program (from a file) | |
ShaderProgram (string vpFileName, string fpFileName) | |
Creates a shader program (from a file) | |
ShaderProgram (string fileName, ShaderProgramOption option) | |
Creates a shader program (from a file, with options) | |
ShaderProgram (string vpFileName, string fpFileName, ShaderProgramOption option) | |
Creates a shader program (from a file, with options) | |
ShaderProgram (byte[] fileImage) | |
Creates a shader program (from a file image) | |
ShaderProgram (byte[] vpFileImage, byte[] fpFileImage) | |
Creates a shader program (from a file image) | |
ShaderProgram (byte[] fileImage, ShaderProgramOption option) | |
Creates a shader program (from a file image, with options) | |
ShaderProgram (byte[] vpFileImage, byte[] fpFileImage, ShaderProgramOption option) | |
Creates a shader program (from a file image, with options) | |
virtual Object | ShallowClone () |
Creates a copy of the shader program. | |
void | Dispose () |
Frees the unmanaged resources of the shader program. | |
int | FindUniform (string name) |
Enables search by specifying the uniform variable name. | |
int | FindAttribute (string name) |
Enables search by specifying the attribute variable name. | |
string | GetUniformBinding (int index) |
Obtains the uniform variable binding. | |
void | SetUniformBinding (int index, string name) |
Sets the uniform variable binding. | |
string | GetAttributeBinding (int index) |
Obtains the attribute variable binding. | |
void | SetAttributeBinding (int index, string name) |
Sets the attribute variable binding. | |
ShaderUniformType | GetUniformType (int index) |
Obtains the uniform variable type. | |
ShaderAttributeType | GetAttributeType (int index) |
Obtains the attribute variable type. | |
string | GetUniformName (int index) |
Obtains the uniform variable name. | |
string | GetAttributeName (int index) |
Obtains the attribute variable name. | |
int | GetUniformSize (int index) |
Obtains the array size of the uniform variable. | |
int | GetAttributeSize (int index) |
Obtains the array size of the attribute variable. | |
void | SetUniformValue (int index, ref Matrix4 value) |
Sets the uniform variable value. | |
void | SetUniformValue (int index, ref Vector4 value) |
Sets the uniform variable value. | |
void | SetUniformValue (int index, ref Vector3 value) |
Sets the uniform variable value. | |
void | SetUniformValue (int index, ref Vector2 value) |
Sets the uniform variable value. | |
void | SetUniformValue (int index, float value) |
Sets the uniform variable value. | |
void | SetUniformValue (int index, int value) |
Sets the uniform variable value. | |
void | SetUniformValue (int index, float[] value) |
Sets the uniform variable value. | |
void | SetUniformValue (int index, int[] value) |
Sets the uniform variable value. | |
void | SetUniformValue (int index, int offset, ref Matrix4 value) |
Sets the uniform variable value (with offset) | |
void | SetUniformValue (int index, int offset, ref Vector4 value) |
Sets the uniform variable value (with offset) | |
void | SetUniformValue (int index, int offset, ref Vector3 value) |
Sets the uniform variable value (with offset) | |
void | SetUniformValue (int index, int offset, ref Vector2 value) |
Sets the uniform variable value (with offset) | |
void | SetUniformValue (int index, int offset, float value) |
Sets the uniform variable value (with offset) | |
void | SetUniformValue (int index, int offset, int value) |
Sets the uniform variable value (with offset) | |
void | SetUniformValue (int index, int offset, float[] value) |
Sets the uniform variable value (with offset) | |
void | SetUniformValue (int index, int offset, int[] value) |
Sets the uniform variable value (with offset) | |
void | SetUniformValue (int index, Matrix4[] value, int to, int from, int count) |
Sets the uniform variable value (for array data) | |
void | SetUniformValue (int index, Vector4[] value, int to, int from, int count) |
Sets the uniform variable value (for array data) | |
void | SetUniformValue (int index, Vector3[] value, int to, int from, int count) |
Sets the uniform variable value (for array data) | |
void | SetUniformValue (int index, Vector2[] value, int to, int from, int count) |
Sets the uniform variable value (for array data) | |
void | SetUniformValue (int index, float[] value, int to, int from, int count) |
Sets the uniform variable value (for array data) | |
void | SetUniformValue (int index, int[] value, int to, int from, int count) |
Sets the uniform variable value (for array data) | |
void | SetAttributeValue (int index, params float[] value) |
Sets the default value of the attribute variable. | |
int | GetUniformTexture (int index) |
Obtains the uniform variable texture number. | |
int | GetAttributeStream (int index) |
Obtains the vertex stream number of the attribute variable. | |
void | SetAttributeStream (int index, int stream) |
Sets the vertex stream number of the attribute variable. | |
Protected Member Functions | |
ShaderProgram (ShaderProgram program) | |
Creates a copy of the shader program. | |
void | SwapShader (ShaderProgram program) |
Changes the shader. | |
virtual internal void | UpdateShader () |
Updates the shader state. | |
Properties | |
int | UniformCount [get] |
Number of uniform variables. | |
int | AttributeCount [get] |
Number of attribute variables. |
Class representing a shader program.
ShaderProgram | ( | string | fileName | ) |
Creates a shader program (from a file)
fileName | Shader filename |
Creates a shader program from a specified file. The usable file format is CGX.
ShaderProgram | ( | string | vpFileName, |
string | fpFileName | ||
) |
Creates a shader program (from a file)
vpFileName | Vertex shader filename |
fpFileName | Fragment shader filename |
Creates a shader program from a specified file. The usable file format is CGX.
ShaderProgram | ( | string | fileName, |
ShaderProgramOption | option | ||
) |
Creates a shader program (from a file, with options)
fileName | Shader filename |
option | Shader program creation option |
Creates a shader program from a specified file. The usable file format is CGX.
ShaderProgram | ( | string | vpFileName, |
string | fpFileName, | ||
ShaderProgramOption | option | ||
) |
Creates a shader program (from a file, with options)
vpFileName | Vertex shader filename |
fpFileName | Fragment shader filename |
option | Shader program creation option |
Creates a shader program from a specified file. The usable file format is CGX.
ShaderProgram | ( | byte[] | fileImage | ) |
Creates a shader program (from a file image)
fileImage | Shader file image |
Creates a shader program from a specified file image. The usable file format is CGX.
ShaderProgram | ( | byte[] | vpFileImage, |
byte[] | fpFileImage | ||
) |
Creates a shader program (from a file image)
vpFileImage | Vertex shader file image |
fpFileImage | Fragment shader file image |
Creates a shader program from a specified file image. The usable file format is CGX.
ShaderProgram | ( | byte[] | fileImage, |
ShaderProgramOption | option | ||
) |
Creates a shader program (from a file image, with options)
fileImage | Shader file image |
Creates a shader program from a specified file image. The usable file format is CGX.
ShaderProgram | ( | byte[] | vpFileImage, |
byte[] | fpFileImage, | ||
ShaderProgramOption | option | ||
) |
Creates a shader program (from a file image, with options)
vpFileImage | Vertex shader file image |
fpFileImage | Fragment shader file image |
Creates a shader program from a specified file image. The usable file format is CGX.
ShaderProgram | ( | ShaderProgram | program | ) | [protected] |
Creates a copy of the shader program.
Creates a copy of the shader program. The 2 shader programs will then share unmanaged resources. When Dispose() is called for all copies, the shared unmanaged resources will be freed.
int FindAttribute | ( | string | name | ) |
Enables search by specifying the attribute variable name.
name | Name of the attribute variable |
Enables search by specifying the attribute variable name. -1 will be returned if the specified variable is not found.
int FindUniform | ( | string | name | ) |
Enables search by specifying the uniform variable name.
name | Name of the uniform variable |
Enables search by specifying the uniform variable name. -1 will be returned if the specified variable is not found.
string GetAttributeBinding | ( | int | index | ) |
Obtains the attribute variable binding.
index | Number of the attribute variable (0 to AttributeCount-1) |
string GetAttributeName | ( | int | index | ) |
Obtains the attribute variable name.
index | Number of the attribute variable (0 to AttributeCount-1) |
int GetAttributeSize | ( | int | index | ) |
Obtains the array size of the attribute variable.
index | Number of the attribute variable (0 to AttributeCount-1) |
int GetAttributeStream | ( | int | index | ) |
Obtains the vertex stream number of the attribute variable.
index | Number of the attribute variable (0 to AttributeCount-1) |
ShaderAttributeType GetAttributeType | ( | int | index | ) |
Obtains the attribute variable type.
index | Number of the attribute variable (0 to AttributeCount-1) |
string GetUniformBinding | ( | int | index | ) |
Obtains the uniform variable binding.
index | Number of the uniform variable (0 to UniformCount-1) |
string GetUniformName | ( | int | index | ) |
Obtains the uniform variable name.
index | Number of the uniform variable (0 to UniformCount-1) |
int GetUniformSize | ( | int | index | ) |
Obtains the array size of the uniform variable.
index | Number of the uniform variable (0 to UniformCount-1) |
int GetUniformTexture | ( | int | index | ) |
Obtains the uniform variable texture number.
index | Number of the uniform variable (0 to UniformCount-1) |
Obtains the uniform variable texture number. -1 will be returned if the specified variable is not a sampler.
ShaderUniformType GetUniformType | ( | int | index | ) |
Obtains the uniform variable type.
index | Number of the uniform variable (0 to UniformCount-1) |
void SetAttributeBinding | ( | int | index, |
string | name | ||
) |
Sets the attribute variable binding.
index | Number of the attribute variable |
name | Name of the attribute variable (default when null) |
Links the attribute variable to a specific number. The old binding of the specified variable will be freed. Variables that do not have a binding are assigned an unused number.
It is also possible to specify a number that is equal to or greater than AttributeCount to index. In such cases, an empty variable is inserted and the AttributeCount value increases.
void SetAttributeStream | ( | int | index, |
int | stream | ||
) |
Sets the vertex stream number of the attribute variable.
index | Number of the attribute variable (0 to AttributeCount-1) |
stream | Vertex stream number (invalid if -1) |
Sets the vertex stream number of the attribute variable. The initial value is the number of the attribute variable. With this setting, an arbitrary vertex stream can be forwarded to the specified attribute variable. In addition, specific vertex streams can be disabled and a single vertex stream can be forwarded to multiple attribute variables.
void SetAttributeValue | ( | int | index, |
params float[] | value | ||
) |
Sets the default value of the attribute variable.
index | Number of the attribute variable (0 to AttributeCount-1) |
value | Array data (float) |
void SetUniformBinding | ( | int | index, |
string | name | ||
) |
Sets the uniform variable binding.
index | Number of the uniform variable |
name | Name of the uniform variable (default when null) |
Links the uniform variable to a specific number. The old binding of the specified variable will be freed. Variables that do not have a binding are assigned an unused number.
It is also possible to specify a number that is equal to or greater than UniformCount to index. In such cases, an empty variable is inserted and the UniformCount value increases.
void SetUniformValue | ( | int | index, |
int | offset, | ||
float | value | ||
) |
Sets the uniform variable value (with offset)
index | Number of the uniform variable (0 to UniformCount-1) |
offset | Offset of array variable |
value | Scalar (float) |
void SetUniformValue | ( | int | index, |
int | offset, | ||
ref Vector4 | value | ||
) |
Sets the uniform variable value (with offset)
index | Number of the uniform variable (0 to UniformCount-1) |
offset | Offset of array variable |
value | 4D vector (float) |
void SetUniformValue | ( | int | index, |
int | offset, | ||
ref Matrix4 | value | ||
) |
Sets the uniform variable value (with offset)
index | Number of the uniform variable (0 to UniformCount-1) |
offset | Offset of array variable |
value | 4D matrix (float) |
void SetUniformValue | ( | int | index, |
int[] | value | ||
) |
Sets the uniform variable value.
index | Number of the uniform variable (0 to UniformCount-1) |
value | Array data (int) |
Sets the uniform variable value. This overload can set a value not only to an int scalar variable, but also to the int vector variable such as int2,int3,int4... However, the array data size must be a multiple of the vector size.
void SetUniformValue | ( | int | index, |
float[] | value | ||
) |
Sets the uniform variable value.
index | Number of the uniform variable (0 to UniformCount-1) |
value | Array data (float) |
Sets the uniform variable value. This overload can set a value not only to a float scalar variable, but also to the float vector or matrix variable such as float2,float3,float4... However, the array data size must be a multiple of the vector or matrix size.
void SetUniformValue | ( | int | index, |
int | offset, | ||
int | value | ||
) |
Sets the uniform variable value (with offset)
index | Number of the uniform variable (0 to UniformCount-1) |
offset | Offset of array variable |
value | Scalar (int) |
void SetUniformValue | ( | int | index, |
ref Matrix4 | value | ||
) |
Sets the uniform variable value.
index | Number of the uniform variable (0 to UniformCount-1) |
value | 4D matrix (float) |
void SetUniformValue | ( | int | index, |
float[] | value, | ||
int | to, | ||
int | from, | ||
int | count | ||
) |
Sets the uniform variable value (for array data)
index | Number of the uniform variable (0 to UniformCount-1) |
value | Array data (float) |
to | Offset of the transfer destination |
from | Offset of the transfer source |
count | Number of data items to be transferred |
Sets the uniform variable value. This overload can set a value not only to a float scalar variable, but also to the float vector or matrix variable such as float2,float3,float4... However, note that the offset and count arguments are counted in vector or matrix units.
void SetUniformValue | ( | int | index, |
ref Vector3 | value | ||
) |
Sets the uniform variable value.
index | Number of the uniform variable (0 to UniformCount-1) |
value | 3D vector (float) |
void SetUniformValue | ( | int | index, |
Matrix4[] | value, | ||
int | to, | ||
int | from, | ||
int | count | ||
) |
Sets the uniform variable value (for array data)
index | Number of the uniform variable (0 to UniformCount-1) |
value | 4D matrix array (float) |
to | Offset of the transfer destination |
from | Offset of the transfer source |
count | Number of data items to be transferred |
void SetUniformValue | ( | int | index, |
ref Vector4 | value | ||
) |
Sets the uniform variable value.
index | Number of the uniform variable (0 to UniformCount-1) |
value | 4D vector (float) |
void SetUniformValue | ( | int | index, |
int | offset, | ||
float[] | value | ||
) |
Sets the uniform variable value (with offset)
index | Number of the uniform variable (0 to UniformCount-1) |
offset | Offset of array variable |
value | Array data (float) |
Sets the uniform variable value. This overload can set a value not only to a float scalar variable, but also to the float vector or matrix variable such as float2,float3,float4... However, the array data size must be a multiple of the vector or matrix size. Note that the offset arguments are counted in vector or matrix units.
void SetUniformValue | ( | int | index, |
Vector3[] | value, | ||
int | to, | ||
int | from, | ||
int | count | ||
) |
Sets the uniform variable value (for array data)
index | Number of the uniform variable (0 to UniformCount-1) |
value | 3D vector array (float) |
to | Offset of the transfer destination |
from | Offset of the transfer source |
count | Number of data items to be transferred |
void SetUniformValue | ( | int | index, |
int | offset, | ||
ref Vector3 | value | ||
) |
Sets the uniform variable value (with offset)
index | Number of the uniform variable (0 to UniformCount-1) |
offset | Offset of array variable |
value | 3D vector (float) |
void SetUniformValue | ( | int | index, |
ref Vector2 | value | ||
) |
Sets the uniform variable value.
index | Number of the uniform variable (0 to UniformCount-1) |
value | 2D vector (float) |
void SetUniformValue | ( | int | index, |
float | value | ||
) |
Sets the uniform variable value.
index | Number of the uniform variable (0 to UniformCount-1) |
value | Scalar (float) |
void SetUniformValue | ( | int | index, |
int | value | ||
) |
Sets the uniform variable value.
index | Number of the uniform variable (0 to UniformCount-1) |
value | Scalar (int) |
void SetUniformValue | ( | int | index, |
int | offset, | ||
int[] | value | ||
) |
Sets the uniform variable value (with offset)
index | Number of the uniform variable (0 to UniformCount-1) |
offset | Offset of array variable |
value | Array data (int) |
Sets the uniform variable value. This overload can set a value not only to an int scalar variable, but also to the int vector variable such as int2,int3,int4... However, the array data size must be a multiple of the vector size. Note that the offset arguments are counted in vector units.
void SetUniformValue | ( | int | index, |
int[] | value, | ||
int | to, | ||
int | from, | ||
int | count | ||
) |
Sets the uniform variable value (for array data)
index | Number of the uniform variable (0 to UniformCount-1) |
value | Array data (int) |
to | Offset of the transfer destination |
from | Offset of the transfer source |
count | Number of data items to be transferred |
Sets the uniform variable value. This overload can set a value not only to an int scalar variable, but also to the int vector variable such as int2,int3,int4... However, note that the offset and count arguments are counted in vector units.
void SetUniformValue | ( | int | index, |
Vector4[] | value, | ||
int | to, | ||
int | from, | ||
int | count | ||
) |
Sets the uniform variable value (for array data)
index | Number of the uniform variable (0 to UniformCount-1) |
value | 4D vector array (float) |
to | Offset of the transfer destination |
from | Offset of the transfer source |
count | Number of data items to be transferred |
void SetUniformValue | ( | int | index, |
Vector2[] | value, | ||
int | to, | ||
int | from, | ||
int | count | ||
) |
Sets the uniform variable value (for array data)
index | Number of the uniform variable (0 to UniformCount-1) |
value | 2D vector array (float) |
to | Offset of the transfer destination |
from | Offset of the transfer source |
count | Number of data items to be transferred |
void SetUniformValue | ( | int | index, |
int | offset, | ||
ref Vector2 | value | ||
) |
Sets the uniform variable value (with offset)
index | Number of the uniform variable (0 to UniformCount-1) |
offset | Offset of array variable |
value | 2D vector (float) |
virtual Object ShallowClone | ( | ) | [virtual] |
Creates a copy of the shader program.
Creates a copy of the shader program. The 2 shader programs will then share unmanaged resources. When Dispose() is called for all copies, the shared unmanaged resources will be freed.
Reimplemented in BasicProgram.
void SwapShader | ( | ShaderProgram | program | ) | [protected] |
Changes the shader.
program | Shader Program |
Sets the shader of the specified shader program to this shader program. This function is used when switching shaders internally.
virtual internal void UpdateShader | ( | ) | [protected, virtual] |
Updates the shader state.
A virtual function that is called from the graphics context before primitive rendering. This function is used when a cached state in a class is applied to the shader.
Reimplemented in BasicProgram.