1

I am replacing the OpenGL code of my C++ app with code that uses OpenSceneGraph.

The app is based on Qt and using Qt Threads.

The main thread is calling the viewer->frame() while other threads are loading data.

Those threads directly works whith my scene graph, adding node with addChild().

But sometimes this group->addChild call make my app crash. I Can see, in the stacktrace, the group's vector containing the children is resizing.

I guess that I'm not supposed to add childrens in one thread while another may be drawing it. Am I right ?

What is the best way to do it ? Using a update callback ? Locking the main thread ?

Krag
  • 79
  • 1
  • 9
  • 1
    It's even worse: you're not allowed to use any classes (whether in OSG or Qt) from multiple threads without locking unless they're documented as thread-safe. There are many possible approaches to multithreaded use of OSG. The question is likely too broad without some clarification and code examples. – Kuba hasn't forgotten Monica May 02 '16 at 18:15
  • That is the answer I needed, thanks. – Krag May 03 '16 at 07:44

0 Answers0