Can I turn off RAPAGUI in middle of program?

Discuss GUI programming with the RapaGUI plugin here
Post Reply
Bugala
Posts: 1305
Joined: Sun Feb 14, 2010 7:11 pm

Can I turn off RAPAGUI in middle of program?

Post by Bugala »

I ran into new problem with RAPAGUI. Appears that as long as I have "@REQUIRE "RapaGUI" my program not only runs much slower, but it also reacts to mouse clicks very slow. Can easily take more than a second for it to react to mouseclicks.

If I simply remove the Require RapaGUI part from my code, it works no problem at all.

And to clarify, idea was that I used RapaGUI to let user choose the screenmode, but even by skipping this RapaGUI part completely and opening predefined screenmode, still this @REGUIRE "RapaGUI" line causes problem.

Therefore I wonder if I can let user first choose the screenmode, and then completely close RapaGUI. Currently I am using moai.FreeApp() but that doesn't help avoid the problem.
Bugala
Posts: 1305
Joined: Sun Feb 14, 2010 7:11 pm

Re: Can I turn off RAPAGUI in middle of program?

Post by Bugala »

Here is an example code to demonstrate the problem:

Code: Select all

EscapeQuit(True)
@REQUIRE "RapaGUI"

Function draw()
	Box(100, 100, 100, 100, color)
EndFunction
color=#RED

SetInterval(1, draw, 50)

CreateDisplay(0, {Width=1920, Height=1080, Title = "Rogue Football Cardgame", Sizeable=False, borderless=True, smoothscale=True, Mode="Windowed", monitor=1})
OpenDisplay(0)

MakeButton(1, #SIMPLEBUTTON, 100, 100, 100, 100, {OnMouseDown=Function()
						C=1-C
						If C=0 Then color=#RED
						If C=1 Then color=#BLUE
						EndFunction})
Repeat
WaitEvent
Forever
Without @REQUIRE "RapaGUI" program is fully responsive, with the line, it clearly is less responsive.

Tested with HW 10, Windows 11
Bugala
Posts: 1305
Joined: Sun Feb 14, 2010 7:11 pm

Re: Can I turn off RAPAGUI in middle of program?

Post by Bugala »

To add bit more explanation.

Unresponsiveness can be tested by repeatedly clicking on the box. It is supposed to change between red and blue each time you click inside the rectangle area.

With the RAPAGui line, the first one-two clicks seem to happen with normal speed, after that it slows down reacting to clicks. Also, if you keep a break clicking, then the next click happens instant again, after which it slows down responding again.
Flinx
Posts: 274
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Can I turn off RAPAGUI in middle of program?

Post by Flinx »

I know these problems. Look at andreas' answer here, though it is meant for Linux.
And to see the reason, insert a

Code: Select all

StartTimer(1)
above your main loop, and compare the drawing speed:

Code: Select all

Function draw()
	ResetTimer(1)
	Box(100, 100, 100, 100, color)
	DebugPrint(GetTimer(1))
EndFunction
Here (on an older Windows machine) the Box() needs 22-30 ms when using RapaGUI, without RapaGUI it needs fewer than 1 ms.
Bugala
Posts: 1305
Joined: Sun Feb 14, 2010 7:11 pm

Re: Can I turn off RAPAGUI in middle of program?

Post by Bugala »

Thanks.

Although not the answer I was hoping for, this at least tells me I have to figure out some other solution than RapaGUI for my problem, since RapaGUI wont work.
User avatar
airsoftsoftwair
Posts: 5652
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Can I turn off RAPAGUI in middle of program?

Post by airsoftsoftwair »

On Windows/macOS/Linux it's not possible to turn off RapaGUI. Once you @REQUIRE RapaGUI all display-related stuff will run through RapaGUI since on those platforms it's not possible for Hollywood's inbuilt display handler to co-exist with RapaGUI.

On Amiga & compatibles things are different. On Amiga RapaGUI doesn't even replace Hollywood's inbuilt display handler because thanks to the ingenuity of Exec signal and message handling it's perfectly possible to seamlessly integrate RapaGUI with Hollywood's inbuilt display handler so on Amiga systems you also won't have the problem that drawing will be slower once RapaGUI is active because Hollywood's inbuilt display handler will still be used.

On Windows/macOS/Linux that's not possible so using RapaGUI will completely replace Hollywood's inbuilt display handler by a custom RapaGUI one which can be much slower (and also doesn't support everything Hollywood's inbuilt display handler supports). E.g. Hollywood's inbuilt display handler on Windows uses Direct2D for accelerated drawing. RapaGUI can't do that. So using RapaGUI really isn't a good idea if you care about raw drawing performance.
Bugala
Posts: 1305
Joined: Sun Feb 14, 2010 7:11 pm

Re: Can I turn off RAPAGUI in middle of program?

Post by Bugala »

Thanks for clarifying and confirming that. Unfortunately RapaGUI doesnt work as the solution to my problem, for it had been handy otherwise.
Post Reply