Multiple Irrlicht Devices in different threads. Thread safe?

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
Locien
Posts: 25
Joined: Wed Jul 10, 2013 2:43 am

Multiple Irrlicht Devices in different threads. Thread safe?

Post by Locien »

Hello. So I have a question regarding thread safety and Irrlicht. I'm working on a block style game, similar to Minecraft but not really in some ways. I have a blocky terrain which I generate as meshes and meta data in one or more different threads than the renderer thread for performance reasons. It's working really way with this approach but I've hit a little problem now. I'm using 3d models that I load into the game and batch them into large static meshes for trees and other things in the environment. The problem with this is that I can only load 3d models in the main thread since that's where the Irrlicht device and scene manager is, and this is causing some stuttering because the meshes are big and take time to write. Ideally I would like to create null renderer devices and use those to load 3d models and batch meshes in the other threads, but is that thread safe? Also is it safe to create multiple devices and drop them without affecting the main one? I hope someone who is Irrlicht savvy and know the inner workings can help me out with this, thanks :D

Here's the current state of my game: http://i.imgur.com/KnwTucG.png
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: Multiple Irrlicht Devices in different threads. Thread s

Post by devsh »

Nope, some mesh renderers have static variables... not very object oriented... also irrlicht itself has such variables so its pretty much impossible to create 2 irrlichts, even in different threads.
Locien
Posts: 25
Joined: Wed Jul 10, 2013 2:43 am

Re: Multiple Irrlicht Devices in different threads. Thread s

Post by Locien »

Well, that certainly sucks... Do you know if it's possible to create a static method to load 3d models and return a mesh in the scene manager that doesn't require a device? Worst case scenario I'll have to preload the meshes and send them to different threads or send them by request. Certainly not the way I want to do it though :/
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Multiple Irrlicht Devices in different threads. Thread s

Post by mongoose7 »

Build only the mesh buffers in another thread. Then let the rendering thread know they are available. The main thread can then add the mesh buffer to a scene node.
Post Reply