Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoWinGLWidget Class Referenceabstract

VSG extension Component for OpenGL rendering. More...

#include <Inventor/Win/SoWinGLWidget.h>

+ Inheritance diagram for SoWinGLWidget:

Public Types

enum  FloatColorBufferSize {
  FLOAT_16_COLOR_BUFFER = SoGuiGLWidget::FLOAT_16_COLOR_BUFFER ,
  FLOAT_32_COLOR_BUFFER = SoGuiGLWidget::FLOAT_32_COLOR_BUFFER
}
 FloatColorBufferSize. More...
 
- Public Types inherited from SoWinComponent
typedef void SoWinComponentCB(void *userData, SoWinComponent *comp)
 

Public Member Functions

virtual Window getNormalWindow ()
 Gets the normal GL window, which is needed as an argument to SbGlContextHelper::makeCurrent() when drawing in the normal planes.
 
GLXContext getNormalContext ()
 Gets the normal context, which is needed as an argument to SbGlContextHelper::makeCurrent() when drawing in the normal planes.
 
virtual SoGLContextgetNormalSoContext ()
 
Hdc getNormalDC () const
 Returns the device context (which is needed for SbGlContextHelper::makeCurrent).
 
void setStealFocus (SbBool onOrOff)
 By default the GLWidget "steals" focus whenever the cursor moves over it.
 
SoWidget getNormalWidget () const
 Gets the normal window handle, which is needed as an argument to SbGlContextHelper::makeCurrent() when drawing in the normal planes.
 
virtual void setNormalVisual (XVisualInfo *vis)
 Specifies the exact pixel format descriptor for the normal window.
 
XVisualInfo * getNormalVisual ()
 Returns the pixel format descriptor for the normal window.
 
virtual void setPixelFormat (int format)
 Sets the current pixel format.
 
int getPixelFormat ()
 Returns the current pixel format.
 
void setAntialiasing (const float quality, const SoSceneManager::AntialiasingMode mode=SoSceneManager::AUTO)
 Enable (or disable) antialiasing with specified quality and mode.
 
void setAntialiasing (SoAntialiasingParameters *advancedParameters)
 Enable (or disable) antialiasing with specific parameters.
 
float getAntialiasingQuality () const
 Returns the antialiasing quality set using the setAntialiasing(float,AntialiasingMode) method.
 
SoSceneManager::AntialiasingMode getAntialiasingMode () const
 Returns the antialiasing mode set using the setAntialiasing(float,AntialiasingMode) method.
 
SoAntialiasingParametersgetAntialiasingParameters () const
 Returns the antialiasing parameters set using the setAntialiasing(SoAntialiasingParameters*) method.
 
void setDoubleBuffer (SbBool onOrOff)
 Routine that dynamically changes between single and double buffering.
 
SbBool isDoubleBuffer ()
 Returns whether double buffering is on or off.
 
void setBorder (SbBool onOrOff)
 Included for portability only.
 
int getBorderSize ()
 Included for portability only.
 
SbBool isBorder () const
 Included for portability only.
 
void setDrawToFrontBufferEnable (SbBool enableFlag)
 Sets drawing to the front buffer.
 
SbBool isDrawToFrontBufferEnable () const
 Returns whether drawing to the front buffer is enabled.
 
void setCursor (Cursor newCursor)
 Sets the current cursor.
 
Cursor getCursor ()
 Returns the current cursor.
 
virtual SbBool bindNormalContext ()
 Makes the normal rendering context the current context.
 
virtual SbBool unbindNormalContext ()
 unbind the current context (previously bind with bindNormalContext );
 
virtual SbBool swapNormalBuffers ()
 Swaps the normal front and back buffers.
 
SoGLGraphicConfigTemplategetGraphicConfigTemplate ()
 Gets the current graphics configuration template.
 
void setGraphicConfigTemplate (SoGLGraphicConfigTemplate *gTemplate)
 Sets a new graphics configuration template.
 
virtual void setFloatingColorBuffer (SbBool enable, FloatColorBufferSize size=FLOAT_16_COLOR_BUFFER)
 Enables/disables floating point rendering using 16- or 32-bit components.
 
virtual void getFloatingColorBuffer (SbBool &enable, FloatColorBufferSize &size)
 Returns TRUE if floating point rendering is used and its precision.
 
bool saveSnapshot (const SbString &filename, bool overwrite=true)
 Save a snapshot of the current image displayed in the viewer.
 
- Public Member Functions inherited from SoWinComponent
virtual void show ()
 This shows the component.
 
virtual void hide ()
 This hides the component.
 
SbBool isVisible ()
 Returns TRUE if this component is mapped onto the screen.
 
SoWidget getWidget () const
 This returns the base window handle for this component.
 
SbBool isTopLevelShell () const
 Returns TRUE if this component is a top level shell component (has its own window).
 
SoWidget getShellWidget () const
 Returns the shell window handle (NULL if the shell hasn't been created by this component).
 
SoWidget getParentWidget () const
 Returns the parent window handle, be it a shell or not.
 
void setSize (const SbVec2s &size)
 Convenience routine on the window handle.
 
SbVec2s getSize ()
 Convenience routine on the window handle.
 
SbBool setFullScreen (const SbBool enable)
 Switches the viewer into (or out of) fullscreen mode.
 
SbBool isFullScreen () const
 Queries if the viewer is in fullscreen mode.
 
void setFullScreenEnable (const SbBool enable)
 Enables/disables fullscreen mode.
 
SbBool isFullScreenEnable (void) const
 Queries if it is possible to put the viewer in fullscreen mode.
 
UINT * getDisplay ()
 Included for portability only.
 
SoNONUNICODE void setTitle (const char *newTitle)
 Sets window title.
 
void setTitle (const SbString &newTitle)
 Sets window title.
 
SbString getTitle () const
 Gets window title.
 
SoNONUNICODE void setIconTitle (const char *newIconTitle)
 Included for portability only.
 
void setIconTitle (const SbString &newIconTitle)
 Included for portability only.
 
SbString getIconTitle () const
 Included for portability only.
 
void setWindowCloseCallback (SoWinComponentCB *func, void *data=NULL)
 Sets which callback to call when the user closes this component (double click in the upper left corner) - by default hide() is called on this component, unless a callback is specified.
 
SbString getWidgetName () const
 Returns the window handle name.
 
SbString getClassName () const
 Returns the class name.
 
virtual ~SoWinComponent ()
 Destructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from SoWinComponent
SoDEPRECATED static SoNONUNICODE void displayHelp (const char *filename, UINT contextID)
 Static method to display the specified topic of the specified help file.
 
static SoDEPRECATED void displayHelp (const SbString &filename, UINT contextID)
 Static method to display the specified topic of the specified help file.
 
static SoWinComponentgetComponent (SoWidget w)
 Returns the SoWinComponent for this window handle.
 
- Public Attributes inherited from SoWinComponent
SbString helpFileName
 Name of help file to open when the viewer Help button is pressed.
 
UINT helpContextID
 The context ID of the help topic to open when the viewer Help button is pressed.
 
SbString helpContextString
 The TopicID of the help topic to open when the viewer Help button is pressed.
 

Detailed Description

VSG extension Component for OpenGL rendering.

This abstract base class provides a C++ wrapper around an OpenGL drawing window. It allows OpenGL rendering to be performed within a Windows window and is used by the SoWinRenderArea. SoWinGLWidget uses a parent window with two separate OpenGL windows (one for single buffering and one for double buffering), with routines to return the appropriate windows.

Subclasses only need to redefine the redraw() routine for rendering and processEvent() routine if they are interested in receiving Windows messages.

SEE ALSO

SoWinComponent, SoWinRenderArea

Definition at line 79 of file SoWinGLWidget.h.

Member Enumeration Documentation

◆ FloatColorBufferSize

FloatColorBufferSize.

Enumerator
FLOAT_16_COLOR_BUFFER 

16-bit rendering per component.

FLOAT_32_COLOR_BUFFER 

32-bit rendering per component.

Definition at line 84 of file SoWinGLWidget.h.

Member Function Documentation

◆ bindNormalContext()

virtual SbBool SoWinGLWidget::bindNormalContext ( )
virtual

Makes the normal rendering context the current context.

Equivalent to makeNormalCurrent() call.

◆ getAntialiasingMode()

SoSceneManager::AntialiasingMode SoWinGLWidget::getAntialiasingMode ( ) const

Returns the antialiasing mode set using the setAntialiasing(float,AntialiasingMode) method.

Returns AUTO by default. Parameters set using the setAntialiasing(SoAntialiasingParameters*) method may change the antialiasing mode, but do not affect the value returned by this method. Therefore this method does not necessarily return the current actual antialiasing mode.

◆ getAntialiasingParameters()

SoAntialiasingParameters * SoWinGLWidget::getAntialiasingParameters ( ) const

Returns the antialiasing parameters set using the setAntialiasing(SoAntialiasingParameters*) method.

Returns null by default. A quality value set using the setAntialiasing(float,AntialiasingMode) method may modify internal parameters, but does not affect the value returned by this method. Therefore this method does not necessarily return the current actual antialiasing parameters.

◆ getAntialiasingQuality()

float SoWinGLWidget::getAntialiasingQuality ( ) const

Returns the antialiasing quality set using the setAntialiasing(float,AntialiasingMode) method.

Returns 0.0 by default. Parameters set using the setAntialiasing(SoAntialiasingParameters*) method override internal parameters, but do not affect the value returned by this method. Therefore this method does not necessarily return the current actual antialiasing quality.

◆ getBorderSize()

int SoWinGLWidget::getBorderSize ( )
inline

Included for portability only.

Definition at line 228 of file SoWinGLWidget.h.

◆ getCursor()

Cursor SoWinGLWidget::getCursor ( )

Returns the current cursor.

◆ getFloatingColorBuffer()

virtual void SoWinGLWidget::getFloatingColorBuffer ( SbBool enable,
FloatColorBufferSize size 
)
virtual

Returns TRUE if floating point rendering is used and its precision.

Reimplemented in SoWinRenderArea.

◆ getGraphicConfigTemplate()

SoGLGraphicConfigTemplate * SoWinGLWidget::getGraphicConfigTemplate ( )

Gets the current graphics configuration template.

◆ getNormalContext()

GLXContext SoWinGLWidget::getNormalContext ( )
inline

Gets the normal context, which is needed as an argument to SbGlContextHelper::makeCurrent() when drawing in the normal planes.

Note: This should not be cached by users because it will change as single/double buffering changes.

Definition at line 114 of file SoWinGLWidget.h.

◆ getNormalDC()

Hdc SoWinGLWidget::getNormalDC ( ) const

Returns the device context (which is needed for SbGlContextHelper::makeCurrent).

◆ getNormalSoContext()

virtual SoGLContext * SoWinGLWidget::getNormalSoContext ( )
inlinevirtual

Definition at line 116 of file SoWinGLWidget.h.

◆ getNormalVisual()

XVisualInfo * SoWinGLWidget::getNormalVisual ( )

Returns the pixel format descriptor for the normal window.

◆ getNormalWidget()

SoWidget SoWinGLWidget::getNormalWidget ( ) const

Gets the normal window handle, which is needed as an argument to SbGlContextHelper::makeCurrent() when drawing in the normal planes.

Note: This should not be cached by users because it will change as single/double buffering changes.

◆ getNormalWindow()

virtual Window SoWinGLWidget::getNormalWindow ( )
virtual

Gets the normal GL window, which is needed as an argument to SbGlContextHelper::makeCurrent() when drawing in the normal planes.

Note: This should not be cached by users because it will change as single/double buffering changes.

◆ getPixelFormat()

int SoWinGLWidget::getPixelFormat ( )

Returns the current pixel format.

This method allow an application to query a pixel format that has extended attributes that can't be specified in a PFD struct.

◆ isBorder()

SbBool SoWinGLWidget::isBorder ( ) const
inline

Included for portability only.

Definition at line 233 of file SoWinGLWidget.h.

◆ isDoubleBuffer()

SbBool SoWinGLWidget::isDoubleBuffer ( )
inline

Returns whether double buffering is on or off.

Definition at line 218 of file SoWinGLWidget.h.

◆ isDrawToFrontBufferEnable()

SbBool SoWinGLWidget::isDrawToFrontBufferEnable ( ) const
inline

Returns whether drawing to the front buffer is enabled.

Definition at line 244 of file SoWinGLWidget.h.

◆ saveSnapshot()

bool SoWinGLWidget::saveSnapshot ( const SbString filename,
bool  overwrite = true 
)

Save a snapshot of the current image displayed in the viewer.

The image is read back from the OpenGL framebuffer and will be the same size as the viewer's drawing window. Returns true if successful.

Notes:

  • Depending on the operating system and graphics hardware, it is possible that the image could be incomplete if the viewer window is overlapped by other windows.
  • The supported image file formats are: BMP (Windows only), JPEG, PNG and TIFF.
    The image file format to write is determined by the extension of the specified filename, e.g. ".png" for PNG format.
  • For BMP and JPEG formats an RGB image is written.
  • For PNG and TIFF formats, an RGBA (RGB plus alpha channel) image is always written.
  • Writing an RGBA image means the image background is transparent. Actually an RGBA snapshot can not be saved without transparency. To get the displayed image without transparency, use the BMP or the JPEG format.
  • To generate an image with a different size or different options, use SoOffscreenRenderArea instead.
  • The specified filename must include a directory or nothing will be written. Can be simply "./filename.png", but just "filename.png" won't work.
Parameters
filenameFully qualified file path for the snapshot file.
The specified filename must end with one of the extensions supported by SoJPEGImageRW (jpg, jpeg, ...), SoPNGImageRW (png), SoBMPImageRW (bmp), or SoTIFFImageRW (tif, ...).
overwriteIf true, overwrite any existing file with the same name (default is true).

◆ setAntialiasing() [1/2]

void SoWinGLWidget::setAntialiasing ( const float  quality,
const SoSceneManager::AntialiasingMode  mode = SoSceneManager::AUTO 
)

Enable (or disable) antialiasing with specified quality and mode.

Specific antialiasing parameters will be set automatically based on the quality value. Note that the quality and mode settings are overridden if specific antialiasing parameters are subsequently set using the setAntialiasing(SoAntialiasingParameters*) method.

The default mode is AUTO but this may be overridden by setting the environment variable OIV_ANTIALIASING_DEFAULT_MODE (see SoPreferences).

Parameters
qualityThe quality is a factor in the range [0.0,1.0].
Use the value 0.0 to turn off antialiasing. 0.5 is a typical value.
modeThe antialiasing algorithm. Default is AUTO, which means use the best for the current hardware.
Use the value NO_ANTIALIASING to turn off antialiasing.

◆ setAntialiasing() [2/2]

void SoWinGLWidget::setAntialiasing ( SoAntialiasingParameters advancedParameters)

Enable (or disable) antialiasing with specific parameters.

Use one of the subclasses of SoAntialiasingParameters. The antialiasing mode is determined by which subclass is used to set the parameters. For example, passing an SoFXAAParameters object automatically sets FXAA mode. Note that the parameters are overridden if a quality and mode are subsequently set using the setAntialiasing(float,AntialiasingMode) method.

NOTES

    • When the antialiasing parameters are modified a listener is called if it has been defined. See also setAntialiasingEventListener().
    • The caller is responsible for allocation and destruction of the advancedParameters object. SoSceneManager makes a copy of the parameter values, so the object can be destroyed after calling this method.
    Parameters
    advancedParametersProvides specific parameters for an antialiasing mode.
    Use a null parameter to turn off antialiasing or use one of the subclasses of SoAntialiasingParameters.

◆ setBorder()

void SoWinGLWidget::setBorder ( SbBool  onOrOff)

Included for portability only.

◆ setCursor()

void SoWinGLWidget::setCursor ( Cursor  newCursor)

Sets the current cursor.

If you are using a viewer class, the viewer will automatically change the cursor depending on the viewer mode. These changes will override the cursor set with this method unless you also call SoWinViewer::setCursorEnabled(FALSE).

◆ setDoubleBuffer()

void SoWinGLWidget::setDoubleBuffer ( SbBool  onOrOff)

Routine that dynamically changes between single and double buffering.

Default is double buffer off. (The SoWinRenderArea subclass makes it double buffer by default.)

◆ setDrawToFrontBufferEnable()

void SoWinGLWidget::setDrawToFrontBufferEnable ( SbBool  enableFlag)

Sets drawing to the front buffer.

Controls drawing to the front buffer when an obscured portion of the window is exposed. Default: FALSE.

◆ setFloatingColorBuffer()

virtual void SoWinGLWidget::setFloatingColorBuffer ( SbBool  enable,
FloatColorBufferSize  size = FLOAT_16_COLOR_BUFFER 
)
virtual

Enables/disables floating point rendering using 16- or 32-bit components.

If TRUE, Open Inventor will automatically render to an offscreen floating point buffer, and copy the resulting image to the screen.

To determine if floating point rendering was successfully enabled, use getFloatingColorBuffer, below.

Using floating point rendering can improve image quality, particularly when many objects are being blended, for example, in volume rendering. This is a convenience method as you could accomplish the same results setting up a graphic template.

Reimplemented in SoWinRenderArea.

◆ setGraphicConfigTemplate()

void SoWinGLWidget::setGraphicConfigTemplate ( SoGLGraphicConfigTemplate gTemplate)

Sets a new graphics configuration template.

◆ setNormalVisual()

virtual void SoWinGLWidget::setNormalVisual ( XVisualInfo *  vis)
virtual

Specifies the exact pixel format descriptor for the normal window.

This allows the user to create all possible pixel format descriptors supported by OpenGL. The PIXELFORMATDESCRIPTOR structure should be a valid OpenGL pixel format descriptor returned by ChoosePixelFormat(). (The methods for setting the pixel format descriptor are virtual so that derived classes can know when the pixel format descriptor is changing.)

Reimplemented in SoWinViewer.

◆ setPixelFormat()

virtual void SoWinGLWidget::setPixelFormat ( int  format)
virtual

Sets the current pixel format.

This method allows an application to set a pixel format that has extended attributes that can't be specified in a PFD struct. The specified format must support OpenGL and drawing to a window.

You can also use environment variable OIV_FORCE_PIXEL_FORMAT to request a pixel format.

Note: OIV_FORCE_PIXEL_FORMAT can also be used to set special convenience values (-1, -2, etc.) used for troubleshooting. However, these values are not actually valid pixel formats and are not supported by setPixelFormat.

◆ setStealFocus()

void SoWinGLWidget::setStealFocus ( SbBool  onOrOff)
inline

By default the GLWidget "steals" focus whenever the cursor moves over it.

This roughly simulates the UNIX/X "focusFollowsCursor" behavior (which has no equivalent in Win32) and allows the Ctrl and Shift keys to be detected for 1-button mouse behaviors. Sometimes you want to this off however, like when you're typing in the zoom field.

Definition at line 135 of file SoWinGLWidget.h.

◆ swapNormalBuffers()

virtual SbBool SoWinGLWidget::swapNormalBuffers ( )
virtual

Swaps the normal front and back buffers.

◆ unbindNormalContext()

virtual SbBool SoWinGLWidget::unbindNormalContext ( )
virtual

unbind the current context (previously bind with bindNormalContext );


The documentation for this class was generated from the following file: