createDevice inside a thread

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
allx_90
Posts: 7
Joined: Sun Jan 30, 2011 8:07 am

createDevice inside a thread

Post by allx_90 »

So my problem is the following: i am creating a new thread. Inside that thread i try to create a nulldevice to get desktop resolution then to create another device with those values then run a loop to draw things. The problem is that the application closes itself at the first createDevice with the following message in console: 'The thread 0x5ce4 has exited with code 0 (0x0)'
Anyone knows something about this? or if it is possible to create a thread that will create the device and keep it running/drawing instead of doing that in the main method?
Thanks in advance.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: createDevice inside a thread

Post by mongoose7 »

You need to read up on creating a worker thread. You need to have a way of "parking" a thread when it has nothing to do. Or of coordinating two threads.

I think you will always have problems. Multithreading an application requires a lot of discipline. You are trying to do it for a specific purpose I know, but that purpose will seem less important as the problems grow. My advice - stick to the one thread.
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: createDevice inside a thread

Post by thanhle »

I'm not sure why you create a null device.
But you can create a rendering thread.

Inside the thread you create the device, drivers, smgr etc. and the rendering loop. after the loop you also call device->closeDevice(); device.drop(); etc.

There is the DriverMultithreaded in the device parameter setting. I didn't use that option. Since I don't know what it does :). Instead I manage crossthread with signal/event.

Regards
Thanh
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: createDevice inside a thread

Post by Granyte »

The DriverMultithreaded option flag dx to know if it need to expect getting called from multiple threads

how ever this has no effect on irrlicht it self so even with a multithreaded driver the irrlicht function them selves will collide as they are not thread safe

also there are some irrlicht function that can be called from multiple threads that do not collide how ever they are driver specific so what you test on dx9 will not work on dx11 or OGL and the same goes for the other way around

also I specified DX because as far as I know this parameter has no effect on OGL (some one correct me if it does)

So my advice is if you can cram everything in a single thread and have good performance stay on a single thread.

if you cannot keep irrlicht and the rendering on the main thread and use others to do your game logic that you can then split as you see fit my personal project can take advantage of up to 8 cores probably more but I have yet to test on any hardware that has more then 8
Post Reply