Hi,
I’m coding a project in C++ right now and I got a few
problems/Questions about Threads under SDL…
First, a Paste :
main()
{
…
updateTHREAD = SDL_CreateThread(visual.refresh_thread(), NULL);
cout << “Thread Initialized…” << endl;
…
}
/** This is the Refresh Thread */
int Viewport::refresh_thread()
{
while(refresh_switch)
{
if(needRefresh() == 1) {
Viewport::refresh();
cout << "Refresh Switch : " << refresh_switch << endl;
}
SDL_Delay(20);
}
return(0);
}
If you look at my paste in the main() function… The Thread Does start but it
doesn’t continue to run my main function … it keep running the While loop in
my thread without caring about what’s next in my main() function (that mean I
never see “Thread Initialized on the Screen”… Any idea why ? I do put a delay
of 20 ms in my while loop…
And now for the Questions :)
Wtf is a Mutex :) ok I got the prototypes of the threads function
(it’s pretty strait forward…) except for this mutex thing… Is there a place
where I could find more Info about Mutex and their use ?
A last question : is this good to create a Thread like I did that look whenever
a viewport need to be refreshed and if yes refresh it calling the
viewport.refresh() ?
Thanks a lot
Jeremie Plante (working on the RPGen Project …
homepage almost ready !)