SoXt  1.4.1
Coin3D GUI toolkit binding
Loading...
Searching...
No Matches
SoXtGLWidget Class Referenceabstract

The SoXtGLWidget class manages OpenGL contexts. More...

#include <Inventor/Xt/SoXtGLWidget.h>

Inheritance diagram for SoXtGLWidget:
SoXtComponent SoXtObject SoXtRenderArea SoXtViewer SoXtFullViewer SoXtConstrainedViewer SoXtExaminerViewer SoXtPlaneViewer SoXtFlyViewer

Public Member Functions

SbBool getAccumulationBuffer (void) const
 
SbBool getAlphaChannel (void) const
 
int getColorMapSize (void)
 
Widget getGLWidget (void) const
 
void getLineWidthLimits (SbVec2f &range, float &granularity)
 
GLXContext getNormalContext (void)
 
XVisualInfo * getNormalVisual (void)
 
Widget getNormalWidget (void) const
 
Window getNormalWindow (void)
 
int getOverlayColorMapSize (void)
 
GLXContext getOverlayContext (void)
 
unsigned long getOverlayTransparentPixel (void)
 
XVisualInfo * getOverlayVisual (void)
 
Widget getOverlayWidget (void) const
 
Window getOverlayWindow (void)
 
void getPointSizeLimits (SbVec2f &range, float &granularity)
 
int getSampleBuffers (void) const
 
SbBool getStencilBuffer (void) const
 
SbBool hasNormalGLArea (void) const
 
SbBool hasOverlayGLArea (void) const
 
SbBool isBorder (void) const
 
SbBool isDoubleBuffer (void) const
 
SbBool isDrawToFrontBufferEnable (void) const
 
SbBool isOverlayRender (void) const
 
SbBool isQuadBufferStereo (void) const
 
SbBool isStealFocus (void) const
 
void setAccumulationBuffer (const SbBool enable)
 
void setAlphaChannel (const SbBool enable)
 
void setBorder (const SbBool enable)
 
virtual void setDoubleBuffer (const SbBool enable)
 
void setDrawToFrontBufferEnable (const SbBool enable)
 
virtual void setNormalVisual (XVisualInfo *visual)
 
void setOverlayRender (const SbBool onoff)
 
virtual void setOverlayVisual (XVisualInfo *visual)
 
void setQuadBufferStereo (const SbBool enable)
 
void setSampleBuffers (const int numsamples)
 
void setStealFocus (SbBool enable)
 
void setStencilBuffer (const SbBool enable)
 
- Public Member Functions inherited from SoXtComponent
virtual ~SoXtComponent ()
 
void addWindowCloseCallback (SoXtComponentCB *callback, void *closure=NULL)
 
void fitSize (const SbVec2s size)
 
Widget getBaseWidget (void) const
 
const char * getClassName (void) const
 
Display * getDisplay (void)
 
const char * getIconTitle (void) const
 
Widget getParentWidget (void) const
 
Widget getShellWidget (void) const
 
SbVec2s getSize (void) const
 
const char * getTitle (void) const
 
Widget getWidget (void) const
 
const char * getWidgetName (void) const
 
virtual void hide (void)
 
SbBool isFullScreen (void) const
 
SbBool isTopLevelShell (void) const
 
SbBool isVisible (void)
 
void removeWindowCloseCallback (SoXtComponentCB *callback, void *closure=NULL)
 
virtual void setComponentCursor (const SoXtCursor &cursor)
 
SbBool setFullScreen (const SbBool onoff)
 
void setIconTitle (const char *const title)
 
void setSize (const SbVec2s size)
 
void setTitle (const char *const title)
 
void setWindowCloseCallback (SoXtComponentCB *const func, void *const user=NULL)
 
virtual void show (void)
 
- Public Member Functions inherited from SoXtObject
virtual SoType getTypeId (void) const =0
 
SbBool isOfType (SoType type) const
 

Protected Member Functions

 SoXtGLWidget (Widget const parent=NULL, const char *const name=NULL, const SbBool embed=TRUE, const int glmodes=SO_GL_RGB, const SbBool build=TRUE)
 
 ~SoXtGLWidget ()
 
Widget buildWidget (Widget parent)
 
int getDisplayListShareGroup (GLXContext context)
 
float getGLAspectRatio (void) const
 
SbVec2s getGLSize (void) const
 
float getGlxAspectRatio (void) const
 
Widget getGlxMgrWidget (void)
 
SbVec2s getGlxSize (void) const
 
void glFlushBuffer (void)
 
void glLockNormal (void)
 
void glLockOverlay (void)
 
virtual SbBool glScheduleRedraw (void)
 
void glSwapBuffers (void)
 
void glUnlockNormal (void)
 
void glUnlockOverlay (void)
 
virtual void initGraphic (void)
 
virtual void initOverlayGraphic (void)
 
SbBool isRGBMode (void)
 
SbBool isStereoBuffer (void) const
 
virtual void processEvent (XAnyEvent *event)
 
virtual void redraw (void)=0
 
virtual void redrawOverlay (void)
 
void setGLSize (const SbVec2s size)
 
void setGlxSize (const SbVec2s size)
 
void setStereoBuffer (SbBool flag)
 
virtual void sizeChanged (const SbVec2s &size)
 
virtual void widgetChanged (Widget w)
 
- Protected Member Functions inherited from SoXtComponent
 SoXtComponent (Widget const parent=NULL, const char *const name=NULL, const SbBool embed=TRUE)
 
void addVisibilityChangeCallback (SoXtComponentVisibilityCB *const func, void *const user=NULL)
 
virtual void afterRealizeHook (void)
 
virtual const char * getDefaultIconTitle (void) const
 
virtual const char * getDefaultTitle (void) const
 
virtual const char * getDefaultWidgetName (void) const
 
void invokeVisibilityChangeCallbacks (const SbBool enable) const
 
void invokeWindowCloseCallbacks (void) const
 
void registerWidget (Widget widget)
 
void removeVisibilityChangeCallback (SoXtComponentVisibilityCB *const func, void *const user=NULL)
 
void setBaseWidget (Widget widget)
 
void setClassName (const char *const name)
 
void unregisterWidget (Widget widget)
 
virtual void windowCloseAction (void)
 

Static Protected Member Functions

static void eventHandler (Widget, SoXtGLWidget *, XAnyEvent *, Boolean *)
 

Protected Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from SoXtComponent
static SoXtComponentgetComponent (Widget widget)
 
static void initClasses (void)
 
static void setWidgetCursor (Widget w, const SoXtCursor &cursor)
 
- Static Public Member Functions inherited from SoXtObject
static SoType getClassTypeId (void)
 
static void init (void)
 
static void initClass (void)
 

Detailed Description

The SoXtGLWidget 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, SoXtRenderArea, or through one of the "rapid application development"-style viewer subclasses.

Constructor & Destructor Documentation

◆ SoXtGLWidget()

SoXtGLWidget::SoXtGLWidget ( Widget 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 its subclasses.

◆ ~SoXtGLWidget()

SoXtGLWidget::~SoXtGLWidget ( )
protected

Clean up all use of internal resources.

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

Member Function Documentation

◆ buildWidget()

Widget SoXtGLWidget::buildWidget ( Widget 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:

Widget MyOwnViewer::buildWidget(Widget parent)
{
Widget superw = <superclass>::buildWidget(parent);
// [then move superw within MyOwnViewer framework and add own
// user interface components]
}
Widget buildWidget(Widget parent)
Definition SoXtGLWidget.cpp:792

◆ eventHandler()

void SoXtGLWidget::eventHandler ( Widget widget,
SoXtGLWidget * closure,
XAnyEvent * event,
Boolean * dispatch )
staticprotected

This method is a callback that dispatches events to processEvent().

See also
processEvent

◆ getAccumulationBuffer()

SbBool SoXtGLWidget::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 SoXtGLWidget::setAccumulationBuffer(). See documentation of that function for more information.

Returns whether the OpenGL accumulation buffer is enabled.

◆ getAlphaChannel()

SbBool SoXtGLWidget::getAlphaChannel ( void ) const

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

Returns whether the an alpha channel is enabled.

◆ getColorMapSize()

int SoXtGLWidget::getColorMapSize ( void )

This method returns the size of the colormap for the normal planes.

◆ getDisplayListShareGroup()

int SoXtGLWidget::getDisplayListShareGroup ( GLXContext context)
protected

This method returns the share group for the display lists for the GL context.

◆ getGLAspectRatio()

float SoXtGLWidget::getGLAspectRatio ( void ) const
protected

Return the aspect ratio of the OpenGL canvas.

This method returns the aspect ratio of the GL area.

◆ getGLSize()

SbVec2s SoXtGLWidget::getGLSize ( void ) const
protected

Return the dimensions of the OpenGL canvas.

This method returns the size of the GL area.

◆ getGLWidget()

Widget SoXtGLWidget::getGLWidget ( void ) const

Returns a pointer to the toolkit-native GL widget.

This method returns the actual GL widget.

◆ getGlxAspectRatio()

float SoXtGLWidget::getGlxAspectRatio ( void ) const
inlineprotected

This function has been renamed to the more appropriate getGLAspectRatio.

See also
getGLAspectRatio

This is the old name for getGLAspectRatio.

See also
getGLAspectRatio

◆ getGlxMgrWidget()

Widget SoXtGLWidget::getGlxMgrWidget ( void )
protected

This method returns the widget that is managing the GL widget.

◆ getGlxSize()

const SbVec2s SoXtGLWidget::getGlxSize ( void ) const
inlineprotected

This function has been renamed to the more appropriate getGLSize.

See also
getGLSize

This method returns the size of the GLX area.

See also
getGLSize

◆ getLineWidthLimits()

void SoXtGLWidget::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.

◆ getNormalContext()

GLXContext SoXtGLWidget::getNormalContext ( void )

Returns the GL context for normal rendering.

See also
getOverlayContext

◆ getNormalVisual()

XVisualInfo * SoXtGLWidget::getNormalVisual ( void )

This method returns the visual for the normal GL context.

◆ getNormalWidget()

Widget SoXtGLWidget::getNormalWidget ( void ) const

This method returns the Widget associated with the normal GL context.

◆ getNormalWindow()

Window SoXtGLWidget::getNormalWindow ( void )

This method returns the Window associated with the normal GL context.

◆ getOverlayColorMapSize()

int SoXtGLWidget::getOverlayColorMapSize ( void )

This method returns the size of the colormap for the overlay planes.

◆ getOverlayContext()

GLXContext SoXtGLWidget::getOverlayContext ( void )

Returns the GL context for overlay rendering.

See also
getNormalContext

◆ getOverlayTransparentPixel()

unsigned long SoXtGLWidget::getOverlayTransparentPixel ( void )

Returns the overlay transparent pixel.

This method returns the transparent pixel for the overlay planes.

◆ getOverlayVisual()

XVisualInfo * SoXtGLWidget::getOverlayVisual ( void )

This method returns the visual for the overlay GL context.

◆ getOverlayWidget()

Widget SoXtGLWidget::getOverlayWidget ( void ) const

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

This method returns the Widget associated with the overlay GL context.

◆ getOverlayWindow()

Window SoXtGLWidget::getOverlayWindow ( void )

This method returns the Window associated with the overlay GL context.

◆ getPointSizeLimits()

void SoXtGLWidget::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.

◆ getSampleBuffers()

int SoXtGLWidget::getSampleBuffers ( void ) const

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

◆ getStencilBuffer()

SbBool SoXtGLWidget::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 SoXtGLWidget::getAccumulationBuffer(). See documentation of SoXtGLWidget::setStencilBuffer().

Returns whether the OpenGL stencil buffer is enabled.

◆ glFlushBuffer()

void SoXtGLWidget::glFlushBuffer ( void )
protected

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

This method flushes the GL context.

◆ glLockNormal()

void SoXtGLWidget::glLockNormal ( void )
protected

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

This method locks the GL context.

On systems that use GL context locking and unlocking, this method will lock the GL context. On other systems, only makeCurrent will be run.

This method is an SoXt extension.

◆ glLockOverlay()

void SoXtGLWidget::glLockOverlay ( void )
protected

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

This method locks the GL context.

On systems that use GL context locking and unlocking, this method will lock the GL context. On other systems, only makeCurrent will be run.

This method is an SoXt extension.

◆ glScheduleRedraw()

SbBool SoXtGLWidget::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.

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

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

Reimplemented in SoXtRenderArea.

◆ glSwapBuffers()

void SoXtGLWidget::glSwapBuffers ( void )
protected

Swap back buffer to front and vice versa.

This method swaps the GL buffers.

◆ glUnlockNormal()

void SoXtGLWidget::glUnlockNormal ( void )
protected

This method decreases the lock level.

This method unlocks the GL context.

◆ glUnlockOverlay()

void SoXtGLWidget::glUnlockOverlay ( void )
protected

This method decreases the lock level.

This method unlocks the GL context.

◆ hasNormalGLArea()

SbBool SoXtGLWidget::hasNormalGLArea ( void ) const

Will return TRUE if a normal GL drawing area exists.

Should return TRUE if a normal GL drawing area exists.

◆ hasOverlayGLArea()

SbBool SoXtGLWidget::hasOverlayGLArea ( void ) const

Will return TRUE if an overlay GL drawing area exists.

Should return TRUE if an overlay GL drawing area exists.

◆ initGraphic()

void SoXtGLWidget::initGraphic ( void )
protectedvirtual

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

This method initializes the graphics.

Reimplemented in SoXtRenderArea.

◆ initOverlayGraphic()

void SoXtGLWidget::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.

This method initializes the overlay graphics.

Reimplemented in SoXtRenderArea.

◆ isBorder()

SbBool SoXtGLWidget::isBorder ( void ) const

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

See also
setBorder()

◆ isDoubleBuffer()

SbBool SoXtGLWidget::isDoubleBuffer ( void ) const

Returns the status of the buffer mode.

See also
setDoubleBuffer()

This method returns whether double buffering is used or not.

◆ isDrawToFrontBufferEnable()

SbBool SoXtGLWidget::isDrawToFrontBufferEnable ( void ) const
See also
setDrawToFrontBufferEnable()

This method returns whether rendering is done to the front buffer or not.

◆ isOverlayRender()

SbBool SoXtGLWidget::isOverlayRender ( void ) const

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

See also
setOverlayRender()

◆ isQuadBufferStereo()

SbBool SoXtGLWidget::isQuadBufferStereo ( void ) const

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

◆ isRGBMode()

SbBool SoXtGLWidget::isRGBMode ( void )
protected

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

This method returns whether the GL context is in RGB mode or not.

◆ isStealFocus()

SbBool SoXtGLWidget::isStealFocus ( void ) const

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

Default is TRUE.

See also
setStealFocus
Since
SoXt 1.3.0

◆ isStereoBuffer()

SbBool SoXtGLWidget::isStereoBuffer ( void ) const
protected

Returns whether OpenGL stereo buffers are being used.

◆ processEvent()

void SoXtGLWidget::processEvent ( XAnyEvent * event)
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, as well as forwarding relevant events to the scene graph.

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

It is overloaded in the subclasses to catch user interaction with the render canvas in the viewers, as well as forwarding relevant events to the scene graph.

Reimplemented in SoXtRenderArea.

◆ redraw()

void SoXtGLWidget::redraw ( void )
protectedpure virtual

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

Implemented in SoXtRenderArea.

◆ redrawOverlay()

void SoXtGLWidget::redrawOverlay ( void )
protectedvirtual

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

This method is invoked when the overlay graphics should be redrawn.

Reimplemented in SoXtRenderArea.

◆ setAccumulationBuffer()

void SoXtGLWidget::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-accelerated rendering, etc).

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

See also
SoXtRenderArea::setAntiAliasing()

Enables or disables quad buffer stereo.

Enables/disables the OpenGL accumulation buffer.

◆ setAlphaChannel()

void SoXtGLWidget::setAlphaChannel ( const SbBool enable)

Enables/disables the alpha channel for the OpenGL context.

Enables/disables an alpha channel for the rendering context.

◆ setBorder()

void SoXtGLWidget::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()

◆ setDoubleBuffer()

void SoXtGLWidget::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()

This method sets whether double buffering is to be used or not.

Reimplemented in SoXtViewer.

◆ setDrawToFrontBufferEnable()

void SoXtGLWidget::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.

This method sets whether rendering will be done to the front buffer or not.

◆ setGLSize()

void SoXtGLWidget::setGLSize ( const SbVec2s size)
protected

Sets the size of the GL canvas.

This method sets the size of the GL widget.

◆ setGlxSize()

void SoXtGLWidget::setGlxSize ( const SbVec2s size)
inlineprotected

This function has been renamed to the more appropriate setGLSize.

See also
setGLSize

This method sets the GLX size.

See also
setGLSize

◆ setNormalVisual()

void SoXtGLWidget::setNormalVisual ( XVisualInfo * visual)
virtual

This method sets the visual for the normal GL context.

◆ setOverlayRender()

void SoXtGLWidget::setOverlayRender ( const SbBool onoff)

Turn on or off the use of overlay planes.

See also
isOverlayRender()

◆ setOverlayVisual()

void SoXtGLWidget::setOverlayVisual ( XVisualInfo * visual)
virtual

This method sets the visual for the overlay GL context.

◆ setQuadBufferStereo()

void SoXtGLWidget::setQuadBufferStereo ( const SbBool enable)

Enables or disables OpenGL quad buffer stereo.

◆ setSampleBuffers()

void SoXtGLWidget::setSampleBuffers ( const int numsamples)

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

◆ setStealFocus()

void SoXtGLWidget::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
SoXt 1.3.0

◆ setStencilBuffer()

void SoXtGLWidget::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 SoXtGLWidget::setAccumulationBuffer().

Enables/disables the OpenGL stencil buffer.

◆ setStereoBuffer()

void SoXtGLWidget::setStereoBuffer ( SbBool flag)
protected

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

◆ sizeChanged()

void SoXtGLWidget::sizeChanged ( const SbVec2s & size)
protectedvirtual

Called internally from within the SoXt library when the widget embedded in a component changes its 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 SoXtComponent.

Reimplemented in SoXtRenderArea, SoXtFullViewer, and SoXtViewer.

◆ widgetChanged()

void SoXtGLWidget::widgetChanged ( Widget widget)
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 SoXtGLWidget::getGLWidget() method.

See also
sizeChanged()

This method is invoked when a widget in the component is changed.

Reimplemented in SoXtRenderArea.

Member Data Documentation

◆ drawToFrontBuffer

SbBool SoXtGLWidget::drawToFrontBuffer
protected

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

◆ waitForExpose

SbBool SoXtGLWidget::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.


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