| 1 |
{ |
| 2 |
Copyright 2000-2022 Michalis Kamburelis. |
| 3 |
|
| 4 |
This file is part of "Castle Game Engine". |
| 5 |
|
| 6 |
"Castle Game Engine" is free software; see the file COPYING.txt, |
| 7 |
included in this distribution, for details about the copyright. |
| 8 |
|
| 9 |
"Castle Game Engine" is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 12 |
|
| 13 |
---------------------------------------------------------------------------- |
| 14 |
} |
| 15 |
|
| 16 |
{ Time utilities. |
| 17 |
|
| 18 |
Note that the initialization of this unit calls @link(CastleRandomize) |
| 19 |
(which on most platforms just calls standard @code(Randomize)) |
| 20 |
to initialize random sequence of the standard @code(Random). } |
| 21 |
unit CastleTimeUtils; |
| 22 |
|
| 23 |
{$I castleconf.inc} |
| 24 |
|
| 25 |
interface |
| 26 |
|
| 27 |
uses |
| 28 |
{$ifdef MSWINDOWS} Windows, {$endif} |
| 29 |
{$ifdef UNIX} |
| 30 |
{$ifdef FPC} BaseUnix, Unix, Dl, |
| 31 |
{$else} Posix.SysTypes, Posix.SysTime, Posix.SysTimes, {$endif} |
| 32 |
{$endif} |
| 33 |
{$ifdef ANDROID} Linux, {$endif} |
| 34 |
SysUtils, Classes, Math, Generics.Collections, |
| 35 |
CastleUtils; |
| 36 |
|
| 37 |
{$define read_interface} |
| 38 |
{$I castletimeutils_gettickcount64.inc} |
| 39 |
{$I castletimeutils_miscellaneous.inc} |
| 40 |
{$I castletimeutils_timer.inc} |
| 41 |
{$I castletimeutils_processtimer.inc} |
| 42 |
{$I castletimeutils_framespersecond.inc} |
| 43 |
{$I castletimeutils_profiler.inc} |
| 44 |
{$I castletimeutils_frameprofiler.inc} |
| 45 |
{$I castletimeutils_now.inc} |
| 46 |
{$undef read_interface} |
| 47 |
|
| 48 |
implementation |
| 49 |
|
| 50 |
uses Generics.Defaults, DateUtils, |
| 51 |
{$ifdef FPC} |
| 52 |
{$ifdef LINUX} Linux, {$endif} // for clock_gettime |
| 53 |
{$ifdef FREEBSD} FreeBSD, {$endif} // for clock_gettime |
| 54 |
{$else} |
| 55 |
{$ifdef LINUX} Posix.Time, {$endif} // for clock_gettime |
| 56 |
{$endif} |
| 57 |
CastleLog; |
| 58 |
|
| 59 |
{$define read_implementation} |
| 60 |
{$I castletimeutils_miscellaneous.inc} |
| 61 |
{$I castletimeutils_gettickcount64.inc} // must be included before castletimeutils_timer.inc on Windows or Nintendo Switch |
| 62 |
{$I castletimeutils_timer.inc} |
| 63 |
{$I castletimeutils_processtimer.inc} |
| 64 |
{$I castletimeutils_framespersecond.inc} |
| 65 |
{$I castletimeutils_now.inc} |
| 66 |
{$I castletimeutils_profiler.inc} |
| 67 |
{$I castletimeutils_frameprofiler.inc} |
| 68 |
|
| 69 |
initialization |
| 70 |
{ Required by Random and all stuff on top of it } |
| 71 |
CastleRandomize; |
| 72 |
finalization |
| 73 |
FreeAndNil(FProfiler); |
| 74 |
FreeAndNil(FFrameProfiler); |
| 75 |
end. |