Description | Hierarchy | Fields | Methods | Properties |
type TAdShader = class(TObject)
The TAdShader class represents a single vertex or fragment (pixel) shader program in the Andorra 2D application. The TAdShader class abstracts the TAd2dShader plugin interface. You are able to use your preferred shader language. But remember that not every shader language is supported by each rendering plugin. For example, the DirectX-Plugin is capable of executing HLSL and CG shaders, the OpenGL plugin is able to run GLSL and CG shaders.
To load and compile a shader follow the following steps:
Check whether your desired shader language is supported using the "SupportsShaderLanguage" function
If you found a supported language, load the shader source using the "LoadFrom" functions
Finally compile the loaded program using the "CompileProgram" function.
constructor Create(AShaderSystem: TAdShaderSystem); |
|
destructor Destroy; override; |
|
function SupportsShaderLanguage(ALanguage: TAdVeryShortString): boolean; |
|
procedure LoadFromStream(AStream: TStream); |
|
procedure LoadFromStrings(AStrs: TStrings); |
|
procedure LoadFromString(AStr: string); |
|
procedure LoadFromFile(AFile: string); |
|
function CompileProgram(AShaderLanguage: TAdVeryShortString; AProgramName: string; AShaderType: TAd2dShaderType): boolean; |
|
procedure BindEffect; |
|
procedure UnbindEffect; |
|
procedure SetParameter(AName: string; AValue: single); overload; |
|
procedure SetParameter(AName: string; AValue: integer); overload; |
|
procedure SetParameter(AName: string; AValue: TAdMatrix); overload; |
|
procedure SetParameter(AName: string; AValue: TAd2dTexture); overload; |
|
procedure SetParameter(AName: string; AValue: TAndorraColor); overload; |
|
procedure SetParameter(AName: string; AValue: TAdVector3); overload; |
|
procedure SetParameter(AName: string; AValue: TAdVector4); overload; |
|
procedure SetParameter(AName: string; AValue: TAdVector2); overload; |
property Shader: TAd2dShader read FShader; |
|
property ShaderLanguage: TAdVeryShortString read FShaderLanguage; |
|
property ShaderType: TAd2dShaderType read FShaderType; |
|
property ProgramName: string read FProgramName; |
constructor Create(AShaderSystem: TAdShaderSystem); |
|
Creates an instance of TAdShader, linked to the shader system defined in the "AShaderSystem" parameter. So before freeing TAdShaderSystem, always destroy the shader objects linked to it. |
destructor Destroy; override; |
|
Destroys the instance of TAdShader and frees its reserved memory and shader objects. |
function SupportsShaderLanguage(ALanguage: TAdVeryShortString): boolean; |
|
Returns whether a shader language is supported. Parameters
See also
|
procedure LoadFromStream(AStream: TStream); |
|
Loads the shader sourcecode from a stream. |
procedure LoadFromStrings(AStrs: TStrings); |
|
Loads the shader sourcecode from a string list. |
procedure LoadFromString(AStr: string); |
|
Loads the shader sourcecode from a single string. |
procedure LoadFromFile(AFile: string); |
|
Loads the shader sourcecode from the specified file. |
function CompileProgram(AShaderLanguage: TAdVeryShortString; AProgramName: string; AShaderType: TAd2dShaderType): boolean; |
|
Compiles the program loaded by the "LoadFrom" functions. Parameters
Exceptions raised
See also
|
procedure BindEffect; |
|
Activates the loaded effect. Remember that only one pixel and one vertex shader can be active at the same time. Exceptions raised
|
procedure UnbindEffect; |
|
Deactivate the loaded effect. Depending on the implementation in the graphic system. |
procedure SetParameter(AName: string; AValue: single); overload; |
|
Sets a "uniform" float parameter in the shader to the specified value. Exceptions raised
|
procedure SetParameter(AName: string; AValue: integer); overload; |
|
Sets a "uniform" integer parameter in the shader to the specified value. Exceptions raised
|
procedure SetParameter(AName: string; AValue: TAdMatrix); overload; |
|
Sets a "uniform" 4x4 float matrix parameter in the shader to the specified value. Exceptions raised
|
procedure SetParameter(AName: string; AValue: TAd2dTexture); overload; |
|
Sets a "uniform" sampler2D parameter in the shader to the specified Andorra 2D texture. Exceptions raised
|
procedure SetParameter(AName: string; AValue: TAndorraColor); overload; |
|
Sets a "uniform" float4 parameter in the shader to the specified Andorra 2D color. Exceptions raised
|
procedure SetParameter(AName: string; AValue: TAdVector3); overload; |
|
Sets a "uniform" float3 parameter in the shader to the specified vector. Exceptions raised
|
procedure SetParameter(AName: string; AValue: TAdVector4); overload; |
|
Sets a "uniform" float4 parameter in the shader to the specified vector. Exceptions raised
|
procedure SetParameter(AName: string; AValue: TAdVector2); overload; |
|
Sets a "uniform" float2 parameter in the shader to the specified vector. Exceptions raised
|
property Shader: TAd2dShader read FShader; |
|
Pointer on the internal shader object returned by the graphic plugin. It is not recommended to use this direct way if you don't know exactly what you're doing. See also
|
property ShaderLanguage: TAdVeryShortString read FShaderLanguage; |
|
The language the loaded shader is written in. |
property ShaderType: TAd2dShaderType read FShaderType; |
|
The type of the currently loaded shader - vertex or fragment shader. |
property ProgramName: string read FProgramName; |
|
The name of the currently loaded shader main function. |