Best way to do lots of moving things on screen?

Discuss any general programming issues here
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Best way to do lots of moving things on screen?

Post by Bugala »

I am truly surpised how powerful Hollywood is. I made this test code:

Code: Select all

EscapeQuit(True)
@DISPLAY {Width = 1920, Height = 1080}

@REQUIRE "rebelsdl"

CreateBrush(1, 5, 5, #WHITE, {hardware=True})

BeginDoubleBuffer(True) ; set up a hardware double buffer

StartTimer(1)
SetFillStyle(#FILLCOLOR)
For move=1 To 300
     For a = 1 To 100
	For b = 1 To 100
	     DisplayBrush(1, 10 + (a*8) + move, 10+(8*b))
	Next
     Next
Flip
Cls
Next
DebugPrint(GetTimer(1))
Then I tried this both as it is, as well as removing Require RebelSDL, I also tried this by instead drawing same sized filled boxes and here are the restuls:

NO RebelSDL filled boxes: 10300
RebelSDL filled boxes: 9886
NO RebelSDL brushes: 9300
RebelSDL brushes(code above): 8900

First of all, surprisingly displaying brushes was faster than drawing, and another surprise was that RebelSDL gave only very little advantage over Hollywood in my machine. My machine was Win10 Intel Nuc 3, which is starting to be bit old already, and was a low powered machine even when i bought it maybe 5 years ago.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Best way to do lots of moving things on screen?

Post by airsoftsoftwair »

This is not the correct way to do benchmarks. Flip() will synchronize with the monitor's vertical refresh so your loop will be throttled instead of running as fast as possible. If you want to test raw blitting performance with RebelSDL, you need to set "EnableVSync" to FALSE in your @REQUIRE call.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Best way to do lots of moving things on screen?

Post by Bugala »

ah, thanks for clarifying that. Well, regardless, seems even bare hollywood is very fast actually. Faster than I expected. I was expecting it to start stumbling after couple hundred rectangles, and was expecting drawing be even slower.

Oh, and reminds me, when i forgot to add the double buffer first, the Rebel SDL became very slow, just like you warned that RebelSDL not using properly, might make even Hollywood things slower.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Best way to do lots of moving things on screen?

Post by Bugala »

I am need of help in getting Buttons made with RebelSDL, or by otherwords, without having layers on.

When I try to make #SIMPLEBUTTON, it complains I need a BGpic active, when i use "SelectBIPic()", it complains i need layers on.

So how do I make the buttons wihtout putting Layers on?
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Best way to do lots of moving things on screen?

Post by Bugala »

And another thing. If I understood right, Hardware brushes cannot be altered? If so, then can I make Brush a hardware brush at later point?

Right now I have this system where background is drawn first to a brush, then I keep displaying this whole screen size brush every cycle, but I would like that to be hardware brush naturally.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Best way to do lots of moving things on screen?

Post by airsoftsoftwair »

Bugala wrote: Tue Jun 18, 2019 11:28 am When I try to make #SIMPLEBUTTON, it complains I need a BGpic active
You're probably trying to construct a button while a double buffer is active... that won't work. Create your buttons before the double buffer...
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Best way to do lots of moving things on screen?

Post by airsoftsoftwair »

Bugala wrote: Tue Jun 18, 2019 11:34 am And another thing. If I understood right, Hardware brushes cannot be altered? If so, then can I make Brush a hardware brush at later point?

Right now I have this system where background is drawn first to a brush, then I keep displaying this whole screen size brush every cycle, but I would like that to be hardware brush naturally.
Sure, you can convert brushes to hardware brushes using CopyBrush()...
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Best way to do lots of moving things on screen?

Post by Bugala »

airsoftsoftwair wrote: Fri Jun 21, 2019 12:33 pm
Sure, you can convert brushes to hardware brushes using CopyBrush()...
Ah, didnt think of that. Thanks!
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Best way to do lots of moving things on screen?

Post by Bugala »

airsoftsoftwair wrote: Fri Jun 21, 2019 12:32 pm
You're probably trying to construct a button while a double buffer is active... that won't work. Create your buttons before the double buffer...
Thats funny. So I as long as i make them before doublebuffer is on, they work fine even doublebuffer is on. No wonder I couldnt figure that one out. Anyway, no problem doing that way.
xabierpayet
Posts: 267
Joined: Fri Feb 24, 2012 9:34 am

Re: Best way to do lots of moving things on screen?

Post by xabierpayet »

Hello Bugala, and Andreas, i test the snippet supplied by Bugala, and my results are better without RebelSDL, using RebelSDL i have 132000 ms time when i execute the script ,whithout RebelSDL my result is 12900 ms, this in windows 10 64 bits, any idea about why this is happening?
Post Reply