I'm working on a Cinder/Cairo app (a puzzle generator) which will be doing some CPU intensive stuff in another thread, and will only need to refresh the display at specific times, using the puzzle-generation thread to request refreshes when puzzles are complete.
Most Cinder projects have a main loop which is constantly refreshing the screen. I'm calling setFrameRate(0) in my setup, to turn this off, as I'd like to save CPU for making puzzles. I'd like to be able to request redraws dynamically.
Is there a way to do this? Calling draw() manually doesn't seem to work properly, and the app class doesn't seem to have an obvious refresh mechanism.
Instead of disabling your app looping, try writing your own method to update your graphics and call that selectively from draw(). Then in draw(), all you otherwise need to do is not clear the current buffer. That way you'll still be able to perform other animations for things like user interface or a loading bar while calculating puzzles in the background.
I have the same question (except using regular OpenGL drawing, not Cairo)... Four years later, is this work-around still the only/best approach to only redraw when desired (e.g. on UI interaction)? Or is there now a way to do this using signals -- requesting a redraw/repaint to later be drawn in the usual way? Thanks!
Leave a comment on totalgee's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic