Can I change framerate on the fly?

I draw a loaded 3D model and when the model get large/complex it drags down the application, as one would expect, as it renders each frame at the framerate (or as close as it can manage). I use PeasyCam for viewing the model, but for some processes could shut that off.

My question is, can I stop that rendering and show a static non-updating image when I need more performance, and then resume the rendering per-frame when that is needed, on the fly in my application? I.e., is there a "freeze frame" function? I'd like to offer the user the option to stop on-screen drawing and resume at will. I'm thinking I could create and then load a screenshot of itself, and revert to drawing when needed, but if there is a Processing command/technique to do this I'd prefer to go that way.

Suggestions?

Answers

  • The right way to do this would be to take a screenshot of itself and use that until you want to resume drawing.

  • Yes, thank you. That was what I mentioned above, just didn't want to code this if there was a built-in function that would do the same thing.

  • noLoop()?

  • Thanks Philho, I use the draw loop to do much more than screen rendering so for me noLoop() would mean a re-write.

    Fortunately I had my drawing code in separate routines, so with some re-arranging and tracing of orphaned variables I was able to switch off screen rendering on command from the user. Later I'll add a screenshot before switch-off.

    Good learning experience though as next time I'll be more conscious of the resources required to support OpenGL.

    Now I just need to sort out some foibles with the ControlP5 ControlFrame passing value back and forth (another post)......always another challenge just around the corner :)

  • frameRate()?

  • "stop that rendering and show a static non-updating image [...] is there a "freeze frame" function?""if there was a built-in function that would do the same thing"

    noLoop() is exactly what you look for, even if it means a bit of rewriting your code... :-)

    "I use the draw loop to do much more than screen rendering"
    Then it is time to move this code out to some functions.

    Alternative to noLoop(), if you still need a "pulse", regular call of your code: just add

    if (paused)
      return;
    

    after your computing, but before screen updating.

Sign In or Register to comment.