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.
- Include the necessary headers:
#include <osg/Geode> #include <osgDB/ReadFile> #include <osgText/Text> #include <osgViewer/Viewer> #include <iostream>
- Declare our new
DataReceiverThreadclass as being derived from
OpenThreads::Thread. Two virtual methods should be implemented to ensure ...