From cc1ab2c71161ee2136ece5187b951217e40194f1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 10 Apr 2007 11:03:37 +0000 Subject: [PATCH] Create new incliude/osgViewer/api directory to hold platform specific classes such as GraphicsWindow implementations. Moved GraphicsWindowWin32,X11 and Carbon into their api/Win32, api/X11 and api/Carbon directories. --- include/osgViewer/GraphicsWindowCocoa | 92 --------- .../{ => api/Carbon}/GraphicsWindowCarbon | 0 .../{ => api/Win32}/GraphicsWindowWin32 | 0 .../osgViewer/{ => api/X11}/GraphicsWindowX11 | 0 src/osgViewer/CMakeLists.txt | 7 +- src/osgViewer/GraphicsWindowCarbon.cpp | 2 +- src/osgViewer/GraphicsWindowCocoa.cpp | 188 ------------------ src/osgViewer/GraphicsWindowWin32.cpp | 2 +- src/osgViewer/GraphicsWindowX11.cpp | 2 +- 9 files changed, 6 insertions(+), 287 deletions(-) delete mode 100644 include/osgViewer/GraphicsWindowCocoa rename include/osgViewer/{ => api/Carbon}/GraphicsWindowCarbon (100%) rename include/osgViewer/{ => api/Win32}/GraphicsWindowWin32 (100%) rename include/osgViewer/{ => api/X11}/GraphicsWindowX11 (100%) delete mode 100644 src/osgViewer/GraphicsWindowCocoa.cpp diff --git a/include/osgViewer/GraphicsWindowCocoa b/include/osgViewer/GraphicsWindowCocoa deleted file mode 100644 index fca85a3bf..000000000 --- a/include/osgViewer/GraphicsWindowCocoa +++ /dev/null @@ -1,92 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield - * - * This library is open source and may be redistributed and/or modified under - * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or - * (at your option) any later version. The full license is in LICENSE file - * included with this distribution, and on the openscenegraph.org website. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * OpenSceneGraph Public License for more details. -*/ - -/* Note, elements of GraphicsWindowX11 have used Prodcer/RenderSurface_X11.cpp as both - * a guide to use of X11/GLX and copiying directly in the case of setBorder(). - * These elements are license under OSGPL as above, with Copyright (C) 2001-2004 Don Burns. - */ - -#ifndef OSGVIEWER_GRAPHICSWINDOWCOCOA -#define OSGVIEWER_GRAPHICSWINDOWCOCOA 1 - -#include - -namespace osgViewer -{ - -class GraphicsWindowCocoa : public osgViewer::GraphicsWindow -{ - public: - - GraphicsWindowCocoa(osg::GraphicsContext::Traits* traits): - _valid(false), - _initialized(false), - _realized(false) - { - _traits = traits; - - init(); - - if (valid()) - { - setState( new osg::State ); - getState()->setContextID( osg::GraphicsContext::createNewContextID() ); - } - } - - virtual bool valid() const { return _valid; } - - /** Realise the GraphicsContext.*/ - virtual bool realizeImplementation(); - - /** Return true if the graphics context has been realised and is ready to use.*/ - virtual bool isRealizedImplementation() const { return _realized; } - - /** Close the graphics context.*/ - virtual void closeImplementation(); - - /** Make this graphics context current.*/ - virtual bool makeCurrentImplementation(); - - /** Release the graphics context.*/ - virtual bool releaseContextImplementation(); - - /** Swap the front and back buffers.*/ - virtual void swapBuffersImplementation(); - - /** Check to see if any events have been generated.*/ - virtual void checkEvents(); - - /** Set Window decoration.*/ - virtual void setWindowDecoration(bool flag); - - /** Get focus.*/ - virtual void grabFocus(); - - /** Get focus on if the pointer is in this window.*/ - virtual void grabFocusIfPointerInWindow(); - - protected: - - void init(); - - void transformMouseXY(float& x, float& y); - - bool _valid; - bool _initialized; - bool _realized; -}; - -} - -#endif diff --git a/include/osgViewer/GraphicsWindowCarbon b/include/osgViewer/api/Carbon/GraphicsWindowCarbon similarity index 100% rename from include/osgViewer/GraphicsWindowCarbon rename to include/osgViewer/api/Carbon/GraphicsWindowCarbon diff --git a/include/osgViewer/GraphicsWindowWin32 b/include/osgViewer/api/Win32/GraphicsWindowWin32 similarity index 100% rename from include/osgViewer/GraphicsWindowWin32 rename to include/osgViewer/api/Win32/GraphicsWindowWin32 diff --git a/include/osgViewer/GraphicsWindowX11 b/include/osgViewer/api/X11/GraphicsWindowX11 similarity index 100% rename from include/osgViewer/GraphicsWindowX11 rename to include/osgViewer/api/X11/GraphicsWindowX11 diff --git a/src/osgViewer/CMakeLists.txt b/src/osgViewer/CMakeLists.txt index 1fce66f32..dcdec015d 100644 --- a/src/osgViewer/CMakeLists.txt +++ b/src/osgViewer/CMakeLists.txt @@ -22,10 +22,9 @@ SET(LIB_PUBLIC_HEADERS ) SET(LIB_PRIVATE_HEADERS - ${HEADER_PATH}/GraphicsWindowCarbon - ${HEADER_PATH}/GraphicsWindowCocoa - ${HEADER_PATH}/GraphicsWindowWin32 - ${HEADER_PATH}/GraphicsWindowX11 + ${HEADER_PATH}/api/Carbon/GraphicsWindowCarbon + ${HEADER_PATH}/api/Win32/GraphicsWindowWin32 + ${HEADER_PATH}/api/X11/GraphicsWindowX11 ) SET(LIB_COMMON_FILES diff --git a/src/osgViewer/GraphicsWindowCarbon.cpp b/src/osgViewer/GraphicsWindowCarbon.cpp index 6842da1c6..55b2a2c6f 100644 --- a/src/osgViewer/GraphicsWindowCarbon.cpp +++ b/src/osgViewer/GraphicsWindowCarbon.cpp @@ -13,7 +13,7 @@ #ifdef __APPLE__ #include -#include +#include #include #include using namespace osgViewer; diff --git a/src/osgViewer/GraphicsWindowCocoa.cpp b/src/osgViewer/GraphicsWindowCocoa.cpp deleted file mode 100644 index 261e8d6c4..000000000 --- a/src/osgViewer/GraphicsWindowCocoa.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield - * - * This library is open source and may be redistributed and/or modified under - * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or - * (at your option) any later version. The full license is in LICENSE file - * included with this distribution, and on the openscenegraph.org website. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * OpenSceneGraph Public License for more details. -*/ - -#include - - -using namespace osgViewer; - -namespace osgViewer -{ - -/** This is the class we need to create for pbuffers, note its not a GraphicsWindow as it won't need any of the event handling and window mapping facilities.*/ -class GraphicsContextCocoa : public osg::GraphicsContext -{ - public: - - GraphicsContextCocoa(osg::GraphicsContext::Traits* traits): - _valid(false) - { - _traits = traits; - } - - virtual bool valid() const { return _valid; } - - /** Realise the GraphicsContext implementation, - * Pure virtual - must be implemented by concrate implementations of GraphicsContext. */ - virtual bool realizeImplementation() { osg::notify(osg::NOTICE)<<"GraphicsWindow::realizeImplementation() not implemented."<getUseFixedMouseInputRange()) - { - osgGA::GUIEventAdapter* eventState = getEventQueue()->getCurrentEventState(); - x = eventState->getXmin() + (eventState->getXmax()-eventState->getXmin())*x/float(_traits->width); - y = eventState->getYmin() + (eventState->getYmax()-eventState->getYmin())*y/float(_traits->height); - } -} - -struct CocoaWindowingSystemInterface : public osg::GraphicsContext::WindowingSystemInterface -{ - - CocoaWindowingSystemInterface() - { - - } - - virtual unsigned int getNumScreens(const osg::GraphicsContext::ScreenIdentifier& si) - { - osg::notify(osg::NOTICE)<<"CocoaWindowingSystemInterface::getNumScreens() Please implement me!"<pbuffer) - { - osg::ref_ptr pbuffer = new GraphicsContextCocoa(traits); - if (pbuffer->valid()) return pbuffer.release(); - else return 0; - } - else - { - osg::ref_ptr window = new GraphicsWindowCocoa(traits); - if (window->valid()) return window.release(); - else return 0; - } - } - -}; - -struct RegisterWindowingSystemInterfaceProxy -{ - RegisterWindowingSystemInterfaceProxy() - { - osg::GraphicsContext::setWindowingSystemInterface(new CocoaWindowingSystemInterface); - } - - ~RegisterWindowingSystemInterfaceProxy() - { - osg::GraphicsContext::setWindowingSystemInterface(0); - } -}; - -RegisterWindowingSystemInterfaceProxy createWindowingSystemInterfaceProxy; diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index 2a8d5452e..f6361435d 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -16,7 +16,7 @@ * These elements are licensed under OSGPL as above, with Copyright (C) 2001-2004 Don Burns. */ -#include +#include #include #include #include diff --git a/src/osgViewer/GraphicsWindowX11.cpp b/src/osgViewer/GraphicsWindowX11.cpp index d9a41942d..38d23117c 100644 --- a/src/osgViewer/GraphicsWindowX11.cpp +++ b/src/osgViewer/GraphicsWindowX11.cpp @@ -16,7 +16,7 @@ * These elements are license under OSGPL as above, with Copyright (C) 2001-2004 Don Burns. */ -#include +#include #include #include