Class TAdShader

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TAdShader = class(TObject)

Description

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:

See also
TAdShaderSystem
Andorra 2D's main shader system class.

Hierarchy

Overview

Methods

Public constructor Create(AShaderSystem: TAdShaderSystem);
Public destructor Destroy; override;
Public function SupportsShaderLanguage(ALanguage: TAdVeryShortString): boolean;
Public procedure LoadFromStream(AStream: TStream);
Public procedure LoadFromStrings(AStrs: TStrings);
Public procedure LoadFromString(AStr: string);
Public procedure LoadFromFile(AFile: string);
Public function CompileProgram(AShaderLanguage: TAdVeryShortString; AProgramName: string; AShaderType: TAd2dShaderType): boolean;
Public procedure BindEffect;
Public procedure UnbindEffect;
Public procedure SetParameter(AName: string; AValue: single); overload;
Public procedure SetParameter(AName: string; AValue: integer); overload;
Public procedure SetParameter(AName: string; AValue: TAdMatrix); overload;
Public procedure SetParameter(AName: string; AValue: TAd2dTexture); overload;
Public procedure SetParameter(AName: string; AValue: TAndorraColor); overload;
Public procedure SetParameter(AName: string; AValue: TAdVector3); overload;
Public procedure SetParameter(AName: string; AValue: TAdVector4); overload;
Public procedure SetParameter(AName: string; AValue: TAdVector2); overload;

Properties

Public property Shader: TAd2dShader read FShader;
Public property ShaderLanguage: TAdVeryShortString read FShaderLanguage;
Public property ShaderType: TAd2dShaderType read FShaderType;
Public property ProgramName: string read FProgramName;

Description

Methods

Public 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.

Public destructor Destroy; override;

Destroys the instance of TAdShader and frees its reserved memory and shader objects.

Public function SupportsShaderLanguage(ALanguage: TAdVeryShortString): boolean;

Returns whether a shader language is supported.

Parameters
ALanguage
is the shader id consiting of maximal four letters. Currently supported shader languages are:

hlsl

HLSL is the shader language integrated in D3D.

glsl

GLSL is the shader language integrated in OpenGL.

cg

The CG-Shader language developed by Nvidea, can be used simultaneously with D3D and OpenGL

See also
TAdShader.CompileProgram
Compiles the program loaded by the "LoadFrom" functions.
Public procedure LoadFromStream(AStream: TStream);

Loads the shader sourcecode from a stream.

Public procedure LoadFromStrings(AStrs: TStrings);

Loads the shader sourcecode from a string list.

Public procedure LoadFromString(AStr: string);

Loads the shader sourcecode from a single string.

Public procedure LoadFromFile(AFile: string);

Loads the shader sourcecode from the specified file.

Public function CompileProgram(AShaderLanguage: TAdVeryShortString; AProgramName: string; AShaderType: TAd2dShaderType): boolean;

Compiles the program loaded by the "LoadFrom" functions.

Parameters
AShaderLanguage
specifies the language the shader sourcecode is written in
AProgramName
specifies the name of the main function that is used by the shader language.
AShaderType
specifies whether you want to use the shader as a vertex or a fragment (pixel) shader.
Exceptions raised
EUnsupportedShaderLanguage
if the shader language is not supported.
See also
TAdShader.SupportsShaderLanguage
Returns whether a shader language is supported.
TAdShader.LoadFromStream
Loads the shader sourcecode from a stream.
TAdShader.LoadFromFile
Loads the shader sourcecode from the specified file.
TAdShader.LoadFromString
Loads the shader sourcecode from a single string.
TAdShader.LoadFromStrings
Loads the shader sourcecode from a string list.
Public procedure BindEffect;

Activates the loaded effect. Remember that only one pixel and one vertex shader can be active at the same time.

Exceptions raised
EShaderNotLoaded
if the shader is not compiled or not available
Public procedure UnbindEffect;

Deactivate the loaded effect. Depending on the implementation in the graphic system.

Public procedure SetParameter(AName: string; AValue: single); overload;

Sets a "uniform" float parameter in the shader to the specified value.

Exceptions raised
EShaderNotLoaded
if the shader is not compiled or not available
Public procedure SetParameter(AName: string; AValue: integer); overload;

Sets a "uniform" integer parameter in the shader to the specified value.

Exceptions raised
EShaderNotLoaded
if the shader is not compiled or not available
Public procedure SetParameter(AName: string; AValue: TAdMatrix); overload;

Sets a "uniform" 4x4 float matrix parameter in the shader to the specified value.

Exceptions raised
EShaderNotLoaded
if the shader is not compiled or not available
Public procedure SetParameter(AName: string; AValue: TAd2dTexture); overload;

Sets a "uniform" sampler2D parameter in the shader to the specified Andorra 2D texture.

Exceptions raised
EShaderNotLoaded
if the shader is not compiled or not available
Public procedure SetParameter(AName: string; AValue: TAndorraColor); overload;

Sets a "uniform" float4 parameter in the shader to the specified Andorra 2D color.

Exceptions raised
EShaderNotLoaded
if the shader is not compiled or not available
Public procedure SetParameter(AName: string; AValue: TAdVector3); overload;

Sets a "uniform" float3 parameter in the shader to the specified vector.

Exceptions raised
EShaderNotLoaded
if the shader is not compiled or not available
Public procedure SetParameter(AName: string; AValue: TAdVector4); overload;

Sets a "uniform" float4 parameter in the shader to the specified vector.

Exceptions raised
EShaderNotLoaded
if the shader is not compiled or not available
Public procedure SetParameter(AName: string; AValue: TAdVector2); overload;

Sets a "uniform" float2 parameter in the shader to the specified vector.

Exceptions raised
EShaderNotLoaded
if the shader is not compiled or not available

Properties

Public 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
TAd2dShader
The abstract shader class that is created by a shader system.
Public property ShaderLanguage: TAdVeryShortString read FShaderLanguage;

The language the loaded shader is written in.

Public property ShaderType: TAd2dShaderType read FShaderType;

The type of the currently loaded shader - vertex or fragment shader.

Public property ProgramName: string read FProgramName;

The name of the currently loaded shader main function.

SourceForge.net Logo


Generated by PasDoc 0.11.0 on 2008-12-31 14:32:00