Recent

Author Topic: Trying to create Smooth SCrolling using BGRA GL Controls.  (Read 4949 times)

Josh

  • Hero Member
  • *****
  • Posts: 1271
Trying to create Smooth SCrolling using BGRA GL Controls.
« on: June 26, 2018, 08:51:46 pm »
HI

I am trying to create a non cpu intensive scrolling text, I tried using LCL using various methods; the best I got was scrolling a panel within a panel, but when scrolling on a large area of large screen, result were jerky and very CPU intensive.

The scroll is just using 5 Label Type Controls as the TExt holders, and these are updated as and when they become in focus.

SO I thought I would try BGRABitmap GL a Go, It is much better in that not so jerky but the CPU usage is still High around 8% CPU, and GPU is about the same.

I suspect I am doing something very basic wrong...

I have attached the project
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Trying to create Smooth SCrolling using BGRA GL Controls.
« Reply #1 on: June 27, 2018, 01:24:50 am »
Hi, what you're doing wrong is moving actual components, instead of drawing directly on a canvas.

I've implemented one. Attached. I compared the CPU usage of this and the one that's on the Lazarus about dialog, and is almost the same. When the Window is maximized it uses between 3-4 of CPU usage (both Lazarus about dialog and my demo).

What you can optimize, is drawing the text only once into a temporary bitmap (a big bitmap, so it will use more memory) and just drawing the part of that bitmap that's actually visible in the screen. With BGRABitmap that's possible, Bitmap.GetPart(..) then draw that part into the base bitmap that's used by BGRAVirtualScreen. Is just an idea and maybe it doesn't optimize too much.

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: Trying to create Smooth SCrolling using BGRA GL Controls.
« Reply #2 on: June 27, 2018, 12:52:13 pm »
Hi Lainz,

Thanks for the demo.

I was wanting to have clickable controls scrolling, but with all the redrawing etc; the impact is rather large. So Agree must use textout on the canvas to; and use some logic to determine if anything is clickable within the 'scrolling window'.

If I increase the Font Size and change the pixel scroll amount to say -4; I get around 2.2%CPU on full screen. Maybe It can be optimized.

I had thought of creating a large canvas, but the canvas size is limited to I think 32767 when addressing it ordinates. ( windows limitation in how the x,y are stored).

I have attached a revised scroller, that looks pretty good, and is not too cpu intensive, if you could have a look see and see if you could see anything that could reduce the cpu usage even further.  ( full screen is worst obviously, on mine its about 2.9% ; 1920x1080).  its using normal LCL, so if BGRABitmap could help it;)

nb, best viewed with a Mono spaced font, I am using 'Hack' font.. You can change most values defined in the Projects VAR section.


UPDATED project, you can now scroll tpanel or timage
« Last Edit: June 27, 2018, 02:27:17 pm by josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Soner

  • Sr. Member
  • ****
  • Posts: 305
Re: Trying to create Smooth SCrolling using BGRA GL Controls.
« Reply #3 on: June 27, 2018, 01:59:06 pm »
Try that convert to lazarus, it was good as I tried it:
http://www.delphiarea.com/products/delphi-components/marquee/

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Trying to create Smooth SCrolling using BGRA GL Controls.
« Reply #4 on: June 27, 2018, 02:33:12 pm »
On my CPU your latest demo uses around 5-7% (i7 4790).

I'm not sure if is better to use TBGRABitmap or TBitmap in this case. I've not compared his speeds, there is some test on the wiki, but more real than the case you will use it is nothing. So you can try making a copy of it and replacing TBitmap with TBGRABitmap and see. They had almost the same functions (BGRABitmap has more).

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: Trying to create Smooth SCrolling using BGRA GL Controls.
« Reply #5 on: June 27, 2018, 02:52:27 pm »
Hi Lainz,

I will have a play using BGRABitmap, maybe late today or tommorrow before I get a chance..

Suprised your getting 5-7% on latest split screen version, I get around 1.5% when form maximized on either the Tpanel or Timage,
Ruuning Ryzen 7 1800x
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Trying to create Smooth SCrolling using BGRA GL Controls.
« Reply #6 on: June 27, 2018, 03:02:37 pm »
Yes. Is good to know that in lower hardware will work worst.


Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: Trying to create Smooth SCrolling using BGRA GL Controls.
« Reply #8 on: June 27, 2018, 08:20:02 pm »
Hi lainz,

Just tried to add some timer throttling, does that help the cpu %
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Trying to create Smooth SCrolling using BGRA GL Controls.
« Reply #9 on: June 28, 2018, 01:31:13 am »
1% the left side, 1.0 - 1.5 % the right side when Maximized (but it runs too slow, I need to tweak something?).

When not maximized, it stays at 0%. (it runs normally).

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: Trying to create Smooth SCrolling using BGRA GL Controls.
« Reply #10 on: July 21, 2018, 08:38:49 pm »
Keep in mind that the BGRA OpenGL controls don't really use particularly modern OpenGL techniques. There's a whole lot of glBegin/glEnd, which will indeed hammer the CPU.
« Last Edit: July 22, 2018, 12:08:57 am by Akira1364 »

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Trying to create Smooth SCrolling using BGRA GL Controls.
« Reply #11 on: July 21, 2018, 08:49:19 pm »
What about Castle Game Engine? You know how it's made? Because it as well supports Android and iOS, and maybe we can make multiplatform programs with that, even if it's originally designed for games.

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: Trying to create Smooth SCrolling using BGRA GL Controls.
« Reply #12 on: July 21, 2018, 09:13:20 pm »
Castle is all modern OpenGL. It already actually has a GUI framework built in, also.

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Trying to create Smooth SCrolling using BGRA GL Controls.
« Reply #13 on: July 21, 2018, 09:28:50 pm »
Castle is all modern OpenGL. It already actually has a GUI framework built in, also.

Yes, i'm playing with it, works really smooth.

I'm learning just with the manual, so I can make something.

 

TinyPortal © 2005-2018