Skip to content

Commit d3ed319

Browse files
committed
Add SDL3_gfx (framerate part)
1 parent 499067d commit d3ed319

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

units/SDL3_framerate.inc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
This file is part of:
3+
4+
SDL3 for Pascal
5+
(https://github.com/PascalGameDevelopment/SDL3-for-Pascal)
6+
SPDX-License-Identifier: Zlib
7+
}
8+
9+
Const
10+
{*!
11+
\brief Highest possible rate supported by framerate controller in Hz (1/s).
12+
*}
13+
FPS_UPPER_LIMIT = 200;
14+
15+
{*!
16+
\brief Lowest possible rate supported by framerate controller in Hz (1/s).
17+
*}
18+
FPS_LOWER_LIMIT = 1;
19+
20+
{*!
21+
\brief Default rate of framerate controller in Hz (1/s).
22+
*}
23+
FPS_DEFAULT = 30;
24+
25+
Type
26+
{*!
27+
\brief Structure holding the state and timing information of the framerate controller.
28+
*}
29+
PPFPSmanager = ^PFPSmanager;
30+
PFPSmanager = ^TFPSmanager;
31+
TFPSmanager = record
32+
framecount: cuint32;
33+
rateticks: cfloat;
34+
baseticks: cuint64;
35+
lastticks: cuint64;
36+
rate: cuint32;
37+
end;
38+
39+
{* Functions return 0 or value for sucess and -1 for error *}
40+
41+
procedure SDL_initFramerate(manager: PFPSmanager); cdecl;
42+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_initFramerate' {$ENDIF} {$ENDIF};
43+
44+
function SDL_setFramerate(manager: PFPSmanager; rate: cuint32): cint; cdecl;
45+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_setFramerate' {$ENDIF} {$ENDIF};
46+
47+
function SDL_getFramerate(manager: PFPSmanager): cint; cdecl;
48+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_getFramerate' {$ENDIF} {$ENDIF};
49+
50+
function SDL_getFramecount(manager: PFPSmanager): cint; cdecl;
51+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_getFramecount' {$ENDIF} {$ENDIF};
52+
53+
function SDL_framerateDelay(manager: PFPSmanager): cuint64; cdecl;
54+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_framerateDelay' {$ENDIF} {$ENDIF};

units/SDL3_gfx.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
{$ENDIF}
4545
{$ENDIF}
4646

47+
{$INCLUDE SDL3_framerate.inc}
4748
{$INCLUDE SDL3_imageFilter.inc}
4849
{$INCLUDE SDL3_rotozoom.inc}
4950

0 commit comments

Comments
 (0)