Author Topic: Image inside Bitmap  (Read 1285 times)

furious programming

  • Hero Member
  • *****
  • Posts: 743
Re: Image inside Bitmap
« Reply #15 on: January 24, 2023, 01:53:05 pm »
As far as I know the lowest possible value for TTimer.Interval is 15 on Windows 7, any lower value will be ignored.

Typically, the minimum interval is about 10ms on all Windows systems (at least since Windows XP). The minimum available interval is 1ms, but to activate it, use the timeBeginPeriod function, and when high resolution is no longer needed, restore the previous one using the timeEndPeriod function. Two simple functions are enough for this:

Code: Pascal  [Select][+][-]
  1. uses
  2.   MMSystem;
  4. var
  5.   TimePeriod: Integer = -1;
  7. procedure InitializeShedulerResolution();
  8. var
  9.   Periods: TTimeCaps;
  10. begin
  11.   if TimeGetDevCaps(@Periods, SizeOf(Periods)) = TIMERR_NOERROR then
  12.     if TimeBeginPeriod(Periods.wPeriodMin) = TIMERR_NOERROR then
  13.       TimePeriod := Periods.wPeriodMin;
  14. end;
  16. procedure FinalizeShedulerResolution();
  17. begin
  18.   if TimePeriod <> -1 then
  19.     TimeEndPeriod(TimePeriod);
  20. end;

This is an example of setting a minimum interval, once for the entire program session.

Within one session of the program, the resolution of the sheduler can be changed many times, but there must be the same number of calls to timeBeginPeriod as to timeEndPeriod. You can change the resolution only when you need it and then restore it right away. This will allow you to use slightly less energy and increase system performance, because the sheduler will run at a higher resolution only at specific times, not for the entire session of the program. Although in the end, the system will decide it anyway, but it would be good to help it with this.

When creating games, you don't have to worry about it, because libraries such as SDL take care of it for us.
« Last Edit: January 25, 2023, 01:24:16 pm by furious programming »
Lazarus 2.2.6 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2025.


  • Full Member
  • ***
  • Posts: 101
  • From C# to Lazarus
Re: Image inside Bitmap
« Reply #16 on: January 26, 2023, 01:46:18 pm »


What follow is not related with Pascal Lazarus, but with game development.

If in the future you're interested, with creating Games,

Try Godot it's a 2D/3D opensource Game Engine.

Work on Windows, Linux and Mac.

you can use Python or C# language.



TinyPortal © 2005-2018