CAST II Game Engine

   DESCRIPTION       FEATURES       SCREENSHOTS       FORUMS       DOCUMENTATION       DOWNLOADS       CONTACTS   
Units
Class Hierarchy
Classes, Interfaces and Objects
Types
Enumerations
Variables
Constants
Functions and Procedures
Identifiers

Class TRenderer

Unit

C2Render

Declaration

type TRenderer = class(TSubsystem)

Description

Renderer class

Contains API-independent routines and an interface fo API-dependent ones

Fields

 NameDescription
PublicActiveRenderer performs rendering only if this variable is True. Active is set automatically in response on window minimization or switching to another application in fullscreen mode.
ProtectedAPIBuffersAPI-specific buffer management object
PublicAPIStateReference to API state wrapper object
PublicAppRequirementsApplication requirements record. These values can be changed before renderer initialization to change its behaviour.
PublicBiasMatBias matrix used to remap texture coordinates for mirror and shadow map modes
ProtectedBuffersAPI-independent buffer management object
ProtectedDebugMaterialMaterial for debug rendering
ProtectedDebugTesselatorsTesselators for primitives used in debug rendering
ProtectedDesktopVideoModeCurrent desktop video mde
PublicDisableTesselationIf set to True data existing in vertex/index buffers are always considered as valid and no tesselation will be performed
ProtectedFAdapterNamesNames of video adapters in system
ProtectedFCurrentAdapterCurrent video adapter
ProtectedFCurrentVideoModeCurrent video mode index in FVideoModes array
ProtectedFCurrentZBufferDepthCurrent depth of Z-buffer
ProtectedFDebugOutputDebug output state
ProtectedFFramesRenderedNumber of frames rendered
ProtectedFFullScreenFull screen mode state
ProtectedFLastAppliedCameraLast applied camera
ProtectedFMainCameraTop-level camera through which a scene is visible for user
ProtectedFNormalWindowStyleWindow style in not full-screen mode
ProtectedFPerfProfilePerformance profile
ProtectedFStateCurrent renderer state
ProtectedFTotalAdaptersNumber of video adapters in system
ProtectedFTotalVideoModesNumber of video modes available
ProtectedFVideoModesVideo modes available
ProtectedFWindowedRectRendering area in windowed mode
ProtectedGammaRampCurrent gamma ramp
PublicHardwareClippingTrue if even transformed vertices are clipped by hardware (DirectX only, seems incorrect)
ProtectedManagerReference to items manager
PublicMaxAPILightsMaximum number of light sources which may be simultaneously set through API
PublicMaxClipPlanesMaximum number of user clipping planes
PublicMaxHardwareLightsMaximum number of light sources simultaneously handled by hardware T&L (fixed function pipeline only)
PublicMaxPointSizeMaximum point size
PublicMaxPrimitiveCountMaximum number of primitives per single API call (DIP)
PublicMaxTextureHeightMaximum supported texture height
PublicMaxTexturesPerPassMaximum number of textures which may be used in a pass
PublicMaxTextureStagesMaximum number of texture stages which may be used in a pass
PublicMaxTextureWidthMaximum supported texture width
PublicMaxVertexIndexMaximum index value in index buffer
PublicMaxVertexShaderConstsMax vertex shader constants
PublicPixelShaderVersionMajorMajor pixel shader version
PublicPixelShaderVersionMinorMinor pixel shader version
PublicPower2TexturesTrue if only power of two-sized textures are supported
PublicRenderHeightCurrent render window height
PublicRenderWidthCurrent render window width
ProtectedRenderWindowHandleHandle of render window
PublicSquareTexturesTrue if only square textures are supported
ProtectedTesselationParamsThis record passed to tesselators buffer filling methods
PublicTexturesTextures
PublicVertexShaderVersionMajorMajor vertex shader version
PublicVertexShaderVersionMinorMinor vertex shader version
ProtectedViewPortCurrent viewport
PublicWBufferingTrue if w-buffering is supported

Methods

Overview

Publicconstructor Create(AManager: TItemsManager); virtual;
Publicdestructor Destroy; override;
Protectedfunction APICheckFormat(const Format, Usage, RTFormat: Cardinal): Boolean; virtual; abstract;
Protectedfunction APICreateDevice(WindowHandle, AVideoMode: Cardinal; AFullScreen: Boolean): Boolean; virtual; abstract;
Protectedprocedure APIPrepareFVFStates(Item: TVisible); virtual; abstract;
Publicprocedure APIRenderIndexedStrip(Tesselator: TTesselator; StripIndex: Integer); virtual; abstract;
Publicprocedure APIRenderStrip(Tesselator: TTesselator; StripIndex: Integer); virtual; abstract;
Protectedfunction APIToPixelFormat(Format: Cardinal): Cardinal;
Publicprocedure ApplyCamera(Camera: CAST2.TCamera); virtual;
Publicprocedure ApplyLight(Index: Integer; const ALight: TLight); virtual; abstract;
Publicprocedure BuildModeList; virtual; abstract;
Publicprocedure CheckCaps; virtual; abstract;
Publicfunction CheckFormat(const Format, Usage, RTFormat: Cardinal; out NewFormat: Integer): Boolean; virtual;
Publicprocedure CheckTextureFormats; virtual; abstract;
Publicprocedure Clear(Flags: TClearFlagsSet; Color: BaseTypes.TColor; Z: Single; Stencil: Cardinal); virtual; abstract;
Publicfunction CreateDevice(WindowHandle, AVideoMode: Cardinal; AFullScreen: Boolean): Boolean;
Publicprocedure FinishFrame; virtual; abstract;
Publicprocedure HandleMessage(const Msg: TMessage); override;
Publicprocedure InitDebugRender(ADebugMaterial: TMaterial); virtual;
Protectedprocedure InternalDeInit; virtual;
Protectedfunction InternalGetIndexBufferIndex(Static: Boolean; BufferIndex: Integer): Integer;
Protectedprocedure InternalInit;
Publicfunction IsReady: Boolean;
Protectedfunction PrepareWindow: Boolean;
Publicprocedure ProjectToScreen(out Projected: TVector4s; const Vector: TVector3s);
Publicprocedure RenderItem(Item: TVisible);
Publicprocedure RenderItemBox(Item: CAST2.TProcessing; Color: BaseTypes.TColor); virtual; abstract;
Publicprocedure RenderItemDebug(Item: CAST2.TProcessing); virtual; abstract;
Publicprocedure RenderTesselator(Tesselator: TTesselator);
Publicfunction RestoreDevice(AVideoMode: Cardinal; AFullScreen: Boolean): Boolean; virtual;
Protectedprocedure SetFullScreen(const FScreen: Boolean); virtual;
Publicprocedure SetGamma(Gamma, Contrast, Brightness: Single); virtual;
Publicprocedure SetPerfProfile(APerfProfile: TPerfProfile); virtual;
Publicprocedure SetVideoAdapter(Adapter: Cardinal);
Publicprocedure SetViewPort(const X, Y, Width, Height: Integer; const MinZ, MaxZ: Single); virtual;
Publicprocedure StartFrame; virtual;
Publicfunction ValidateMaterial(const Material: TMaterial): Boolean;

Description

Publicconstructor Create(AManager: TItemsManager); virtual;

 

Publicdestructor Destroy; override;

 

Protectedfunction APICheckFormat(const Format, Usage, RTFormat: Cardinal): Boolean; virtual; abstract;

Returns True if a pixel format is available and can be used as a texture, render target or depth-stencil buffer. RTFormat is used only with depth-stencil usage to determine whether the supported depth-stencil format can be used with the given render target format.

Protectedfunction APICreateDevice(WindowHandle, AVideoMode: Cardinal; AFullScreen: Boolean): Boolean; virtual; abstract;

Calls an API to initialize render device for rendering to the specified window or specified video mode

Protectedprocedure APIPrepareFVFStates(Item: TVisible); virtual; abstract;

Calls an API to set item's transformation, some FVF-related states

Publicprocedure APIRenderIndexedStrip(Tesselator: TTesselator; StripIndex: Integer); virtual; abstract;

Performs necessary API calls to render a piece of indexed triangles

Publicprocedure APIRenderStrip(Tesselator: TTesselator; StripIndex: Integer); virtual; abstract;

Performs necessary API calls to render a piece of triangles

Protectedfunction APIToPixelFormat(Format: Cardinal): Cardinal;

Returns CAST pixel format from an API-specific one

Publicprocedure ApplyCamera(Camera: CAST2.TCamera); virtual;

Applies render target settings, transformations, clear settings of the given camera to the renderer

Publicprocedure ApplyLight(Index: Integer; const ALight: TLight); virtual; abstract;

Apply a light source with the specified index

Publicprocedure BuildModeList; virtual; abstract;

Build available video modes list

Publicprocedure CheckCaps; virtual; abstract;

Checks capabilities

Publicfunction CheckFormat(const Format, Usage, RTFormat: Cardinal; out NewFormat: Integer): Boolean; virtual;

Checks if the given pixel format is supported for the given usage. RTFormat is used only with depth-stencil usage to determine whether the supported depth-stencil format can be used with the given render target format. Returns False if the pixel format is unsupported. Also fills NewFormat with suggested substitue or with pfUndefined if no suitable substitution found.

Publicprocedure CheckTextureFormats; virtual; abstract;

Checks available texture formats

Publicprocedure Clear(Flags: TClearFlagsSet; Color: BaseTypes.TColor; Z: Single; Stencil: Cardinal); virtual; abstract;

Clear the specified parts of current render target with the specified values

Publicfunction CreateDevice(WindowHandle, AVideoMode: Cardinal; AFullScreen: Boolean): Boolean;

Initializes render device to render to the specified window or specified mode

Publicprocedure FinishFrame; virtual; abstract;

Ends a rendering cycle

Publicprocedure HandleMessage(const Msg: TMessage); override;

Default message handling

Publicprocedure InitDebugRender(ADebugMaterial: TMaterial); virtual;

Initializes debug tesselators and material

Protectedprocedure InternalDeInit; virtual;

For internal use only

Protectedfunction InternalGetIndexBufferIndex(Static: Boolean; BufferIndex: Integer): Integer;

For internal use only

Protectedprocedure InternalInit;

For internal use only

Publicfunction IsReady: Boolean;

Returns True if the renderer is ready to render

Protectedfunction PrepareWindow: Boolean;

Prepares render window for windowed rendering

Publicprocedure ProjectToScreen(out Projected: TVector4s; const Vector: TVector3s);

Projects Vector with MainCamera and returns the result in Projected

Publicprocedure RenderItem(Item: TVisible);

Ensures that vertex/index buffers contains an up-to-date representation of the specified item, calls APIPrepareItem() and renders it's tesselator

Publicprocedure RenderItemBox(Item: CAST2.TProcessing; Color: BaseTypes.TColor); virtual; abstract;

Renders item's bounding box

Publicprocedure RenderItemDebug(Item: CAST2.TProcessing); virtual; abstract;

Renders item's debug information (currently colliding volumes if present)

Publicprocedure RenderTesselator(Tesselator: TTesselator);

Renders the specified tesselator

Publicfunction RestoreDevice(AVideoMode: Cardinal; AFullScreen: Boolean): Boolean; virtual;

Restores render device with the specified video mode (if fullscreen)

Protectedprocedure SetFullScreen(const FScreen: Boolean); virtual;

Toggles fullscreen mode

Publicprocedure SetGamma(Gamma, Contrast, Brightness: Single); virtual;

Adjusts gamma ramp

Publicprocedure SetPerfProfile(APerfProfile: TPerfProfile); virtual;

Sets performance profile

Publicprocedure SetVideoAdapter(Adapter: Cardinal);

Sets video adapter

Publicprocedure SetViewPort(const X, Y, Width, Height: Integer; const MinZ, MaxZ: Single); virtual;

Sets render viewport

Publicprocedure StartFrame; virtual;

Starts a rendering cycle

Publicfunction ValidateMaterial(const Material: TMaterial): Boolean;

Validates all techniques of the given material for current hardware configuration. Returns True if the set of available techniques changed during validation.

Properties

Overview

Publicproperty AdapterName[Index: Cardinal]: string;
Publicproperty CurrentAdapter: Cardinal;
Publicproperty CurrentVideoMode: Cardinal;
Publicproperty CurrentZBufferDepth: Cardinal;
Publicproperty DebugOutput: Boolean;
Publicproperty FramesRendered: Integer;
Publicproperty FullScreen: Boolean;
Publicproperty LastAppliedCamera: CAST2;
Publicproperty MainCamera: CAST2;
Publicproperty State: TRendererState;
Publicproperty TotalAdapters: Cardinal;
Publicproperty TotalRenderTargets: Integer;
Publicproperty TotalVideoModes: Cardinal;
Publicproperty VideoMode[Index: Cardinal]: TVideoMode;
Publicproperty WindowedRect: TRect;

Description

Publicproperty AdapterName[Index: Cardinal]: string;

Names of video adapters in system by index

Publicproperty CurrentAdapter: Cardinal;

Current video adapter

Publicproperty CurrentVideoMode: Cardinal;

Current video mode index in FVideoModes array

Publicproperty CurrentZBufferDepth: Cardinal;

Current depth of Z-buffer

Publicproperty DebugOutput: Boolean;

Debug output state

Publicproperty FramesRendered: Integer;

Number of frames rendered

Publicproperty FullScreen: Boolean;

Full screen mode state

Publicproperty LastAppliedCamera: CAST2;

Currently applyed camera. May change during frame visulization (if render to texture used).

Publicproperty MainCamera: CAST2;

Camera through which a scene is rendered. Can't be changed during frame visulization.

Publicproperty State: TRendererState;

Current renderer state

Publicproperty TotalAdapters: Cardinal;

Number of video adapters in system

Publicproperty TotalRenderTargets: Integer;

Additional render targets currently allocated

Publicproperty TotalVideoModes: Cardinal;

Number of video modes available

Publicproperty VideoMode[Index: Cardinal]: TVideoMode;

Video modes available by index

Publicproperty WindowedRect: TRect;

Rendering area in windowed mode

Last modified: 4 Jul, 2008
Copyright (C) 2006-2008, casteng.com