Hya,
**update**
Explaining a problem always helps to solve it :). Though not sure if this is correct, please tell me if not. What I’m doing now: thread B calls a function on thread A where I was loading an image. This gives me the EXC_BAD_ACCESS error. Now, I’m not loading the image anymore in the function in thread A which gets called by B, but instead I set a flag “should_update_image” in that function, then in the “update()” function in thread A I check if I should load the image again.
In pseudo code:
class ThreadA {
void update() {
}
void setNewImagePath(sPath) {
image_path = sPath;
thread_b->onNewImagePath(sPath);
}
string image_path
ThreadB thread_b;
};
class ThreadB {
// called from the main thread
void update() {
if(should_update) {
ofImage o;
o.loadImage(new_image_path);
}
}
// called from thread A
void onNewImagePath(string sNewPath) {
should_update = true;
new_image_path = sNewPath;
}
bool should_update;
string new_path;
};
** end update**
When working with multiple threads where a thread (A) notifies another thread (B) about a new image location which should be shown/loaded in thread B, I get an EXC_BAD_ACCESS in ofTexture, where it calls glGenTextures(…) (see screenshot).
When thinking about this, I was wondering what should be the way to work with multiple threads and openGL?
Kind regards,
Roxlu