Download Now

    Reference TRenderContext

    Declared in Codebot.Render.Contexts.pas on line 135

    The TRenderContext class provides an interface to all rendering in this library
      TRenderContext = class
      public
        constructor Create;
        destructor Destroy; override;
        { Set the color to use when cleared }
        procedure SetClearColor(R, G, B, A: Float);
        { Clear the color and depth buffer bits }
        procedure Clear;
        { Change rendering ability to remove back facing polygons (default to true) }
        procedure PushCulling(Cull: Boolean);
        { Restore previous setting to remove back facing polygons }
        procedure PopCulling;
        { Change rendering ability to bypass depth buffer testing (default to true) }
        procedure PushDepthTesting(DepthTest: Boolean);
        { Restore previous setting to depth buffer testing }
        procedure PopDepthTesting;
        { Change rendering ability to write to the depth buffer (default to true) }
        procedure PushDepthWriting(DepthWriting: Boolean);
        { Restore previous ability to write to the depth buffer }
        procedure PopDepthWriting;
        { Get the current viewport }
        function GetViewport: TRectI;
        { Set the current viewport erasing the viewport stack }
        procedure SetViewport(X, Y, W, H: Integer);
        { Set the current viewport and pushing the prior one to the stack }
        procedure PushViewport(X, Y, W, H: Integer);
        { Restore the prior viewport from the stack }
        procedure PopViewport;
        { Get the world for this context }
        function GetWorld: TContextManagedObject;
        { Set the world for this context }
        procedure SetWorld(Value: TContextManagedObject);
        { Save the current viewport contents to a bitmap }
        procedure SaveToBitmap(Bitmap: IBitmapData);
        { Save the current viewport contents to a bitmap stream }
        procedure SaveToStream(Stream: TStream);
        { Save the current viewport contents to a bitmap file }
        procedure SaveToFile(const FileName: string);
        { Search for an asset stream first using a resource name then using
          GetAssetFile. }
        function GetAssetStream(const Name: string): TStream;
        { Search upwards for an asset returning the valid filename or raise an
          EContextAssetError exception }
        function GetAssetFile(const FileName: string): string;
        { Search upwards for an asset the same way as GetAssetFile, returning False
          instead of raising an exception if it cannot be found }
        function FindAssetFile(const FileName: string; out Path: string): Boolean;
        { Set the asset folder name, which defaults to 'assets' }
        procedure SetAssetFolder(const Folder: string);
        { Returns a collection by name }
        function GetCollection(const Name: string): TContextCollection;
        { Objects refers to managed objects without a specialized collection }
        function Objects: TManagedObjectCollection;
        { Returns the current program }
        function GetProgram: Integer;
        { Add the program to the stack and activates it }
        procedure PushProgram(Prog: Integer);
        { Removes a program from the stack and potentially deactivates it }
        procedure PopProgram;
        { Set the current program's modelview and perspective uniforms }
        procedure SetProgramMatrix;
        { Get the location of unform for the specified program }
        function GetUniform(Prog: Integer; Name: string; out Location: Integer): Boolean; overload;
        { Get the location of unform for the current program }
        function GetUniform(const Name: string; out Location: Integer): Boolean; overload;
        { Overload to set program uniforms by name }
        procedure SetUniform(Location: Integer; const B: Boolean); overload;
        procedure SetUniform(const Name: string; const B: Boolean); overload;
        procedure SetUniform(Location: Integer; const I: Integer); overload;
        procedure SetUniform(const Name: string; const I: Integer); overload;
        procedure SetUniform(Location: Integer; const X: Float); overload;
        procedure SetUniform(const Name: string; const X: Float); overload;
        procedure SetUniform(Location: Integer; const A: TArray<Float>); overload;
        procedure SetUniform(const Name: string; const A: TArray<Float>); overload;
        procedure SetUniform(Location: Integer; const X, Y: Float); overload;
        procedure SetUniform(const Name: string; const X, Y: Float); overload;
        procedure SetUniform(Location: Integer; const X, Y, Z: Float); overload;
        procedure SetUniform(const Name: string; const X, Y, Z: Float); overload;
        procedure SetUniform(Location: Integer; const X, Y, Z, W: Float); overload;
        procedure SetUniform(const Name: string; const X, Y, Z, W: Float); overload;
        procedure SetUniform(Location: Integer; const V: TVec2); overload;
        procedure SetUniform(const Name: string; const V: TVec2); overload;
        procedure SetUniform(Location: Integer; const V: TVec3); overload;
        procedure SetUniform(const Name: string; const V: TVec3); overload;
        procedure SetUniform(Location: Integer; const V: TVec4); overload;
        procedure SetUniform(const Name: string; const V: TVec4); overload;
        procedure SetUniform(Location: Integer; const M: TMatrix); overload;
        procedure SetUniform(const Name: string; const M: TMatrix); overload;
        { Activate a texture unit (slot to avoid reserved word) which can be any
          number 0-9 }
        procedure SetTextureSlot(Slot: Integer);
        { Retrieve the number of the active texture unit }
        function GetTextureSlot: Integer;
        { Retrieve the texture bound to the active texture unit }
        function GetTexture: Integer;
        { Add the texture to the stack and bind it to a unit }
        procedure PushTexture(Texture: Integer; Slot: Integer = 0);
        { Removes a texture from the stack and potentially activates new texture and
          unit }
        procedure PopTexture;
        { Replaces the current modelview matrix }
        procedure SetModelview(constref M: TMatrix);
        { Returns the current modelview matrix }
        function GetModelview: TMatrix;
        { Adds a new modelview matrix on to the stack }
        procedure PushModelview(const M: TMatrix);
        { Removes the most recent modelview matrix from the stack }
        procedure PopModelview;
        { Replaces the current model view matrix with a look at matrix }
        procedure LookAt(Eye, Center, Up: TVec3);
        { Replaces the current model view matrix with an identity matrix }
        procedure Identity;
        { Transform the current model view matrix with a matrix }
        procedure Transform(constref T: TMatrix);
        { Translate the current model view matrix }
        procedure Translate(X, Y, Z: Float);
        { Rotate the current model view matrix }
        procedure Rotate(X, Y, Z: Float; Order: TRotationOrder = roZXY);
        { Scale the current model view matrix }
        procedure Scale(X, Y, Z: Float);
        { Replace the current projection matrix }
        procedure SetProjection(constref M: TMatrix);
        { Returns the current projection matrix }
        function GetProjection: TMatrix;
        { Adds a new projection matrix to the stack }
        procedure PushProjection(const M: TMatrix);
        { Removes the most recent projection matrix from the stack }
        procedure PopProjection;
        { Replaces the current pespective matrix with a perspective matrix }
        procedure Perspective(FoV, AspectRatio, NearPlane, FarPlane: Float);
        { Replaces the current pespective matrix with a frustum matrix }
        procedure Frustum(Left, Right, Top, Bottom, NearPlane, FarPlane: Float);
      end;

    See also

    Float in Codebot.System.pas
    IBitmapData in Codebot.Platform.pas
    TArray<T> in Codebot.System.pas
    TMatrix in Codebot.Geometry.pas
    TRectI in Codebot.Graphics.Types.pas
    TRotationOrder in Codebot.Geometry.pas
    TVec2 in Codebot.Geometry.pas
    TVec3 in Codebot.Geometry.pas
    TVec4 in Codebot.Geometry.pas