Update/render on demand

Is there an easy way to update and render the scene on demand, i.e. when something has changed?

Something like a change listener on the SG, maybe?

I can't check that myself since I've currently no access to the source code (see my other thread in trouble shooting) and search didn't come up with anything useful so far.

Thanks in advance,


I don't know why you would want to do that, but AFAIK nothing can stop you from forcing your game to update/render.

Well, it's not a game but a tool and I don't want it to update more often than necessary. (The computers that are used at work do make ugly noises on heavy load  :wink: )

The problem is that I'd like to have an easy way to trigger rendering whenever the scene is changed, i.e. I don't want to call canvas.makeDirtty() or canvas repaint() in every method that changes something but rather register something like a listener that does it on every change.

You’re trying to control your game loop. This stuff is built directly into jME via AbstractGame, BaseGame, BaseSimpleGame, SimpleGame, or whatever other “game” classes you’re extending. If you open the code of one of these, you can see where the update and render methods are placed in a while-loop to make them continually run until the game is finished.

Make your own implementation, like ThomasGame. Be sure to include methods to force updating and rendering. Then extend ThomasGame instead of SimpleGame and call forceUpdate() and forceRender() when you want to.

(P.S. I think this is a bad idea and am not advocating it, just showing you how to do it. I also think you’ll always need to run your update method. The only thing you could avoid doing here is the render method, I think. I’ve never tried it so I’m not totally sure)