Recent

Author Topic: Call code every frame  (Read 2731 times)

GreatCorn

  • New Member
  • *
  • Posts: 38
    • GreatCorn
Call code every frame
« on: March 20, 2018, 10:28:55 am »
Hi. I am really new to Lazarus and I need to do a simple thing - call a piece of code every frame if a boolean is true. I've tried timers, but they are really slow, I tried searching for anything else and I simply didn't find what I wanted. Is there a procedure for this? Something like the Update() function?

bigeno

  • Sr. Member
  • ****
  • Posts: 266
Re: Call code every frame
« Reply #1 on: March 20, 2018, 11:00:35 am »
For TTimer you can set 1 milisecond, do you need more precise than 1 millisecond ?

maybe here http://wiki.freepascal.org/QueryPerformanceCounter

GreatCorn

  • New Member
  • *
  • Posts: 38
    • GreatCorn
Re: Call code every frame
« Reply #2 on: March 20, 2018, 11:12:17 am »
For TTimer you can set 1 milisecond, do you need more precise than 1 millisecond ?

maybe here http://wiki.freepascal.org/QueryPerformanceCounter
Sorry, I'm a noob in Lazarus. How exactly do I do it?

bigeno

  • Sr. Member
  • ****
  • Posts: 266
Re: Call code every frame
« Reply #3 on: March 20, 2018, 11:23:48 am »
Just set interval value. See attached screenshot

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Call code every frame
« Reply #4 on: March 20, 2018, 11:31:44 am »
For TTimer you can set 1 milisecond, do you need more precise than 1 millisecond ?

maybe here http://wiki.freepascal.org/QueryPerformanceCounter
1 millisecond is usually impossible. Minimal value is USER_TIMER_MINIMUM = 10. But even this value isn't guaranteed, as I know, due to internal kernel precision or something like that. Something around 20-30 milliseconds is only guaranteed interval.
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

bigeno

  • Sr. Member
  • ****
  • Posts: 266
Re: Call code every frame
« Reply #5 on: March 20, 2018, 12:00:43 pm »
1 millisecond is usually impossible. Minimal value is USER_TIMER_MINIMUM = 10. But even this value isn't guaranteed, as I know, due to internal kernel precision or something like that. Something around 20-30 milliseconds is only guaranteed interval.
oh yes, but I don't think he will need more then 100fps

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Call code every frame
« Reply #6 on: March 20, 2018, 12:32:42 pm »
Timers are so no,no. Override OnPaint.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

GreatCorn

  • New Member
  • *
  • Posts: 38
    • GreatCorn
Re: Call code every frame
« Reply #7 on: March 20, 2018, 02:13:01 pm »
Just set interval value. See attached screenshot
Oh my god. I am so dumb. Thank you very much

 

TinyPortal © 2005-2018