Class TShaderConstantSetCallback

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TShaderConstantSetCallback = class(TWrapper)

Description

Callback base class making it possible to set constants for GPU programs every frame.
Implement this class and pass an instance of it to one of the methods in TGPUProgrammingServices when creating a shader. The HandleSetConstants method will be called every frame now.

Hierarchy

Overview

Methods

Public constructor Create(NVideoDriver: TReferenceCounted);
Public destructor Destroy; override;
Public procedure HandleSetConstants(Services: TMaterialRendererServices; UserData: LongInt); virtual; abstract;
Public procedure HandleSetMaterial(Material: PMaterial); virtual;

Properties

Public property VideoDriver: TReferenceCounted read FDriver;

Description

Methods

Public constructor Create(NVideoDriver: TReferenceCounted);

Constructor.
Note that this class is not reference counted, the callback must be Free()d after use.

Parameters
NVideoDriver
The video driver you intend to use this callback with.
Public destructor Destroy; override;

Destructor.

Public procedure HandleSetConstants(Services: TMaterialRendererServices; UserData: LongInt); virtual; abstract;

Called by the engine when the vertex and/or pixel shader constants for an material renderer should be set.
A sample implementation would look like this:

    procedure TMyCallback.HandleSetConstants(Services: TMaterialRendererServices; UserData: LongInt);
    var WorldViewProj: TMatrix4;
        Col: TFloatColor;
    begin    
        // set clip matrix at register 4
        with Services.VideoDriver as TVideoDriver do
            WorldViewProj := GetTransform(tsProjection) * GetTransform(tsView) * GetTransform(tsWorld);
        Services.SetVertexShaderConstant(4, WorldViewProj.Elements);
        
        // set some light color at register 9
        Col := FloatColor(0, 1, 1, 0);
        Services.SetVertexShaderConstant(9, @Col.Alpha, 1);
    end;
                

Parameters
Services
An Interface providing methods to set the constants for the shader.
User-defined
integer which can be specified when creating the shader.
Public procedure HandleSetMaterial(Material: PMaterial); virtual;

Called to let the callback know the used material (optional method).

Properties

Public property VideoDriver: TReferenceCounted read FDriver;

The video driver associated with this callback.


Generated by PasDoc 0.12.1 on 2012-09-14 17:32:22