Tried separate render thread: isWindowActive returns false?!
Posted: Tue Feb 26, 2008 9:25 pm
i came up with the idea to have irrlicht rendering and physics in separate threads. I use irrlicht for displaying custom physical simulations. As the physics solver is heavy, it always hangs when I integrated it into the main loop rendering.
My attempt to seperate it into thread (code below) failed with mysterious effect: the window is not painted when the main loop is in a separate thread.
In the code below, this block is never ender, as it seem that isWindowActive() is not returning true (for a mysterious reason?):
My attempt to seperate it into thread (code below) failed with mysterious effect: the window is not painted when the main loop is in a separate thread.
In the code below, this block is never ender, as it seem that isWindowActive() is not returning true (for a mysterious reason?):
Code: Select all
if (engine.device->isWindowActive())
{
std::cout << "Painting window..." << std::endl;
The code uses boost threads (dont are about the custom class ..engine etc - its just wrappers to the main irrlicht classes).
<snip>
struct thread_irrlicht_render
{
public:
irrlicht_engine_startup &engine;
irrlicht_event_reactor &reactor;
irrlicht_node_factory &game_object_create;
thread_irrlicht_render(
irrlicht_engine_startup &engine_,
irrlicht_event_reactor &reactor_,
irrlicht_node_factory &game_object_create_
) :
engine(engine_),
reactor( reactor_ ),
game_object_create( game_object_create_ )
{
}
void operator()()
{
std::cout << "Render thread.." << std::endl;
while( engine.device->run() )
{
std::cout << "Device run..." << engine.device << std::endl;
if (engine.device->isWindowActive())
{
std::cout << "Painting window..." << std::endl;
}
}
}
};
int main()
{
<snip>
thread_irrlicht_render thread_render(engine, reactor, game_object_create );
boost::thread thread_render_attached(thread_render);
thread_render_attached.join();
<snip>
}