From c3880a25b661522cfe95a3d6c745de68929a2590 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 3 Aug 2018 17:57:45 -0400 Subject: [PATCH] Remove duplication of REGISTER_WINDOWINGSYSTEMINTERFACE code Refactor so GraphicsWindowWin32 doesn't duplicate code in . Also, add OSGVIEWER_EXPORT to X11WindowingSystemInterface so X11WindowingSystemInterface examples can build on cygwin. This change parallels that in commit 0bca415d5af4647da868888c1588b9617dbe3eb8. --- include/osg/GraphicsContext | 9 +++++++-- src/osgViewer/GraphicsWindowWin32.cpp | 3 +-- src/osgViewer/GraphicsWindowX11.cpp | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/osg/GraphicsContext b/include/osg/GraphicsContext index 33d7b0b12..875b0436a 100644 --- a/include/osg/GraphicsContext +++ b/include/osg/GraphicsContext @@ -597,10 +597,15 @@ struct WindowingSystemInterfaceProxy osg::ref_ptr _wsi; }; -#define REGISTER_WINDOWINGSYSTEMINTERFACE(ext, classname) \ - extern "C" void graphicswindow_##ext(void) {} \ +// Internal use only - compile on C90 compilers, which prohibit empty macro arguments. +#define _OSG_GRAPHICSCONTEXT_NO_ATTRIBS + +#define REGISTER_WINDOWINGSYSTEMINTERFACE2(ext, classname, attribs) \ + extern "C" attribs void graphicswindow_##ext(void) {} \ static osg::WindowingSystemInterfaceProxy s_proxy_##classname(#ext); +#define REGISTER_WINDOWINGSYSTEMINTERFACE(ext, classname) \ + REGISTER_WINDOWINGSYSTEMINTERFACE2(ext, classname, _OSG_GRAPHICSCONTEXT_NO_ATTRIBS) } #endif diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index 91e6c8f49..b38423c1b 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -3148,8 +3148,7 @@ static RegisterWindowingSystemInterfaceProxy createWindowingSystemInterfaceProxy } // namespace OsgViewer -extern "C" OSGVIEWER_EXPORT void graphicswindow_Win32(void) {} -static osg::WindowingSystemInterfaceProxy s_proxy_Win32WindowingSystem("Win32"); +REGISTER_WINDOWINGSYSTEMINTERFACE2(Win32,Win32WindowingSystem,OSGVIEWER_EXPORT) void GraphicsWindowWin32::raiseWindow() { diff --git a/src/osgViewer/GraphicsWindowX11.cpp b/src/osgViewer/GraphicsWindowX11.cpp index 9ee634219..453d38829 100644 --- a/src/osgViewer/GraphicsWindowX11.cpp +++ b/src/osgViewer/GraphicsWindowX11.cpp @@ -2277,7 +2277,7 @@ public: }; -REGISTER_WINDOWINGSYSTEMINTERFACE(X11, X11WindowingSystemInterface) +REGISTER_WINDOWINGSYSTEMINTERFACE2(X11, X11WindowingSystemInterface, OSGVIEWER_EXPORT) void GraphicsWindowX11::raiseWindow() {