possible? irrlicht loop in a pthread

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
axel
Posts: 3
Joined: Fri Jun 05, 2009 2:42 pm
Location: Munich (Germany)

possible? irrlicht loop in a pthread

Post by axel »

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?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yup, Irrlicht isn't designed for multithreading. I believe that if you do want to play around with multithreading then the first thing to do is let Irrlicht run in the main thread and spawn extra threads for other tasks.
Image Image Image
axel
Posts: 3
Joined: Fri Jun 05, 2009 2:42 pm
Location: Munich (Germany)

Post by axel »

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.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

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.
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

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.
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).

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).
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

although you can add another rendering context and do texture streaming!
grafikrobot
Posts: 44
Joined: Wed Dec 26, 2007 11:42 pm

Post by grafikrobot »

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.
Post Reply