Added WindowData structures to GraphicsWindowX11,Win32 and Carbon to help support
GraphicsWindow inheriting their window handles from an external toolkit
This commit is contained in:
@@ -125,7 +125,7 @@ class OSG_EXPORT GraphicsContext : public Object
|
||||
// shared context
|
||||
GraphicsContext* sharedContext;
|
||||
|
||||
osg::ref_ptr<osg::Referenced> inhertedWindowData;
|
||||
osg::ref_ptr<osg::Referenced> inheritedWindowData;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -32,13 +32,14 @@ class GraphicsWindowCarbon : public osgViewer::GraphicsWindow
|
||||
public:
|
||||
|
||||
GraphicsWindowCarbon(osg::GraphicsContext::Traits* traits):
|
||||
_ownWindow(true),
|
||||
_valid(false),
|
||||
_initialized(false),
|
||||
_realized(false)
|
||||
{
|
||||
_traits = traits;
|
||||
|
||||
init();
|
||||
init(traits ? dynamic_cast<WindowData*>(traits->inheritedWindowData.get()) : 0);
|
||||
|
||||
if (valid())
|
||||
{
|
||||
@@ -98,9 +99,18 @@ class GraphicsWindowCarbon : public osgViewer::GraphicsWindow
|
||||
bool handleMouseEvent(EventRef theEvent);
|
||||
bool handleKeyboardEvent(EventRef theEvent);
|
||||
|
||||
/** WindowData is used to pass in the X11 window handle attached the GraphicsContext::Traits structure. */
|
||||
struct WindowData : public osg::Referenced
|
||||
{
|
||||
WindowData(Window window):
|
||||
_window(window) {}
|
||||
|
||||
Window _window;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
void init();
|
||||
void init(WindowData* inheritedWindowData=0);
|
||||
|
||||
void transformMouseXY(float& x, float& y);
|
||||
|
||||
@@ -111,6 +121,7 @@ class GraphicsWindowCarbon : public osgViewer::GraphicsWindow
|
||||
bool _realized;
|
||||
bool _useWindowDecoration;
|
||||
|
||||
bool _ownsWindow;
|
||||
WindowRef _window;
|
||||
AGLContext _context;
|
||||
AGLPixelFormat _pixelFormat;
|
||||
|
||||
@@ -78,9 +78,19 @@ class GraphicsWindowWin32 : public osgViewer::GraphicsWindow
|
||||
/** Handle a native (Win32) windowing event as received from the system */
|
||||
virtual LRESULT handleNativeWindowingEvent( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
/** WindowData is used to pass in the Win32 window handle attached the GraphicsContext::Traits structure.*/
|
||||
struct WindowData : public osg::Referenced
|
||||
{
|
||||
WindowData(HWND window):
|
||||
_hwnd(window) {}
|
||||
|
||||
HWND _hwnd;
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
void init();
|
||||
void init(WindowData* inheritedWindowData=0);
|
||||
|
||||
void registerWindowClass();
|
||||
|
||||
@@ -100,6 +110,7 @@ class GraphicsWindowWin32 : public osgViewer::GraphicsWindow
|
||||
|
||||
HGLRC getWGLContext() { return _hglrc; }
|
||||
|
||||
bool _ownsWindow;
|
||||
HWND _hwnd;
|
||||
HDC _hdc;
|
||||
HGLRC _hglrc;
|
||||
|
||||
@@ -50,7 +50,7 @@ class GraphicsWindowX11 : public osgViewer::GraphicsWindow
|
||||
{
|
||||
_traits = traits;
|
||||
|
||||
init();
|
||||
init(traits ? dynamic_cast<WindowData*>(traits->inheritedWindowData.get()) : 0);
|
||||
|
||||
if (valid())
|
||||
{
|
||||
@@ -108,6 +108,15 @@ class GraphicsWindowX11 : public osgViewer::GraphicsWindow
|
||||
/** Switch on/off the cursor.*/
|
||||
virtual void useCursor(bool cursorOn);
|
||||
|
||||
/** WindowData is used to pass in the X11 window handle attached the GraphicsContext::Traits structure. */
|
||||
struct WindowData : public osg::Referenced
|
||||
{
|
||||
WindowData(Window window):
|
||||
_window(window) {}
|
||||
|
||||
Window _window;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
// X11 specific aces functions
|
||||
@@ -127,7 +136,8 @@ class GraphicsWindowX11 : public osgViewer::GraphicsWindow
|
||||
~GraphicsWindowX11();
|
||||
|
||||
bool createVisualInfo();
|
||||
void init();
|
||||
|
||||
void init(WindowData* inheritedWindowData=0);
|
||||
|
||||
void transformMouseXY(float& x, float& y);
|
||||
void adaptKey(XKeyEvent& keyevent, int& keySymbol, unsigned int& modifierMask);
|
||||
|
||||
@@ -536,7 +536,7 @@ void GraphicsWindowCarbon::setWindowDecoration(bool flag)
|
||||
_useWindowDecoration = flag;
|
||||
}
|
||||
|
||||
void GraphicsWindowCarbon::init()
|
||||
void GraphicsWindowCarbon::init(WindowData* inheritedWindowData)
|
||||
{
|
||||
_closeRequested = false;
|
||||
_context = NULL;
|
||||
|
||||
@@ -980,7 +980,9 @@ osgViewer::GraphicsWindowWin32* Win32WindowingSystem::getGraphicsWindowFor( HWND
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GraphicsWindowWin32::GraphicsWindowWin32( osg::GraphicsContext::Traits* traits )
|
||||
: _hwnd(0),
|
||||
:
|
||||
_ownsWindow(true),
|
||||
_hwnd(0),
|
||||
_hdc(0),
|
||||
_hglrc(0),
|
||||
_timeOfLastCheckEvents(-1.0),
|
||||
@@ -1000,7 +1002,7 @@ GraphicsWindowWin32::GraphicsWindowWin32( osg::GraphicsContext::Traits* traits )
|
||||
{
|
||||
_traits = traits;
|
||||
|
||||
init();
|
||||
init(traits ? dynamic_cast<WindowData*>(traits->inheritedWindowData.get()) : 0);
|
||||
|
||||
if (valid())
|
||||
{
|
||||
@@ -1025,7 +1027,7 @@ GraphicsWindowWin32::~GraphicsWindowWin32()
|
||||
destroyWindow();
|
||||
}
|
||||
|
||||
void GraphicsWindowWin32::init()
|
||||
void GraphicsWindowWin32::init(WindowData* inheritedWindowData)
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
|
||||
@@ -367,7 +367,7 @@ void GraphicsWindowX11::useCursor(bool cursorOn)
|
||||
|
||||
}
|
||||
|
||||
void GraphicsWindowX11::init()
|
||||
void GraphicsWindowX11::init(WindowData* inheritedWindowData)
|
||||
{
|
||||
if (_initialized) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user