TavMainRender - MrShoor/AvalancheProject GitHub Wiki
TavMainRender is the primary class providing the base rendering maintenance functions of Avalanche Project. It should the first class created in a project, following by the initialization of 3D-Graphics API (which in its turn requires that TavMainRender has been associated with a system window).
Rendering a scene, requires MainRender to perform binding to a window, followed by rendering the scene, blitting buffers and presenting the resulting screen to the user. Finishing the rendering process with unbinding.
Methods and Properties
Time related
- function Time64 - returns time in milliseconds
- function Time - returns time in seconds but as float-point value
- function BindTime
- procedure ProcessTimerEvents
- property UpdateStatesInterval - timer event interval in milliseconds
Rendering related
Window management
procedure InvalidateWindow;
procedure Dispatch(var message); override;
property Window: TWindow read GetWindow write SetWindow;
property WindowSize: TVec2i read GetWindowSize;
Time Related
Time64
function Time64: Int64;
Returns number of milliseconds passed since the engine time tracking initialization.
Time
function Time: Double;
Returns number of seconds (whole second in the integer part, and more precise time in fractal part) passed since the engine time tracking initialization.
BindTime64
function BindTime64: Int64;
Returns the milliseconds when then the graphic API was bound
ProcessTimerEvents
procedure ProcessTimerEvents;
The method notifies all objects tracking of the timer event (EM_UPS) about the time intervals passed. The number of time intervals is measures in UpdateStatesInterval , between the time of the method is called and the last time the method was called. If the number of time intervals is zero, no notifications will go out.
The method is called at least once on binding the renderer.
UpdateStatesInterval
property UpdateStatesInterval: Integer read FUPS write FUPS;
The time interval in milliseconds, to count the number of updates that occurred between ProcessTimerEvent calls.
Default value is 20 mls
For example. If the first ProcessTimeEvents occurred on 100 Mls, the next once occurred on 223 mls, then the number of updates would be equal to: (223 - 100) / 20 = 6 updates.
The lower the value the more often ProcessTimeEvents might be calling time event handlers. That might cause CPU overload, and might be quite often in a useless actions, because the time fraction passed is too low.
Window management
InvalidateWindow
procedure InvalidateWindow;
Notifies that underlying OS that the system window that is associated with the MainRender must be repainted as soon as possible. The method doesn't call the rendering right away, instead the rendering will occur as soon as possible via message loop used by OS.
Window
property Window: TWindow read GetWindow write SetWindow;
Returns/sets associated window Handle. For Windows it's HWND structure.
WindowSize
property WindowSize: TVec2i
Returns the client rectangle, within the window coordinates. If no window is associated returns (0,0) size