Time for action—configuring the traits of a rendering window

We will create a fixed-size window to contain the rendering result of an OSG scene. The brief steps are: configure the traits of the rendering window, create a graphics context according to the traits, attach the graphics context to a camera, and finally set the camera as the main camera of the viewer.

  1. Include the necessary headers:
    #include <osg/GraphicsContext>
    #include <osgDB/ReadFile>
    #include <osgViewer/Viewer>
    
  2. Create a traits structure and set its attributes. The samples value here is set to enable the global multisampling functionality of the current window, but leave others to their defaults (no multisampling). This is different from the setNumMultiSamples() method of the osg::DisplaySettings ...

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.