Recent

Author Topic: LCL and low level screen routines  (Read 1335 times)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
LCL and low level screen routines
« on: October 12, 2022, 08:04:39 pm »
Does the LCL have a way to discover the screen refresh rate?
And if so, is there a way to synchronise timed code with onset of screen refresh, or is the synchronised calling of Paint outside programmer control (an Invalidate call might be followed by several ms delay before the display is updated) ?

AlexTP

  • Hero Member
  • *****
  • Posts: 2697
    • UVviewsoft
Re: LCL and low level screen routines
« Reply #1 on: October 12, 2022, 08:23:21 pm »
LCL cannot detect the refresh rate. Paint occurs at any rime.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8565
Re: LCL and low level screen routines
« Reply #2 on: October 12, 2022, 08:36:49 pm »
Does the LCL have a way to discover the screen refresh rate?
And if so, is there a way to synchronise timed code with onset of screen refresh, or is the synchronised calling of Paint outside programmer control (an Invalidate call might be followed by several ms delay before the display is updated) ?

On what OS? On what kind of hardware? What makes you think that there really is such a thing as a refresh rate these days?

I think a more useful question would be the latency between a command being sent to Windows or X11 etc., and the image on the LCD changing. But these days there is such a vast number of intervening alphabet soup that it is effectively unanswerable.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jamie

  • Hero Member
  • *****
  • Posts: 7662
Re: LCL and low level screen routines
« Reply #3 on: October 12, 2022, 11:22:43 pm »
in windows you can detect this info.
The only true wisdom is knowing you know nothing

dje

  • Full Member
  • ***
  • Posts: 134
Re: LCL and low level screen routines
« Reply #4 on: October 13, 2022, 12:52:47 am »
EDIT: My understanding of OpenGL's SwapBuffer is that it will sync with the display, so, no matter how hard you try to call it, you wont get a FPS higher than the display rate.

I answer these types of questions by finding out how such a feature would be implemented, and then search the FPC/Lazarus source code for the commands used.
Under Windows you have: (EnumDisplaySettings)
https://stackoverflow.com/questions/4110731/how-to-get-the-screen-refresh-rate
Under Unix style OS's (X11) you have: (XRRGetScreenInfo/XRRConfigCurrentRate)
http://rpm.pbone.net/manpage_idpl_34102865_numer_3_nazwa_XRRGetScreenInfo.html

I searched the FPC/Lazarus code and I couldnt find a cross platform wrapper for this feature. So, you can either search other libraries, or you must code the feature for each OS you want to support:

Example: This returns 60 on my Raspberry Pi:

Code: Pascal  [Select][+][-]
  1. uses xrandr, x, xlib;
  2.  
  3. function GetCurrentRate: integer;
  4. var
  5.   LDisplay: PXDisplay;
  6.   LRootWindow: TWindow;
  7.   LScreenInfo: PXRRScreenConfiguration;
  8. begin
  9.   LDisplay := XOpenDisplay(nil);
  10.   LRootWindow := RootWindow(LDisplay, 0);
  11.   LScreenInfo := XRRGetScreenInfo(LDisplay, LRootWindow);
  12.   Result := XRRConfigCurrentRate(LScreenInfo);
  13.   XCloseDisplay(LDisplay);
  14. end;    

Some people also like to call the commandline tool xrandr to get/set screen settings. This may suit you:

https://www.khronos.org/opengl/wiki/Programming_OpenGL_in_Linux:_Changing_the_Screen_Resolution
« Last Edit: October 13, 2022, 01:36:54 am by dje »

MarkMLl

  • Hero Member
  • *****
  • Posts: 8565
Re: LCL and low level screen routines
« Reply #5 on: October 13, 2022, 08:41:31 am »
Example: This returns 60 on my Raspberry Pi:

...which is connected via HDMI, which still has vestiges of line and frame sync. at least in the earlier versions which were a superset of DVI.

But what of a direct connection on an LCD etc.? My vague recollection is that FPD (and possibly the variant of LVDI which replaces it) still basically sends out the entire screen buffer repeatedly, but I don't think it's safe to rely on any sort of "blanking interval" existing or being accessible.

Not to mention problems where one LCL window is split between two physical displays: even if the apparent frame rate is the same they're not going to be in sync unless- IIRC- you have some expensive Nvidia rig intended for 3D.

In any event, I'm not convinced that any of this is really meaningful any more since a display controller will either have multiport memory or will go to substantial pains to simulate it.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018