Does ofImage.load() interrupt ofApp::draw() and ofApp::update() routine loops?

#1

I’m making a custom graphical loading progress bar (progress indicator calculated in update() and drawn in draw()…),
but anyhow I try, anything in draw() and update() during loading a 2d array of images in a for loop (let’s say 10x10 images in my case) gets stuck and doesn’t animate anymore until the for loop process is done.
I was hoping to track the process of the loop to make it drawn on the canvas, but the fact that update() and draw() are not responsive during that time prevents me to do it.
Is this hard-coded into OF as such a security measure that until the process of loading an image the update() and draw() loops have to stay unresponsive?

#2

Hello,
By default, the execution of an App is sequential,
the only thread in use will go through every computation you asked, one by one.
If the for loop takes longer than the frame update, you will see a ‘lag’.
Fortunately, there is an addon for using multiple threads.
You can read this:
https://openframeworks.cc/ofBook/chapters/threads.html
and also find thread examples in openFrameworks.
You will see there is a few things to be careful about, but that is really expanding your workflow.

1 Like
#3

Thanks much, I’ll go check it and utilize threads perhaps…

#4

if you want to load images in a thread the ofxThreadedImageLoader addon does it for you without need to code it manually

2 Likes