[osg-users] osgViewer GraphicsWindowX11 Event Handling

Chris Hanson xenon at alphapixel.com
Thu Apr 25 08:24:33 PDT 2019


My first question would be why you didn't like the existing Qt OSG options.

What were you seeking to improve?

On Thu, Apr 25, 2019, 11:49 AM Eric Stancliff <ericstancliff at yahoo.com>
wrote:

> Hello!
>
> I'm currently working on embedding an osgViewer into a QWidget (using
> Qt).  We've historically done this using QGLWidget and the
> EmbeddedGraphicsWindow, letting Qt manage the OpenGL contexts.  I'd like to
> move away from using QGLWidget and using contexts managed by OSG.  I've
> accomplished this on windows but am running into issues on Linux.  I'm
> creating the window as follows:
>
> Code:
>
> #include <QWidget>
>
> #ifdef WIN32
> #include <osgViewer/api/Win32/GraphicsWindowWin32>
> #define OSG_PLATFORM_WINDOW osgViewer::GraphicsWindowWin32
> #define WINDOW_HANDLE HWND
> #else
> #include <osgViewer/api/X11/GraphicsWindowX11>
> #define OSG_PLATFORM_WINDOW osgViewer::GraphicsWindowX11
> #define WINDOW_HANDLE Window
> #endif
>
> osg::GraphicsContext::Traits* createWindowTraits(QWidget* OwningWidget)
> {
>     auto traits = new osg::GraphicsContext::Traits();
>     traits->x = 0;
>     traits->y = 0;
>     traits->width = 1080;
>     traits->height = 720;
>     traits->doubleBuffer = true;
>     traits->useCursor = true;
>     //traits->installEventHandler = true;
>     if (OwningWidget)
>     {
>         OSG_PLATFORM_WINDOW::WindowData* data = new
> OSG_PLATFORM_WINDOW::WindowData((WINDOW_HANDLE)OwningWidget->winId());
>         traits->inheritedWindowData = data;
>     }
>     return traits;
> }
>
>
>
> ---- and then in my class derived from Viewer with the traits created
> above ----
>
> Code:
>
>
> getCamera()->setGraphicsContext(osg::GraphicsContext::createGraphicsContext(traits));
>
>
>
>
> Everything is working as expected on Windows.  The problem I'm having is
> that on Linux (RHEL7), my event handlers never get any mouse/keyboard
> events.  I'm unclear whether QWidget's X11 implementation for the owning
> widget is eating my events, or if the inherited window implementation of
> the GraphicsWindowX11 has a bug.  The resize events I'm passing from
> QWidget's resize and pushing to my viewers event queue are effective so my
> window is successfully embedded in the correct widget and rendering
> properly. Just events aren't working.
>
> Any suggestions?
>
> Thanks!
>
> Eric
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75893#75893
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20190425/0d232aa3/attachment.html>


More information about the osg-users mailing list