[osg-users] osgViewer GraphicsWindowX11 Event Handling
Eric Stancliff
ericstancliff at yahoo.com
Wed Apr 24 14:43:12 PDT 2019
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
More information about the osg-users
mailing list