Time for action—using a separate data receiver thread

In this example, we will design a new thread with the OpenThreads library and use it to read characters from the standard input. At the same time, the main process, that is, the OSG viewer and rendering backend will try retrieving the input characters and displaying them on the screen with the osgText library. The entire program can only quit normally when the data thread and main process are both completed.

  1. Include the necessary headers:
    #include <osg/Geode>
    #include <osgDB/ReadFile>
    #include <osgText/Text>
    #include <osgViewer/Viewer>
    #include <iostream>
    
  2. Declare our new DataReceiverThread class as being derived from OpenThreads::Thread. Two virtual methods should be implemented to ensure that ...

Get OpenSceneGraph 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.