Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoWinGLWidget Class Referenceabstract

The SoWinGLWidget class manages OpenGL contexts. More...

#include <Inventor/Win/SoWinGLWidget.h>

Inheritance diagram for SoWinGLWidget:
SoWinComponent SoWinObject SoWinRenderArea SoWinViewer SoWinFullViewer SoWinConstrainedViewer SoWinExaminerViewer SoWinPlaneViewer SoWinFlyViewer

Public Member Functions

void setBorder (const SbBool enable)
 
SbBool isBorder (void) const
 
virtual void setDoubleBuffer (const SbBool enable)
 
SbBool isDoubleBuffer (void) const
 
void setDrawToFrontBufferEnable (const SbBool enable)
 
SbBool isDrawToFrontBufferEnable (void) const
 
void setQuadBufferStereo (const SbBool enable)
 
SbBool isQuadBufferStereo (void) const
 
void setAccumulationBuffer (const SbBool enable)
 
SbBool getAccumulationBuffer (void) const
 
void setStencilBuffer (const SbBool enable)
 
SbBool getStencilBuffer (void) const
 
void setAlphaChannel (const SbBool enable)
 
SbBool getAlphaChannel (void) const
 
void setOverlayRender (const SbBool onoff)
 
SbBool isOverlayRender (void) const
 
void setSampleBuffers (const int numsamples)
 
int getSampleBuffers (void) const
 
void setStealFocus (SbBool enable)
 
SbBool isStealFocus (void) const
 
HWND getGLWidget (void) const
 
HWND getNormalWidget (void) const
 
HWND getOverlayWidget (void) const
 
SbBool hasOverlayGLArea (void) const
 
SbBool hasNormalGLArea (void) const
 
unsigned long getOverlayTransparentPixel (void)
 
void getPointSizeLimits (SbVec2f &range, float &granularity)
 
void getLineWidthLimits (SbVec2f &range, float &granularity)
 
- Public Member Functions inherited from SoWinComponent
virtual ~SoWinComponent ()
 
virtual void show (void)
 
virtual void hide (void)
 
virtual void setComponentCursor (const SoWinCursor &cursor)
 
SbBool isFullScreen (void) const
 
SbBool setFullScreen (const SbBool onoff)
 
SbBool isVisible (void)
 
SbBool isTopLevelShell (void) const
 
HWND getWidget (void) const
 
HWND getBaseWidget (void) const
 
HWND getShellWidget (void) const
 
HWND getParentWidget (void) const
 
void setSize (const SbVec2s size)
 
SbVec2s getSize (void) const
 
void setTitle (const char *const title)
 
const char * getTitle (void) const
 
void setIconTitle (const char *const title)
 
const char * getIconTitle (void) const
 
const char * getWidgetName (void) const
 
const char * getClassName (void) const
 
void setWindowCloseCallback (SoWinComponentCB *const func, void *const user=NULL)
 
- Public Member Functions inherited from SoWinObject
virtual SoType getTypeId (void) const =0
 
SbBool isOfType (SoType type) const
 

Protected Member Functions

 SoWinGLWidget (HWND const parent=NULL, const char *const name=NULL, const SbBool embed=TRUE, const int glmodes=SO_GL_RGB, const SbBool build=TRUE)
 
 ~SoWinGLWidget ()
 
virtual void processEvent (MSG *event)
 
HWND buildWidget (HWND parent)
 
virtual void redraw (void)=0
 
virtual void redrawOverlay (void)
 
virtual void initGraphic (void)
 
virtual void initOverlayGraphic (void)
 
virtual void sizeChanged (const SbVec2s &size)
 
virtual void widgetChanged (HWND w)
 
void setGLSize (const SbVec2s size)
 
SbVec2s getGLSize (void) const
 
float getGLAspectRatio (void) const
 
void setGlxSize (const SbVec2s size)
 
SbVec2s getGlxSize (void) const
 
float getGlxAspectRatio (void) const
 
void setStereoBuffer (SbBool flag)
 
SbBool isStereoBuffer (void) const
 
SbBool isRGBMode (void)
 
void glLockNormal (void)
 
void glUnlockNormal (void)
 
void glLockOverlay (void)
 
void glUnlockOverlay (void)
 
void glSwapBuffers (void)
 
void glFlushBuffer (void)
 
virtual SbBool glScheduleRedraw (void)
 
- Protected Member Functions inherited from SoWinComponent
 SoWinComponent (HWND const parent=NULL, const char *const name=NULL, const SbBool embed=TRUE)
 
virtual void afterRealizeHook (void)
 
void setClassName (const char *const name)
 
void setBaseWidget (HWND widget)
 
void registerWidget (HWND widget)
 
void unregisterWidget (HWND widget)
 
virtual const char * getDefaultWidgetName (void) const
 
virtual const char * getDefaultTitle (void) const
 
virtual const char * getDefaultIconTitle (void) const
 
void addVisibilityChangeCallback (SoWinComponentVisibilityCB *const func, void *const user=NULL)
 
void removeVisibilityChangeCallback (SoWinComponentVisibilityCB *const func, void *const user=NULL)
 

Protected Attributes

SbBool waitForExpose
 
SbBool drawToFrontBuffer
 
- Protected Attributes inherited from SoWinComponent
SbBool firstRealize
 

Additional Inherited Members

- Static Public Member Functions inherited from SoWinComponent
static void setWidgetCursor (HWND w, const SoWinCursor &cursor)
 
static SoWinComponentgetComponent (HWND widget)
 
static void initClasses (void)
 
- Static Public Member Functions inherited from SoWinObject
static void initClass (void)
 
static SoType getClassTypeId (void)
 
static void init (void)
 

Detailed Description

The SoWinGLWidget class manages OpenGL contexts.

This is the basic, abstract component class which sets up an OpenGL canvas for its subclasses.

Application programmers will normally not use this class directly, but rather through the interface of either its direct descendent; SoWinRenderArea, or through one of the "rapid application development"-style viewer subclasses.

For debugging purposes, SoWinGLWidget provides the OIV_FORCE_PIXEL_FORMAT environment variable to make it possible to override the pixel format chosen by the internal attribute match algorithm.

Constructor & Destructor Documentation

◆ SoWinGLWidget()

SoWinGLWidget::SoWinGLWidget ( HWND const  parent = NULL,
const char *const  name = NULL,
const SbBool  embed = TRUE,
const int  glmodes = SO_GL_RGB,
const SbBool  build = TRUE 
)
protected

The constructor is protected, as this is an abstract class to only be used by it's subclasses.

◆ ~SoWinGLWidget()

SoWinGLWidget::~SoWinGLWidget ( )
protected

Clean up all use of internal resources.

The destructor is protected, as this is an abstract class to only be used by it's subclasses.

Member Function Documentation

◆ setBorder()

void SoWinGLWidget::setBorder ( const SbBool  enable)

Specify whether or not there should be a border framing the OpenGL canvas. The border will be 2 pixels wide.

The default is to display the OpenGL canvas with no border.

See also
isBorder()

◆ isBorder()

SbBool SoWinGLWidget::isBorder ( void  ) const

Returns whether or not there's a border framing the OpenGL canvas.

See also
setBorder()

◆ setDoubleBuffer()

void SoWinGLWidget::setDoubleBuffer ( const SbBool  enable)
virtual

Switch between single and double buffer mode for the OpenGL canvas. The default is to use a single buffer canvas.

See also
isDoubleBuffer()

Reimplemented in SoWinViewer.

◆ isDoubleBuffer()

SbBool SoWinGLWidget::isDoubleBuffer ( void  ) const

Returns the status of the buffer mode.

See also
setDoubleBuffer()

◆ setDrawToFrontBufferEnable()

void SoWinGLWidget::setDrawToFrontBufferEnable ( const SbBool  enable)

If this is set to TRUE, rendering will happen in the front buffer even if the current rendering mode is double buffered.

◆ isDrawToFrontBufferEnable()

SbBool SoWinGLWidget::isDrawToFrontBufferEnable ( void  ) const

◆ setQuadBufferStereo()

void SoWinGLWidget::setQuadBufferStereo ( const SbBool  enable)

Enables or disables OpenGL quad buffer stereo.

◆ isQuadBufferStereo()

SbBool SoWinGLWidget::isQuadBufferStereo ( void  ) const

Returns TRUE if quad buffer stereo is enabled for this widget.

◆ setAccumulationBuffer()

void SoWinGLWidget::setAccumulationBuffer ( const SbBool  enable)

Enables/disables the OpenGL accumulation buffer.

For general information about accumulation buffers, confer with your OpenGL reference documentation.

By default, the accumulation buffer will be attempted disabled. Whether or not it will actually be disabled depends on what OpenGL contexts are available on the system. It is perfectly possible that the only usable contexts with regard to the other settings (like double buffering and RGBA mode versus color index mode) causes the context selection to choose an OpenGL format that contains an accumulation buffer, even though it was not requested.

Vice versa, one is not guaranteed to get accumulation buffers even when requested through this function, either because they are not available, or because they are only available in combination with other OpenGL context settings that are not wanted (like single buffers, non-accellerated rendering, etc).

If you try to enable accumulation buffers by using this function, you should therefore in succession use the SoWinGLWidget::getAccumulationBuffer() to query whether or not an accumulation buffer could actually be set up.

See also
SoWinRenderArea::setAntiAliasing()

◆ getAccumulationBuffer()

SbBool SoWinGLWidget::getAccumulationBuffer ( void  ) const

Returns whether the OpenGL accumulation buffer is enabled.

The returned flag will indicate whether or not accumulation buffers are actually present, and not just parrot the input value to SoWinGLWidget::setAccumulationBuffer(). See documentation of that function for more information.

◆ setStencilBuffer()

void SoWinGLWidget::setStencilBuffer ( const SbBool  enable)

Enables/disables the OpenGL stencil buffer.

For general information about stencil buffers, confer with your OpenGL reference documentation.

By default, the stencil buffer will be attempted disabled, but the same notes apply for stencil buffers as for accumulation buffers. For an explanation on the issue of stencil and accumulation buffer availability, see the function documentation of SoWinGLWidget::setAccumulationBuffer().

◆ getStencilBuffer()

SbBool SoWinGLWidget::getStencilBuffer ( void  ) const

Returns whether the OpenGL stencil buffer is enabled.

The returned flag will indicate whether or not stencil buffers are actually present, in the same manner as for SoWinGLWidget::getAccumulationBuffer(). See documentation of SoWinGLWidget::setStencilBuffer().

◆ setAlphaChannel()

void SoWinGLWidget::setAlphaChannel ( const SbBool  enable)

Enables/disables the alpha channel for the OpenGL context.

◆ getAlphaChannel()

SbBool SoWinGLWidget::getAlphaChannel ( void  ) const

Returns whether the alpha channel is enabled for the OpenGL context.

◆ setOverlayRender()

void SoWinGLWidget::setOverlayRender ( const SbBool  onoff)

Turn on or off the use of overlay planes.

See also
isOverlayRender()

◆ isOverlayRender()

SbBool SoWinGLWidget::isOverlayRender ( void  ) const

Returns a flag indicating whether or not overplay planes are currently used.

See also
setOverlayRender()

◆ setSampleBuffers()

void SoWinGLWidget::setSampleBuffers ( const int  numsamples)

Set the number of samples use when enabling multisample buffer contexts. Multisampling will be enabled when numsamples > 1.

◆ getSampleBuffers()

int SoWinGLWidget::getSampleBuffers ( void  ) const

Returns the number of samples used for multisampling. Returns 1 if multisampling is disabled.

◆ setStealFocus()

void SoWinGLWidget::setStealFocus ( SbBool  enable)

Sets whether the GL widget should steal keyboard focus when the mouse is over the GL view.

Default is TRUE.

See also
isStealFocus
Since
SoWin 1.3.0

◆ isStealFocus()

SbBool SoWinGLWidget::isStealFocus ( void  ) const

Returns whether focus stealing policy is on (TRUE) or off (FALSE).

Default is TRUE.

See also
setStealFocus
Since
SoWin 1.3.0

◆ getGLWidget()

HWND SoWinGLWidget::getGLWidget ( void  ) const

Returns a pointer to the toolkit-native GL widget.

◆ getOverlayWidget()

HWND SoWinGLWidget::getOverlayWidget ( void  ) const

Returns widget associated with overlay planes, or NULL if no overlay planes are available.

◆ hasOverlayGLArea()

SbBool SoWinGLWidget::hasOverlayGLArea ( void  ) const

Will return TRUE if an overlay GL drawing area exists.

◆ hasNormalGLArea()

SbBool SoWinGLWidget::hasNormalGLArea ( void  ) const

Will return TRUE if a normal GL drawing area exists.

◆ getOverlayTransparentPixel()

unsigned long SoWinGLWidget::getOverlayTransparentPixel ( void  )

Returns the overlay transparent pixel.

◆ getPointSizeLimits()

void SoWinGLWidget::getPointSizeLimits ( SbVec2f range,
float &  granularity 
)

This function is provided as a convenience for the application programmer to help with acquiring the OpenGL implementation limits for rendering points.

For robust application code, one needs to consider the range limits when setting the SoDrawStyle::pointSize field.

◆ getLineWidthLimits()

void SoWinGLWidget::getLineWidthLimits ( SbVec2f range,
float &  granularity 
)

This function is provided as a convenience for the application programmer to help with acquiring the OpenGL implementation limits for rendering lines.

For robust application code, one needs to consider the range limits when setting the SoDrawStyle::lineWidth field.

◆ processEvent()

void SoWinGLWidget::processEvent ( MSG *  anyevent)
protectedvirtual

Any events from the native window system that goes to the OpenGL canvas gets piped through this method.

It is overridden in the subclasses to catch user interaction with the render canvas in the viewers, aswell as forwarding relevant events to the scenegraph.

Reimplemented in SoWinRenderArea.

◆ buildWidget()

HWND SoWinGLWidget::buildWidget ( HWND  parent)
protected

This method builds the component contents in the given parent widget. For subclasses adding new user interface items, this method is typically overridden in the following manner:

HWND MyOwnViewer::buildWidget(HWND parent)
{
HWND superw = <superclass>::buildWidget(parent);
// [then move superw within MyOwnViewer framework and add own
// user interface components]
}

◆ redraw()

void SoWinGLWidget::redraw ( void  )
protectedpure virtual

This method is invoked when the GL buffer needs to be redrawn.

Implemented in SoWinRenderArea.

◆ redrawOverlay()

void SoWinGLWidget::redrawOverlay ( void  )
protectedvirtual

Renders the overlay scene graph. Default method is empty. Subclasses should override this method.

Reimplemented in SoWinRenderArea.

◆ initGraphic()

void SoWinGLWidget::initGraphic ( void  )
protectedvirtual

Will be called when GL widget should initialize graphic, after the widget has been created. Default method enabled GL_DEPTH_TEST.

Reimplemented in SoWinRenderArea.

◆ initOverlayGraphic()

void SoWinGLWidget::initOverlayGraphic ( void  )
protectedvirtual

Will be called after the overlay widget has been created, and subclasses should override this to initialize overlay stuff.

Default method does nothing.

Reimplemented in SoWinRenderArea.

◆ sizeChanged()

void SoWinGLWidget::sizeChanged ( const SbVec2s size)
protectedvirtual

Called internally from within the SoWin library when the widget embedded in a component changes it size, which is usually triggered by end-user interaction.

This method is then invoked to notify the component that the size has changed. It is called from the top and all the way down to the bottom, the size being adjusted to take into account extra decorations having been added at each level in the component class hierarchy.

Reimplemented from SoWinComponent.

Reimplemented in SoWinViewer, SoWinRenderArea, and SoWinFullViewer.

◆ widgetChanged()

void SoWinGLWidget::widgetChanged ( HWND  w)
protectedvirtual

This is the method which gets called whenever we change which OpenGL widget is used.

Should be overridden in subclasses which directly or indirectly store the return value from the SoWinGLWidget::getGLWidget() method.

See also
sizeChanged()

Reimplemented in SoWinRenderArea.

◆ setGLSize()

void SoWinGLWidget::setGLSize ( const SbVec2s  size)
protected

Sets the size of the GL canvas.

◆ getGLSize()

SbVec2s SoWinGLWidget::getGLSize ( void  ) const
protected

Return the dimensions of the OpenGL canvas.

◆ getGLAspectRatio()

float SoWinGLWidget::getGLAspectRatio ( void  ) const
protected

Return the aspect ratio of the OpenGL canvas.

◆ setGlxSize()

void SoWinGLWidget::setGlxSize ( const SbVec2s  size)
inlineprotected

This function has been renamed to the more appropriate setGLSize.

See also
setGLSize

◆ getGlxSize()

SbVec2s SoWinGLWidget::getGlxSize ( void  ) const
inlineprotected

This function has been renamed to the more appropriate getGLSize.

See also
getGLSize

◆ getGlxAspectRatio()

float SoWinGLWidget::getGlxAspectRatio ( void  ) const
inlineprotected

This function has been renamed to the more appropriate getGLAspectRatio.

See also
getGLAspectRatio

◆ setStereoBuffer()

void SoWinGLWidget::setStereoBuffer ( SbBool  flag)
protected

Sets whether OpenGL stereo buffers (quad buffer stereo) should be used.

◆ isStereoBuffer()

SbBool SoWinGLWidget::isStereoBuffer ( void  ) const
protected

Returns whether OpenGL stereo buffers are being used.

◆ isRGBMode()

SbBool SoWinGLWidget::isRGBMode ( void  )
protected

Returns TRUE if the normal GL context is in RGBA mode. Return FALSE if color index mode is used.

◆ glLockNormal()

void SoWinGLWidget::glLockNormal ( void  )
protected

This method calls make-current on the correct context and ups the lock level.

◆ glUnlockNormal()

void SoWinGLWidget::glUnlockNormal ( void  )
protected

This method drops the lock level.

◆ glLockOverlay()

void SoWinGLWidget::glLockOverlay ( void  )
protected

This method calls make-current on the correct context and ups the lock level.

◆ glUnlockOverlay()

void SoWinGLWidget::glUnlockOverlay ( void  )
protected

This method drops the lock level.

◆ glSwapBuffers()

void SoWinGLWidget::glSwapBuffers ( void  )
protected

Swap back buffer to front and vice versa.

◆ glFlushBuffer()

void SoWinGLWidget::glFlushBuffer ( void  )
protected

Flush the current GL buffer. Simply calls glFlush().

◆ glScheduleRedraw()

SbBool SoWinGLWidget::glScheduleRedraw ( void  )
protectedvirtual

Will be called whenever scene graph needs to be redrawn. If this method return FALSE, redraw() will be called immediately.

Default method simply returns FALSE. Override this method to schedule a redraw and return TRUE if you're trying to do The Right Thing.

Reimplemented in SoWinRenderArea.

Member Data Documentation

◆ waitForExpose

SbBool SoWinGLWidget::waitForExpose
protected

If this is TRUE, rendering should not be done yet. Upon the first expose event of a newly created OpenGL widget, this variable will be set to FALSE.

◆ drawToFrontBuffer

SbBool SoWinGLWidget::drawToFrontBuffer
protected

If this is TRUE, rendering will happen in the front buffer even if the current rendering mode is double buffered.


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