Representation of a GPU shader. More...
Public Member Functions | |
| boolean | HasStage (SHADERSTAGE stage) |
| Checks if the shader program has a shader stage. | |
| boolean | CanCompile () |
| Checks if the shader can be compiled. | |
| boolean | IsValid () |
| Checks if the shader can be used. | |
| void | AddStage (SHADERSTAGE stage, string shader) |
| Adds a stage to the shader program. This should not be called multiple times for the same stage. | |
| void | AddStage (SHADERSTAGE stage, stream shader) |
| Adds a stage to the shader program. This should not be called multiple times for the same stage. | |
| void | AddStageFromString (SHADERSTAGE stage, string shader) |
| Adds a stage to the shader program, from a String containing the shader code. This should not be called multiple times for the same stage. | |
| void | AssignTextureUnit (string uniform) |
| Assigns a texture unit to a texture uniform. This is safe to call multiple times for the same uniform name. | |
| integer | GetTextureUnit (string uniform) |
| Gets the texture unit assigned to a texture uniform. | |
| boolean | Compile () |
| Compiles a shader. | |
| boolean | HasUniform (string uniform) |
| Checks if the shader has an uniform with the given name. This can only be called after the shader has been compiled. | |
| SHADERSTAGE | GetUniformType (string uniform) |
| Gets the type of the uniform with the given name. This can only be called after the shader has been compiled. | |
| void | SetUniform (string uniform, number value, SHADERDATATYPE dataType) |
| Sets the value of an uniform variable. The value passed to the uniform persists between different invocations, and can be set at any time, as long as the shader is valid. This can only be called after the shader has been compiled. | |
| void | SetUniform (string uniform, array value, SHADERDATATYPE dataType) |
| Sets the value of an uniform variable. The value passed to the uniform persists between different invocations, and can be set at any time, as long as the shader is valid. This can only be called after the shader has been compiled. | |
| void | SetTexture (string uniform, integer image) |
| Assigns an Image to a specific texture unit linked to an uniform variable. The texture unit must have been defined using Shader.AssignTextureUnit for this function to succeed. | |
| void | Delete () |
| Deletes a shader. It can no longer be used after this function is called. | |
| Shader () | |
| Creates a shader program. | |
Representation of a GPU shader.
Not all devices will support shaders. Use Device.GetCapability("graphics_shaders") to verify if that's the case.
The software renderer does not support shaders.
| void Shader.AddStage | ( | SHADERSTAGE | stage, |
| stream | shader ) |
Adds a stage to the shader program. This should not be called multiple times for the same stage.
| stage | The shader stage. |
| shader | A stream containing shader code. |
| void Shader.AddStage | ( | SHADERSTAGE | stage, |
| string | shader ) |
Adds a stage to the shader program. This should not be called multiple times for the same stage.
| stage | The shader stage. |
| shader | Filename of the resource containing shader code. |
| void Shader.AddStageFromString | ( | SHADERSTAGE | stage, |
| string | shader ) |
Adds a stage to the shader program, from a String containing the shader code. This should not be called multiple times for the same stage.
| stage | The shader stage. |
| shader | A String that contains shader code. |
| void Shader.AssignTextureUnit | ( | string | uniform | ) |
Assigns a texture unit to a texture uniform. This is safe to call multiple times for the same uniform name.
| uniform | The name of the uniform. |
| boolean Shader.CanCompile | ( | ) |
Checks if the shader can be compiled.
| boolean Shader.Compile | ( | ) |
Compiles a shader.
| integer Shader.GetTextureUnit | ( | string | uniform | ) |
Gets the texture unit assigned to a texture uniform.
| uniform | The name of the uniform. |
| SHADERSTAGE Shader.GetUniformType | ( | string | uniform | ) |
Gets the type of the uniform with the given name. This can only be called after the shader has been compiled.
| uniform | The name of the uniform. |
| boolean Shader.HasStage | ( | SHADERSTAGE | stage | ) |
Checks if the shader program has a shader stage.
| stage | The shader stage. |
| boolean Shader.HasUniform | ( | string | uniform | ) |
Checks if the shader has an uniform with the given name. This can only be called after the shader has been compiled.
| uniform | The name of the uniform. |
| boolean Shader.IsValid | ( | ) |
Checks if the shader can be used.
| void Shader.SetTexture | ( | string | uniform, |
| integer | image ) |
Assigns an Image to a specific texture unit linked to an uniform variable. The texture unit must have been defined using Shader.AssignTextureUnit for this function to succeed.
| uniform | The name of the uniform. |
| image | The image index to bind to the uniform. |
| void Shader.SetUniform | ( | string | uniform, |
| array | value, | ||
| SHADERDATATYPE | dataType ) |
Sets the value of an uniform variable. The value passed to the uniform persists between different invocations, and can be set at any time, as long as the shader is valid. This can only be called after the shader has been compiled.
| uniform | The name of the uniform. |
| value | The value. |
| dataType | The data type of the value being sent. This is required if the value being passed is an array. |
| void Shader.SetUniform | ( | string | uniform, |
| number | value, | ||
| SHADERDATATYPE | dataType ) |
Sets the value of an uniform variable. The value passed to the uniform persists between different invocations, and can be set at any time, as long as the shader is valid. This can only be called after the shader has been compiled.
| uniform | The name of the uniform. |
| value | The value. |
| dataType | The data type of the value being sent. This is required if the value being passed is an array. |