I tried to let the main loop of the simple tutorial example run in a pthread,
all pointers that are needed for the loop are passed to the thread, but as soon as the scene is not empty the drawAll() function crashes when the first object should be drawn. The crash happens deep down in the OpenGL code...
Is this a known problem?
possible? irrlicht loop in a pthread
Ok - thank you very much!
Is there any way to understand the problem? I mean in my simple play-example no other thread is running (exeption: the main thread, which is waiting for an input)-
I also saw a forum-thread in here
"http://irrlicht.sourceforge.net/phpBB2/ ... ht=pthread"
which might solve the problem, but I actually did not really understand the problem from that.
Is there any way to understand the problem? I mean in my simple play-example no other thread is running (exeption: the main thread, which is waiting for an input)-
I also saw a forum-thread in here
"http://irrlicht.sourceforge.net/phpBB2/ ... ht=pthread"
which might solve the problem, but I actually did not really understand the problem from that.
Same applies to DX9 as well...unless you create the DX device as multithreaded, which can hurt performance (each DX API call takes a critical section).hybrid wrote:Actually, the problem here is inherent to OpenGL. You must not call OpenGL calls from a thread different to the one that created the OpenGL context. That's why we promote to use threads for things like I/O or physics.
OpenMP could be useful, but the poster who said they had performance gains hasn't come back with the OpenMP patch for us to try. I've used OpenMP before but I don't currently have the time to do it myself (I'm working on a PVS solution).
Irrlicht Demos: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=6&t=45781
-
- Posts: 44
- Joined: Wed Dec 26, 2007 11:42 pm
And if you are willing to do some extra work, and the OpenGL system API you are using allows it, you can switch the OpenGL rendering context from one thread to another. It's what I do for the iPhone port since the iPhone OS has the same single-thread "problem" in that the event system wants to run in the main thread only.