Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Graphics Preferences and Configurations

Goals

The Open Inventor graphics configuration management classes provide a platform-independent mechanism for chosing the best combination of graphics parameters and features available on your graphics hardware. It is no longer necessary to check all the pixel formats (on Win32) or all the visuals (on Unix) to find the best one. Of course, what is “best” depends on the graphics hardware capabilities of your system and on the set of graphic preferences you specify.

You can specify many different criteria: double/single buffer, raw stereo, OpenGL acceleration, overlays, Z-buffer depth size, RGBA/indexed colors and size, accumulation buffer and size, stencil buffer and size, etc. Each criterion may be required, forbidden, or preferred. The preferred criterion can be weighted with values ranging from 1 to the largest integer. The sum of all weights determines if one graphics configuration is better than another.

Description

The graphics configuration management classes define three kinds of objects:

  • preferences: SoGraphicConfigTemplate classes,
  • devices: SoGraphicDevice classes,
  • configurations: SoGraphicConfig classes. You define a graphics configuration template containing your graphics preferences and pass it to the graphics device. The graphics device stores the available graphic configurations and sorts them from best to worst according the given configuration template.

All the viewers based on SoXtGLWidget can use the graphics configuration template: the inherited method named setGraphicTemplate() can be used to specify the OpenGL graphic preferences.

In a viewer derived from SoXtGLWidget, a graphics device is internally used to find the best graphic config if a template is given via the setGraphicConfigTemplate() method. If none is found (because the template is too restrictive), then the template is ignored. The default values of a OpenGL graphics template are the same as the ones that the SoXtGLWidget heuristic looks for when building an OpenGL widget:

  • Double buffer is REQUIRED.
  • Stereo buffer is FORBIDDEN.
  • Accelerated OpenGL is REQUIRED.
  • Depth buffer is REQUIRED; its size is greater than 0.
  • Non-indexed color is REQUIRED; its R/G/B/A sizes are greater than 0.
  • Indexed color is FORBIDDEN.
  • Accumulation buffer is PREFERRED; its R/G/B/A sizes are greater than 0.
  • Stencil buffer is PREFERRED; its size is greater than 0.
  • Overlays are PREFERRED.
  • Full-scene antialiasing is FORBIDDEN. Every preference can be specified as an integer (1, by default); the sum of all preference weights determines if a particular graphics configuration is better than another one.

"Important" but not both.However, if setGraphicConfigTemplate***has* been called, then when **setPixelFormat is called, several PREFERRED template preferences are changed either to REQUIRED or to FORBIDDEN to ensure that the new pixel format is one of the best ones.

If setGraphicConfigTemplate has been called, several methods, including setDoubleBuffer and setStereo, will automatically modify the current template to indicate that the new state is REQUIRED.

setRGBAColor sets the integer color buffer depth (0-32 bits). For floating point rendering, use setFloatRGBAColor.

C++ : The following example shows how to get pixel format or visual information directly from the graphic configuration.

/WinGLGraphicConfig_object_stores_pixel_format/visual_information_data Example : SoXt/WinGLGraphicConfig object stores pixel format/visual information data

C++ :

SoGLGraphicConfigTemplate gTemplate;
...
SoGLGraphicDevice *dev = ...;
SoGLGraphicConfig* gc = ( SoGLGraphicConfig* )dev.getBestGraphicConfig( gTemplate );
if ( gc != NULL )
{
#ifdef WIN32
int pixelFormat = ( ( SoWinGLGraphicConfig* )gc )->getPixelFormat();
#else
XVisualInfo* vis = ( ( SoXtGLGraphicConfig* )gc )->getXVisualInfo();
#endif
}

C# : The following example shows how to get pixel format or visual information directly from the graphic configuration.

/visual_information_data Example : SoWinGLGraphicConfig object stores pixel format/visual information data

C# :

SoGLGraphicConfigTemplate gTemplate;
...
SoGLGraphicDevice dev = ...;
SoGLGraphicConfig gc = ( SoGLGraphicConfig )dev.GetBestGraphicConfig( gTemplate );
if ( gc != null )
{
int pixelFormat = ( ( SoWinGLGraphicConfig )gc ).GetPixelFormat();
}