After the feedback on my last post i had to implement non-continuous rendering. It was easier then expected. Thanks to Romain and P.T. for subtly pointing out that the proposed “solution” for fake non-continuous rendering is pretty terrible. I will repent
Here’s how it works. The Graphics interface has three new methods:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
interface Graphics { /** * Sets whether to render continuously. In case rendering is performed non-continuously, the * following events will trigger a redraw: * * <ul> * <li>A call to {@link #requestRendering()}</li> * <li>Input events from the touch screen/mouse or keyboard</li> * <li>A {@link Runnable} is posted to the rendering thread via {@link Application#postRunnable(Runnable)}</li> * </ul> * * Life-cycle events will also be reported as usual, see {@link ApplicationListener}. * This method can be called from any thread. * * @param isContinuous whether the rendering should be continuous or not. */ public void setContinuousRendering(boolean isContinuous); /** * @return wheter rendering is continuous. */ public boolean isContinuousRendering(); /** * Requests a new frame to be rendered if the rendering mode is non-continuous. This method * can be called from any thread. */ public void requestRendering(); } |
Not sure this needs more explanation. Read the Javadocs
Caveat: This is currently a NOP in the Lwjgl backend, I added it to the Jogl backend already. It will take a bit before those are up to speed. I hope to finish that of today.
Try it out and let me know of any issues you have.