OpenFrameworks ofThread Help ! !

I’m very new to OpenFrameworks C++ programming and i try to put an ofThread in my app. I try to put a thread on my videoGrabber

Regarding the example of OpenFrameworks Website i should install my thread like this :

OpenFrameworks example

Declaration in a .h file:
class MyThread : public ofThread {

// the thread function
void MyThread::threadedFunction() {

// start

while(isThreadRunning()) {

if(cam.isFrameNew()) {

// load the image

// done

ofVideoGrabber cam; // the cam
ofImage image;

A problem of compilation appeared on the line :

void MyThread::threadedFunction() {

error: extra qualification ‘MyThread::’ on member ‘threadedFunction’ [-fpermissive]

Can i have some help to understand this error ? I tried to search anything about it, but i really dont understand. C++ is very new to me.

If you are defining the function inside in the .h you dont need the scope qualifier

So remove the MyThread:: and just put void threadedFunction()

Thank you very much, it works !

Another question, how can i pass the testapp into an argument in the thread ? !

Thank you for your reply ! :slight_smile:

You would have to create an instance variable in your class MyThread. And then assign testapp to that instance variable.


I’m sorry for digging up an old topic, but I’m dealing with figuring out ofThread as well and I’m not sure if it would be useful to start a new topic for this.

My thread needs some variables from video and audio objects that are playing in testApp and I was interested if the above is the best way to use variables from testApp in the MyThread class? Wouldn’t that create some sort of an endless loop if MyThread is called from testApp?

You’ll have to post your code. I’m not sure what you mean.