Added osg::GraphicsContext::WindowingSystemInterfaces singleton for managing multiple WIndowinSystemInterface

implementations being registered at the same time.

One usage case for this functionality to support usage of Wayland and X11 in the same version of the osgViewer.

As part of the new functionality there is now a osg::GraphicsContext::Traits::windowingSystemPreferrence string
that default to empty, but if defined will ensure that a specific WindowingSystemInterface is utilized when
you do a generic call like osg::createGraphicsContext().

Also implemented is standard proxy object for registering the new contexts and removing them automatically, and
declaration of standard graphicswindow_name() C entry point to help with static build linking.
This commit is contained in:
Robert Osfield 2016-05-16 13:45:31 +01:00
parent dd10619192
commit fe6238d126
12 changed files with 204 additions and 67 deletions

View File

@ -50,6 +50,7 @@ int main( int argc, char **argv )
// left window + left slave camera // left window + left slave camera
{ {
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = xoffset + 0; traits->x = xoffset + 0;
traits->y = yoffset + 0; traits->y = yoffset + 0;
traits->width = 600; traits->width = 600;

View File

@ -76,6 +76,12 @@ class OSG_EXPORT GraphicsContext : public Object
int width; int width;
int height; int height;
// provide a hint as to which WindowingSystemInterface implementation to use, i.e. "X11", "Win32", "Cocoa", "Carbon" etc.
// if the windowingSystemPreference string is empty (default) then return the first available WindowingSystemInterface that
// has been registered with the osg::GraphiccsContext::WindowingSystemInterfaces singleton
// if the windowingSystemPreference string is not empty then return the first WindowingSystemInterface that matches
std::string windowingSystemPreference;
// window decoration and behaviour // window decoration and behaviour
std::string windowName; std::string windowName;
bool windowDecoration; bool windowDecoration;
@ -168,6 +174,9 @@ class OSG_EXPORT GraphicsContext : public Object
/** Callback to be implemented to provide access to Windowing API's ability to create Windows/pbuffers.*/ /** Callback to be implemented to provide access to Windowing API's ability to create Windows/pbuffers.*/
struct WindowingSystemInterface : public osg::Referenced struct WindowingSystemInterface : public osg::Referenced
{ {
void setName(const std::string& name) { _name = name; }
const std::string& getName() const { return _name; }
virtual unsigned int getNumScreens(const ScreenIdentifier& screenIdentifier = ScreenIdentifier()) = 0; virtual unsigned int getNumScreens(const ScreenIdentifier& screenIdentifier = ScreenIdentifier()) = 0;
virtual void getScreenSettings(const ScreenIdentifier& screenIdentifier, ScreenSettings & resolution) = 0; virtual void getScreenSettings(const ScreenIdentifier& screenIdentifier, ScreenSettings & resolution) = 0;
@ -182,9 +191,6 @@ class OSG_EXPORT GraphicsContext : public Object
virtual GraphicsContext* createGraphicsContext(Traits* traits) = 0; virtual GraphicsContext* createGraphicsContext(Traits* traits) = 0;
virtual ~WindowingSystemInterface() {}
/** Gets screen resolution without using the ScreenResolution structure. /** Gets screen resolution without using the ScreenResolution structure.
* \deprecated Provided only for backward compatibility. */ * \deprecated Provided only for backward compatibility. */
inline void getScreenResolution(const ScreenIdentifier& screenIdentifier, unsigned int& width, unsigned int& height) inline void getScreenResolution(const ScreenIdentifier& screenIdentifier, unsigned int& width, unsigned int& height)
@ -210,15 +216,38 @@ class OSG_EXPORT GraphicsContext : public Object
settings.refreshRate = refreshRate; settings.refreshRate = refreshRate;
return setScreenSettings(screenIdentifier, settings); return setScreenSettings(screenIdentifier, settings);
} }
protected:
WindowingSystemInterface() {}
virtual ~WindowingSystemInterface() {}
std::string _name;
}; };
class OSG_EXPORT WindowingSystemInterfaces : public osg::Referenced
{
public:
WindowingSystemInterfaces();
/** Set the query the windowing system for screens and create graphics context - this functor should be supplied by the windows toolkit. */ typedef std::vector< osg::ref_ptr<GraphicsContext::WindowingSystemInterface> > Interfaces;
static void setWindowingSystemInterface(WindowingSystemInterface* wsInterface);
/** Get the WindowingSystemInterface*/ Interfaces& getInterfaces() { return _interfaces; }
static WindowingSystemInterface* getWindowingSystemInterface();
void addWindowingSystemInterface(WindowingSystemInterface* wsInterface);
void removeWindowingSystemInterface(WindowingSystemInterface* wsInterface);
/** get named WindowingSystemInterface if one is available, otherwise return 0; */
WindowingSystemInterface* getWindowingSystemInterface(const std::string& name = "");
private:
virtual ~WindowingSystemInterfaces();
Interfaces _interfaces;
};
static osg::ref_ptr<WindowingSystemInterfaces>& getWindowingSystemInterfaces();
/** Get the default WindowingSystemInterface for this OS*/
static WindowingSystemInterface* getWindowingSystemInterface(const std::string& name = "");
/** Create a graphics context for a specified set of traits.*/ /** Create a graphics context for a specified set of traits.*/
static GraphicsContext* createGraphicsContext(Traits* traits); static GraphicsContext* createGraphicsContext(Traits* traits);
@ -544,6 +573,30 @@ public:
GLsync _previousSync; GLsync _previousSync;
}; };
template<class T>
struct WindowingSystemInterfaceProxy
{
WindowingSystemInterfaceProxy(const std::string& name)
{
_wsi = new T;
_wsi->setName(name);
osg::GraphicsContext::getWindowingSystemInterfaces()->addWindowingSystemInterface(_wsi.get());
}
~WindowingSystemInterfaceProxy()
{
osg::GraphicsContext::getWindowingSystemInterfaces()->removeWindowingSystemInterface(_wsi.get());
}
osg::ref_ptr<T> _wsi;
};
#define REGISTER_WINDOWINGSYSTEMINTERFACE(ext, classname) \
extern "C" void graphicswindow_##ext(void) {} \
static osg::WindowingSystemInterfaceProxy<classname> s_proxy_##classname(#ext);
} }
#endif #endif

View File

@ -39,8 +39,10 @@ namespace osgQt
// forward declarations // forward declarations
class GraphicsWindowQt; class GraphicsWindowQt;
#if 0
/// The function sets the WindowingSystem to Qt. /// The function sets the WindowingSystem to Qt.
void OSGQT_EXPORT initQtWindowingSystem(); void OSGQT_EXPORT initQtWindowingSystem();
#endif
/** The function sets the viewer that will be used after entering /** The function sets the viewer that will be used after entering
* the Qt main loop (QCoreApplication::exec()). * the Qt main loop (QCoreApplication::exec()).
@ -69,7 +71,7 @@ public:
inline bool getForwardKeyEvents() const { return _forwardKeyEvents; } inline bool getForwardKeyEvents() const { return _forwardKeyEvents; }
virtual void setForwardKeyEvents( bool f ) { _forwardKeyEvents = f; } virtual void setForwardKeyEvents( bool f ) { _forwardKeyEvents = f; }
inline bool getTouchEventsEnabled() const { return _touchEventsEnabled; } inline bool getTouchEventsEnabled() const { return _touchEventsEnabled; }
void setTouchEventsEnabled( bool e ); void setTouchEventsEnabled( bool e );

View File

@ -34,42 +34,95 @@
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <stdio.h>
using namespace osg; using namespace osg;
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
//
// WindowSystemInterfaces
//
GraphicsContext::WindowingSystemInterfaces::WindowingSystemInterfaces()
{
}
GraphicsContext::WindowingSystemInterfaces::~WindowingSystemInterfaces()
{
}
void GraphicsContext::WindowingSystemInterfaces::addWindowingSystemInterface(GraphicsContext::WindowingSystemInterface* wsi)
{
if (std::find(_interfaces.begin(), _interfaces.end(), wsi)==_interfaces.end())
{
OSG_NOTICE<<"GraphicsContext::WindowingSystemInterfaces::addWindowingSystemInterface("<<wsi<<") Name="<<wsi->getName()<<std::endl;
_interfaces.push_back(wsi);
}
}
void GraphicsContext::WindowingSystemInterfaces::removeWindowingSystemInterface(GraphicsContext::WindowingSystemInterface* wsi)
{
printf("GraphicsContext::WindowingSystemInterfaces::removeWindowingSystemInterface()\n");
Interfaces::iterator itr = std::find(_interfaces.begin(), _interfaces.end(), wsi);
if (itr!=_interfaces.end())
{
printf(" succeded GraphicsContext::WindowingSystemInterfaces::removeWindowingSystemInterface()\n");
_interfaces.erase(itr);
}
}
GraphicsContext::WindowingSystemInterface* GraphicsContext::WindowingSystemInterfaces::getWindowingSystemInterface(const std::string& name)
{
if (_interfaces.empty())
{
OSG_WARN<<"Warning: GraphicsContext::WindowingSystemInterfaces::getWindowingSystemInterface() failed, no interfaces available."<<std::endl;
return 0;
}
if (!name.empty())
{
for(Interfaces::iterator itr = _interfaces.begin();
itr != _interfaces.end();
++itr)
{
if ((*itr)->getName()==name)
{
return itr->get();
}
OSG_NOTICE<<" tried interface "<<typeid(*itr).name()<<", name= "<<(*itr)->getName()<<std::endl;
}
OSG_WARN<<"Warning: GraphicsContext::WindowingSystemInterfaces::getWindowingSystemInterface() failed, no interfaces matches name : "<<name<<std::endl;
return 0;
}
else
{
// no preference provided so just take the first available interface
return _interfaces.front().get();
}
}
// Use a static reference pointer to hold the window system interface. // Use a static reference pointer to hold the window system interface.
// Wrap this within a function, in order to control the order in which // Wrap this within a function, in order to control the order in which
// the static pointer's constructor is executed. // the static pointer's constructor is executed.
osg::ref_ptr<GraphicsContext::WindowingSystemInterfaces>& GraphicsContext::getWindowingSystemInterfaces()
static ref_ptr<GraphicsContext::WindowingSystemInterface> &windowingSystemInterfaceRef()
{ {
static ref_ptr<GraphicsContext::WindowingSystemInterface> s_WindowingSystemInterface; static ref_ptr<GraphicsContext::WindowingSystemInterfaces> s_WindowingSystemInterface = new GraphicsContext::WindowingSystemInterfaces;
return s_WindowingSystemInterface; return s_WindowingSystemInterface;
} }
OSG_INIT_SINGLETON_PROXY(ProxyInitWindowingSystemInterfaces, GraphicsContext::getWindowingSystemInterfaces())
// GraphicsContext static method implementations // GraphicsContext static method implementations
GraphicsContext::WindowingSystemInterface* GraphicsContext::getWindowingSystemInterface(const std::string& name)
void GraphicsContext::setWindowingSystemInterface(WindowingSystemInterface* callback)
{ {
ref_ptr<GraphicsContext::WindowingSystemInterface> &wsref = windowingSystemInterfaceRef(); return GraphicsContext::getWindowingSystemInterfaces()->getWindowingSystemInterface(name);
wsref = callback;
OSG_INFO<<"GraphicsContext::setWindowingSystemInterface() "<<wsref.get()<<"\t"<<&wsref<<std::endl;
}
GraphicsContext::WindowingSystemInterface* GraphicsContext::getWindowingSystemInterface()
{
ref_ptr<GraphicsContext::WindowingSystemInterface> &wsref = windowingSystemInterfaceRef();
OSG_INFO<<"GraphicsContext::getWindowingSystemInterface() "<<wsref.get()<<"\t"<<&wsref<<std::endl;
return wsref.get();
} }
GraphicsContext* GraphicsContext::createGraphicsContext(Traits* traits) GraphicsContext* GraphicsContext::createGraphicsContext(Traits* traits)
{ {
ref_ptr<GraphicsContext::WindowingSystemInterface> &wsref = windowingSystemInterfaceRef(); ref_ptr<GraphicsContext::WindowingSystemInterface> wsref = getWindowingSystemInterface(traits ? traits->windowingSystemPreference : "") ;
if ( wsref.valid()) if ( wsref.valid())
{ {
// catch any undefined values. // catch any undefined values.

View File

@ -125,7 +125,7 @@ public:
osg::observer_ptr< osgViewer::ViewerBase > _viewer; osg::observer_ptr< osgViewer::ViewerBase > _viewer;
virtual ~HeartBeat(); virtual ~HeartBeat();
void init( osgViewer::ViewerBase *viewer ); void init( osgViewer::ViewerBase *viewer );
void stopTimer(); void stopTimer();
void timerEvent( QTimerEvent *event ); void timerEvent( QTimerEvent *event );
@ -869,7 +869,6 @@ void GraphicsWindowQt::requestWarpPointer( float x, float y )
QCursor::setPos( _widget->mapToGlobal(QPoint((int)x,(int)y)) ); QCursor::setPos( _widget->mapToGlobal(QPoint((int)x,(int)y)) );
} }
class QtWindowingSystem : public osg::GraphicsContext::WindowingSystemInterface class QtWindowingSystem : public osg::GraphicsContext::WindowingSystemInterface
{ {
public: public:
@ -945,6 +944,9 @@ private:
QtWindowingSystem& operator=( const QtWindowingSystem& ); QtWindowingSystem& operator=( const QtWindowingSystem& );
}; };
#if 1
REGISTER_WINDOWINGSYSTEMINTERFACE(Qt, QtWindowingSystem)
#else
// declare C entry point for static compilation. // declare C entry point for static compilation.
extern "C" void OSGQT_EXPORT graphicswindow_Qt(void) extern "C" void OSGQT_EXPORT graphicswindow_Qt(void)
@ -957,7 +959,7 @@ void osgQt::initQtWindowingSystem()
{ {
graphicswindow_Qt(); graphicswindow_Qt();
} }
#endif
void osgQt::setViewer( osgViewer::ViewerBase *viewer ) void osgQt::setViewer( osgViewer::ViewerBase *viewer )

View File

@ -8,7 +8,7 @@
*/ */
#ifdef __APPLE__ #ifdef __APPLE__
#ifndef DARWIN_UTILS_HEADER_ #ifndef DARWIN_UTILS_HEADER_
#define DARWIN_UTILS_HEADER_ #define DARWIN_UTILS_HEADER_
@ -31,37 +31,37 @@ namespace osgDarwin {
/** the MenubarController class checks all open windows if they intersect with the menubar / dock and hide the menubar/dock if necessary */ /** the MenubarController class checks all open windows if they intersect with the menubar / dock and hide the menubar/dock if necessary */
class MenubarController : public osg::Referenced class MenubarController : public osg::Referenced
{ {
public: public:
class WindowAdapter : public osg::Referenced { class WindowAdapter : public osg::Referenced {
public: public:
WindowAdapter() : osg::Referenced() {} WindowAdapter() : osg::Referenced() {}
virtual bool valid() = 0; virtual bool valid() = 0;
virtual void getWindowBounds(CGRect& rect) = 0; virtual void getWindowBounds(CGRect& rect) = 0;
virtual osgViewer::GraphicsWindow* getWindow() = 0; virtual osgViewer::GraphicsWindow* getWindow() = 0;
protected: protected:
virtual ~WindowAdapter() {} virtual ~WindowAdapter() {}
}; };
MenubarController(); MenubarController();
static MenubarController* instance(); static MenubarController* instance();
void attachWindow(WindowAdapter* win); void attachWindow(WindowAdapter* win);
void update(); void update();
void detachWindow(osgViewer::GraphicsWindow* win); void detachWindow(osgViewer::GraphicsWindow* win);
void setDisplaySettings(osg::DisplaySettings* display_settings); void setDisplaySettings(osg::DisplaySettings* display_settings);
protected: protected:
~MenubarController(); ~MenubarController();
private: private:
typedef std::list< osg::ref_ptr< WindowAdapter > > WindowList; typedef std::list< osg::ref_ptr< WindowAdapter > > WindowList;
WindowList _list; WindowList _list;
bool _menubarShown; bool _menubarShown;
@ -69,7 +69,7 @@ class MenubarController : public osg::Referenced
CGRect _mainScreenBounds; CGRect _mainScreenBounds;
OpenThreads::Mutex _mutex; OpenThreads::Mutex _mutex;
MenubarToggler* _toggler; MenubarToggler* _toggler;
}; };
@ -91,25 +91,25 @@ struct DarwinWindowingSystemInterface : public osg::GraphicsContext::WindowingSy
virtual void getScreenSettings(const osg::GraphicsContext::ScreenIdentifier& si, osg::GraphicsContext::ScreenSettings & resolution); virtual void getScreenSettings(const osg::GraphicsContext::ScreenIdentifier& si, osg::GraphicsContext::ScreenSettings & resolution);
virtual void enumerateScreenSettings(const osg::GraphicsContext::ScreenIdentifier& screenIdentifier, osg::GraphicsContext::ScreenSettingsList & resolutionList); virtual void enumerateScreenSettings(const osg::GraphicsContext::ScreenIdentifier& screenIdentifier, osg::GraphicsContext::ScreenSettingsList & resolutionList);
virtual bool setScreenSettings (const osg::GraphicsContext::ScreenIdentifier & si, const osg::GraphicsContext::ScreenSettings & settings); virtual bool setScreenSettings (const osg::GraphicsContext::ScreenIdentifier & si, const osg::GraphicsContext::ScreenSettings & settings);
/** return the top left coord of a specific screen in global screen space */ /** return the top left coord of a specific screen in global screen space */
void getScreenTopLeft(const osg::GraphicsContext::ScreenIdentifier& si, int& x, int& y); void getScreenTopLeft(const osg::GraphicsContext::ScreenIdentifier& si, int& x, int& y);
/** returns screen-ndx containing rect x,y,w,h */ /** returns screen-ndx containing rect x,y,w,h */
unsigned int getScreenContaining(int x, int y, int w, int h); unsigned int getScreenContaining(int x, int y, int w, int h);
virtual void setDisplaySettings(osg::DisplaySettings* display_settings) { virtual void setDisplaySettings(osg::DisplaySettings* display_settings) {
MenubarController::instance()->setDisplaySettings(display_settings); MenubarController::instance()->setDisplaySettings(display_settings);
} }
protected: protected:
virtual void _init(); virtual void _init();
template<class PixelBufferImplementation, class GraphicsWindowImplementation> template<class PixelBufferImplementation, class GraphicsWindowImplementation>
osg::GraphicsContext* createGraphicsContextImplementation(osg::GraphicsContext::Traits* traits) osg::GraphicsContext* createGraphicsContextImplementation(osg::GraphicsContext::Traits* traits)
{ {
@ -136,6 +136,7 @@ struct DarwinWindowingSystemInterface : public osg::GraphicsContext::WindowingSy
}; };
#if 0
template <class WSI> template <class WSI>
struct RegisterWindowingSystemInterfaceProxy struct RegisterWindowingSystemInterfaceProxy
{ {
@ -155,7 +156,7 @@ struct RegisterWindowingSystemInterfaceProxy
osg::GraphicsContext::setWindowingSystemInterface(0); osg::GraphicsContext::setWindowingSystemInterface(0);
} }
}; };
#endif
} }

View File

@ -1100,15 +1100,19 @@ public:
} }
#if 1
REGISTER_WINDOWINGSYSTEMINTERFACE(Carbon, osgViewer::CarbonWindowingSystemInterface)
#else
#ifdef USE_DARWIN_CARBON_IMPLEMENTATION #ifdef USE_DARWIN_CARBON_IMPLEMENTATION
RegisterWindowingSystemInterfaceProxy<CarbonWindowingSystemInterface> createWindowingSystemInterfaceProxy; RegisterWindowingSystemInterfaceProxy<CarbonWindowingSystemInterface> createWindowingSystemInterfaceProxy;
#endif #endif
// declare C entry point for static compilation. // declare C entry point for static compilation.
extern "C" void graphicswindow_Carbon(void) extern "C" void graphicswindow_Carbon(void)
{ {
osg::GraphicsContext::setWindowingSystemInterface(new osgViewer::CarbonWindowingSystemInterface()); osg::GraphicsContext::setWindowingSystemInterface(new osgViewer::CarbonWindowingSystemInterface());
} }
#endif
#endif #endif

View File

@ -1829,6 +1829,9 @@ private:
} }
#if 1
REGISTER_WINDOWINGSYSTEMINTERFACE(Cocoa, osgViewer::CocoaWindowingSystemInterface)
#else
#ifdef USE_DARWIN_COCOA_IMPLEMENTATION #ifdef USE_DARWIN_COCOA_IMPLEMENTATION
RegisterWindowingSystemInterfaceProxy<osgViewer::CocoaWindowingSystemInterface> createWindowingSystemInterfaceProxy; RegisterWindowingSystemInterfaceProxy<osgViewer::CocoaWindowingSystemInterface> createWindowingSystemInterfaceProxy;
#endif #endif
@ -1838,3 +1841,4 @@ extern "C" void graphicswindow_Cocoa(void)
{ {
osg::GraphicsContext::setWindowingSystemInterface(new osgViewer::CocoaWindowingSystemInterface()); osg::GraphicsContext::setWindowingSystemInterface(new osgViewer::CocoaWindowingSystemInterface());
} }
#endif

View File

@ -1226,7 +1226,9 @@ public:
}//end namspace }//end namspace
#if 1
REGISTER_WINDOWINGSYSTEMINTERFACE(IOS, osgViewer::ConcreteIOSWindowingSystemInterface)
#else
RegisterWindowingSystemInterfaceProxy<osgViewer::ConcreteIOSWindowingSystemInterface> createWindowingSystemInterfaceProxy; RegisterWindowingSystemInterfaceProxy<osgViewer::ConcreteIOSWindowingSystemInterface> createWindowingSystemInterfaceProxy;
@ -1235,3 +1237,4 @@ extern "C" void graphicswindow_IOS(void)
{ {
osg::GraphicsContext::setWindowingSystemInterface(new osgViewer::ConcreteIOSWindowingSystemInterface()); osg::GraphicsContext::setWindowingSystemInterface(new osgViewer::ConcreteIOSWindowingSystemInterface());
} }
#endif

View File

@ -317,14 +317,16 @@ class Win32WindowingSystem : public osg::GraphicsContext::WindowingSystemInterfa
static std::string osgGraphicsWindowWithCursorClass; //!< Name of Win32 window class (with cursor) used by OSG graphics window instances static std::string osgGraphicsWindowWithCursorClass; //!< Name of Win32 window class (with cursor) used by OSG graphics window instances
static std::string osgGraphicsWindowWithoutCursorClass; //!< Name of Win32 window class (without cursor) used by OSG graphics window instances static std::string osgGraphicsWindowWithoutCursorClass; //!< Name of Win32 window class (without cursor) used by OSG graphics window instances
Win32WindowingSystem(); Win32WindowingSystem()
~Win32WindowingSystem(); {
getInterface() = this;
}
// Access the Win32 windowing system through this singleton class. // Access the Win32 windowing system through this singleton class.
static Win32WindowingSystem* getInterface() static osg::ref_ptr<Win32WindowingSystem>& getInterface()
{ {
static Win32WindowingSystem* win32Interface = new Win32WindowingSystem; static osg::ref_ptr<Win32WindowingSystem> s_win32Interface;
return win32Interface; return s_win32Interface;
} }
// Return the number of screens present in the system // Return the number of screens present in the system
@ -368,6 +370,8 @@ class Win32WindowingSystem : public osg::GraphicsContext::WindowingSystemInterfa
protected: protected:
virtual ~Win32WindowingSystem() {}
// Display devices present in the system // Display devices present in the system
typedef std::vector<DISPLAY_DEVICE> DisplayDevices; typedef std::vector<DISPLAY_DEVICE> DisplayDevices;
@ -2273,7 +2277,7 @@ void GraphicsWindowWin32::setCursorImpl( MouseCursor mouseCursor )
_currentCursor = newCursor; _currentCursor = newCursor;
_traits->useCursor = (_currentCursor != NULL) && (_mouseCursor != NoCursor); _traits->useCursor = (_currentCursor != NULL) && (_mouseCursor != NoCursor);
PostMessage(_hwnd, WM_SETCURSOR, 0, 0); PostMessage(_hwnd, WM_SETCURSOR, 0, 0);
} }
} }
@ -2894,7 +2898,7 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Class responsible for registering the Win32 Windowing System interface // Class responsible for registering the Win32 Windowing System interface
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#if 0
struct RegisterWindowingSystemInterfaceProxy struct RegisterWindowingSystemInterfaceProxy
{ {
RegisterWindowingSystemInterfaceProxy() RegisterWindowingSystemInterfaceProxy()
@ -2915,16 +2919,19 @@ struct RegisterWindowingSystemInterfaceProxy
}; };
static RegisterWindowingSystemInterfaceProxy createWindowingSystemInterfaceProxy; static RegisterWindowingSystemInterfaceProxy createWindowingSystemInterfaceProxy;
#endif
} // namespace OsgViewer } // namespace OsgViewer
#if 1
REGISTER_WINDOWINGSYSTEMINTERFACE(Win32, Win32WindowingSystem)
#else
// declare C entry point for static compilation. // declare C entry point for static compilation.
extern "C" void OSGVIEWER_EXPORT graphicswindow_Win32(void) extern "C" void OSGVIEWER_EXPORT graphicswindow_Win32(void)
{ {
osg::GraphicsContext::setWindowingSystemInterface(osgViewer::Win32WindowingSystem::getInterface()); osg::GraphicsContext::setWindowingSystemInterface(osgViewer::Win32WindowingSystem::getInterface());
} }
#endif
void GraphicsWindowWin32::raiseWindow() void GraphicsWindowWin32::raiseWindow()
{ {

View File

@ -2144,6 +2144,12 @@ public:
}; };
#if 1
REGISTER_WINDOWINGSYSTEMINTERFACE(X11, X11WindowingSystemInterface)
#else
struct RegisterWindowingSystemInterfaceProxy struct RegisterWindowingSystemInterfaceProxy
{ {
RegisterWindowingSystemInterfaceProxy() RegisterWindowingSystemInterfaceProxy()
@ -2166,7 +2172,6 @@ struct RegisterWindowingSystemInterfaceProxy
} }
}; };
RegisterWindowingSystemInterfaceProxy createWindowingSystemInterfaceProxy; RegisterWindowingSystemInterfaceProxy createWindowingSystemInterfaceProxy;
// declare C entry point for static compilation. // declare C entry point for static compilation.
@ -2174,6 +2179,7 @@ extern "C" void graphicswindow_X11(void)
{ {
osg::GraphicsContext::setWindowingSystemInterface(new X11WindowingSystemInterface); osg::GraphicsContext::setWindowingSystemInterface(new X11WindowingSystemInterface);
} }
#endif
void GraphicsWindowX11::raiseWindow() void GraphicsWindowX11::raiseWindow()
{ {

View File

@ -11,8 +11,8 @@
* *
*/ */
#ifdef __APPLE__ #ifdef __APPLE__
#ifndef IOS_UTILS_HEADER_ #ifndef IOS_UTILS_HEADER_
#define IOS_UTILS_HEADER_ #define IOS_UTILS_HEADER_
@ -45,7 +45,7 @@ public:
virtual void getScreenSettings(const osg::GraphicsContext::ScreenIdentifier& si, osg::GraphicsContext::ScreenSettings & resolution); virtual void getScreenSettings(const osg::GraphicsContext::ScreenIdentifier& si, osg::GraphicsContext::ScreenSettings & resolution);
virtual void enumerateScreenSettings(const osg::GraphicsContext::ScreenIdentifier& screenIdentifier, osg::GraphicsContext::ScreenSettingsList & resolutionList); virtual void enumerateScreenSettings(const osg::GraphicsContext::ScreenIdentifier& screenIdentifier, osg::GraphicsContext::ScreenSettingsList & resolutionList);
virtual bool setScreenSettings (const osg::GraphicsContext::ScreenIdentifier & si, const osg::GraphicsContext::ScreenSettings & settings); virtual bool setScreenSettings (const osg::GraphicsContext::ScreenIdentifier & si, const osg::GraphicsContext::ScreenSettings & settings);
/** returns screen-ndx containing rect x,y,w,h, NOT_TESTED@tom */ /** returns screen-ndx containing rect x,y,w,h, NOT_TESTED@tom */
@ -57,12 +57,12 @@ public:
//return the UIScreen object asscoiated with the passed ScreenIdentifier //return the UIScreen object asscoiated with the passed ScreenIdentifier
//returns nil if si isn't found //returns nil if si isn't found
UIScreen* getUIScreen(const osg::GraphicsContext::ScreenIdentifier& si); UIScreen* getUIScreen(const osg::GraphicsContext::ScreenIdentifier& si);
// //
//Get the contents scale factor of the screen, this is the scale factor required //Get the contents scale factor of the screen, this is the scale factor required
//to convert points to pixels on this screen //to convert points to pixels on this screen
bool getScreenContentScaleFactor(const osg::GraphicsContext::ScreenIdentifier& si, float& scaleFactor); bool getScreenContentScaleFactor(const osg::GraphicsContext::ScreenIdentifier& si, float& scaleFactor);
// //
//Get the screens size in points, docs state a point is roughly 1/160th of an inch //Get the screens size in points, docs state a point is roughly 1/160th of an inch
bool getScreenSizeInPoints(const osg::GraphicsContext::ScreenIdentifier& si, osg::Vec2& pointSize); bool getScreenSizeInPoints(const osg::GraphicsContext::ScreenIdentifier& si, osg::Vec2& pointSize);
@ -80,11 +80,12 @@ protected:
private: private:
}; };
#if 0
template <class WSI> template <class WSI>
struct RegisterWindowingSystemInterfaceProxy struct RegisterWindowingSystemInterfaceProxy
{ {
@ -104,7 +105,7 @@ struct RegisterWindowingSystemInterfaceProxy
osg::GraphicsContext::setWindowingSystemInterface(0); osg::GraphicsContext::setWindowingSystemInterface(0);
} }
}; };
#endif
} }