What is it that doesn't work? Compiler error? Link error? Runtime error?

Regards,
/Marcus

Markus Straub wrote:

Hi all,

I would like to know, if it is possible, to create an osg::Thread from a c++ class-member-function. My guess is, that the osg::Thread is not designed for that purpose, it relies on pthreads, doesn't it?

I created a simple program which uses threads in C:

//-------------<begin TestFader.c>------------------
#include <iostream.h>
#include <OpenSG/OSGGLUTWindow.h>

osg::Thread* tfadeOut;
void fadeOut(void *ptr){
   cout << "it works!\n";
}

int startThread(){
   // declaration & start of the thread
tfadeOut = dynamic_cast<osg::Thread *>(osg::ThreadManager::the()->getThread("fOut"));
   tfadeOut->runFunction(fadeOut, 0, NULL);
   return 0;
}

int main(int argc, char **argv){
   osg::osgInit(argc,argv);
   startThread();
   osg::Thread::join(tfadeOut);
   return 0;
}
//-------------<end TestFader.c>------------------

This code works perfectly and prints out "it works". Nevertheless my attempts to put the same code into a class won't bring any positive results. My C++ code looks like this:

//-------------<begin TestFader.cpp>------------------
#include <iostream.h>
#include <OpenSG/OSGGLUTWindow.h>


class TestFader{
   public:
       osg::Thread* tfadeOut;

       void fadeOut(void *ptr){
           cout << "it works!\n";
       }
          int startThread(){
           // declaration & start of the thread
tfadeOut = dynamic_cast<osg::Thread *>(osg::ThreadManager::the()->getThread("fOut"));
           tfadeOut->runFunction(TestFader::fadeOut, 0, NULL);
           cout << "it works!\n";
           return 0;
       }
};

int main(int argc, char **argv){
   TestFader *f = new TestFader();
   osg::osgInit(argc,argv);
   f->startThread();
   osg::Thread::join(f->tfadeOut);
   return 0;
}
//-------------<end TestFader.cpp>------------------

So has anybody got a hint for me on how to create threads from c++ class-member-functions with OSG-Threads? That would really be appreciated.

Thanks, Markus



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to