Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] how to set mainLoopMode from startFidget #159

Open
IvanScheers opened this issue Jun 15, 2021 · 2 comments
Open

[Question] how to set mainLoopMode from startFidget #159

IvanScheers opened this issue Jun 15, 2021 · 2 comments

Comments

@IvanScheers
Copy link

I tried setting the mailLoopMode to RepaintOnFrame, but get compile errors. Either RepaintOnFrame not defined or when I declare it as MainLoopMode (copied the type MainLoopMode enum to my code, otherwise it did not work at all) I get should be type MainLoopMode but is type MainLoopMode (??).

I went over the source code an finally I hardcoded RepaintOnFrame in openglbackend.nim to get it working.

For my project. I want to display a few parameters originating from a thread (vars residing in the main module which the thread alters by means of nim channels ). It works like expected, but with RepaintOnFrame my exe uses 12 to 19% of the processor because it updates the screen constantly (60 fps+), while an update 2 to 5 times a second would suffice for monitoring the parameters.

Does fidget have another way ? Like a time event that can be set ? So the gui is drawn when something happens (like the default RepaintOnEvent) or when a certain amount of time (in my case 200 to 500 ms) passed. I don't finde anything in the samples, nor in the fidget source code.

I managed to lower the processor use somewhat (to 4 - 9%) by adding a sleep in drawMain(), but obvioulsy that is not the way to solve the issue since it makes the user interface sluggish.

@treeform
Copy link
Owner

Sorry, I don't really support the case where you want to run the loop at 10 or 2fps.

I think you are doing it correctly by going to the source and messing with the terming there.

Are you compiling with -d:release, just the app drawing at 60fps should be pretty fast as it does nothing.

@IvanScheers
Copy link
Author

Thank you for the reply. No indeed, I'm developing and quite new to Nim, so didn't compile with -d:release. If that makes the processor use go down drastically, I'm good. Otherwise I'll stick with RepaintOnEvent and add code to force a repaint after an elapsed time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants