Noloop() in openframeworks?

Processing has the noLoop() function.It can stop the program.Is there any similar function in OF?

call std::exit(1) after you are done with your code and the app should exit.

Hi there!

Sorry, but nope! :slight_smile:

To emulate that behaviour, you’ll have to use a boolean variable to control your drawing, like a toggle.

Have you tried ofExit() ?

Just to be clear for future reference, any exit calling is not the same as noLoop().

ofExit calls ofApp::exit() and quits/stops/exits the app. Which is what happens when you press the Escape key and it’s a way to do some clean up. Processing as something similar.

noLoop() is something that holds the main state machine. Nothing else will be drawn to the screen but you won’t exit the app. You will then have to use an event to restart (redraw()) or enable loop again.

If you want to do something and quit, use ofExit() and do your cleanup on ofApp::exit().

If you want to draw something just when needed, you need some booleans and to disable the autobackground. Or better yet, an FBO.

yes,but it will exit the app directly~

Thanks hubris:)I have think about Fbo and ofSetBackgroundAuto,but they are not very easy understand to some beginner.I am writing some tutorials about OF~~

Here is the code of PApplet.java, which includes noLoop mechanism.

“looping” and “redraw” boolean does the job. Very simple.

Hi, It may be co-routine, boost function.

Here is co-routine and openFrameworks example. (sorry for Japaneses)
i’ve not tried this yet, i hope it will be benefit to you.

Cheers,

Thanks,yuma_T :slight_smile: I will check it later~~~~

How about running everything in setup? But again, that’s not exactly a noloop.

It’ll depend on what you are doing. If you wish to draw something to the window, sorry, but nope. For something to be drawn, it needs to be called within the draw event.