MultiThreading and OpenGL

Started by
1 comment, last by _the_phantom_ 19 years ago
I am making a downloader with opengl graphics in c++, but in order to do this i need to create a second thread next to the main winmain thread. When i use the CreateThread(... function the applications seems to lock up/no more frames are drawn. Anybody got some experience with this and does any1 know where to initialise a thread. Greetz, Me
-->My Site<--
Advertisement
Why would you need multithreading in the first place? Wouldn't it be enough to poll for incoming data in the socket and continue rendering as usual in the meantime?

Make sure that you only call OpenGL from one of the threads and that all of the mutexes are getting unlocked properly.
Do some debugging to check how far into the code each thread reaches.

Multitheading is hard and my first guess is that you've got synchronization issues (a deadlock). Besides that I can't give you much advice without further details of the code and your communication mechanism.

edit: Maybe I didn't read your post. Does the application hang up simply because you create a test thread regardless of what the thread does?

Here's a simple example which should work:
DWORD WINAPI dummyThreadFunc(void *param) {  return 0; } HANDLE spawnAThread(void) { return CreateThread(NULL, 0, dummyThreadFunc, NULL, 0, NULL);}
Check if the application stops rendering after calling the spawn function.

[Edited by - doynax on March 27, 2005 1:18:13 PM]
Quote:Original post by doynax
Make sure that you only call OpenGL from one of the threads


and importantly, make sure the thread you draw from is the one the context is currently associated with (so if you created the context in the main thread drawing from another thread wont work until you free it from the main thread and reaquire it in the worker thread)

This topic is closed to new replies.

Advertisement