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.
createDevice inside a thread
Re: createDevice inside a thread
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.
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.
Re: createDevice inside a thread
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
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
Re: createDevice inside a thread
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
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