Hi,
sorry maybe it's the alcohol
I try it this way:
With the WinApi it's like this
You have a class called MyClass...
class MyClass
{
public:
void drawGraphics();
};
This class has the method drawGraphics()...
You can not run this method in a thread. A thread needs to be a real function.
If you want to use this method as a thread method, there is this workaround:
You build a (global) function that takes a pointer of an object of your class(MyClass)
Like:
void wrapperDrawGraphics(MyClass* c )
{
c->drawGraphics()
}
When creating a thread in WinApi style it would look like this:
MyClass myClassObject;
DWORD dwThreadId;
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)wrapperDrawGraphics, myClassObject, 0, &dwThreadId);
I do not know if SFML is handling it different, but maybe creating this kind of helper function, that takes a pointer to your class Object and running this function in a thread would help?!!
in SFML it would look like this i think:
class MyClass
{
public:
void drawGraphics();
};
void wrapperDrawGraphics(void* c)
{
MyClass* myClassObj = static_cast<MyClass*>(c); //cast back to MyClass
myClassObj->drawGraphics();
}
//somewhere in main maybe...
MyClass myClassObject;
//First the function to be run in a thread, then the param passed to this function...
sf::Thread Thread(&wrapperDrawGraphics, &myClassObject);
Thread.Launch();
This would make the
wrapperDrawGraphics function run in a thread. And cuz this function calls the drawGraphics-Method of the referenced MyClass object, the Method is running in a thread.
Hope this helps somehow.
Regards,
Wafthrudnir