diff --git a/include/osgGA/GraphicsWindow b/include/osgGA/GraphicsWindow new file mode 100644 index 000000000..df7658e3a --- /dev/null +++ b/include/osgGA/GraphicsWindow @@ -0,0 +1,91 @@ +/* -*-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. +*/ + +#ifndef OSG_GRAPHICWINDOW +#define OSG_GRAPHICWINDOW 1 + +#include +#include + +#include + +namespace osgGA { + +/** Base class for providing Windowing API agnostic access to creating and managing graphisc window and events. + * Note, the GraphicsWindow is subclassed from osg::GraphicsContext, and to provide an implemention you'll need to implement its + * range of pure virtual functions, you'll find these all have naming convention methodNameImplemention(..). + * GraphicsWindow adds the event queue ontop of the GraphicsContext, thereby adding a mechnism for adapting Windowing events + * as well as basics graphics context work, you should wire up custom GraphicsWindowImplementation to push their events through + * into the EventQueue. */ +class OSGGA_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgGA::GUIActionAdapter +{ + public: + + GraphicsWindow() { _eventQueue = new osgGA::EventQueue; } + + void setEventQueue(osgGA::EventQueue* eventQueue) { _eventQueue = eventQueue; } + osgGA::EventQueue* getEventQueue() { return _eventQueue.get(); } + const osgGA::EventQueue* getEventQueue() const { return _eventQueue.get(); } + + public: + + /** 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."< _eventQueue; + +}; + + +} + +#endif diff --git a/include/osgGA/SimpleViewer b/include/osgGA/SimpleViewer index 2ecbcdec9..f8ccf45fd 100644 --- a/include/osgGA/SimpleViewer +++ b/include/osgGA/SimpleViewer @@ -14,9 +14,9 @@ #ifndef OSGGA_SimpleViewer #define OSGGA_SimpleViewer 1 -#include #include #include +#include #include @@ -25,7 +25,7 @@ namespace osgGA{ /** SimpleViewer provide a simple interface for setting up rendering of an scene graph, using a single camera view within a single window.*/ -class OSGGA_EXPORT SimpleViewer : public osgGA::GUIActionAdapter, public osg::Referenced +class OSGGA_EXPORT SimpleViewer : public virtual osgGA::GraphicsWindow { public: @@ -50,9 +50,6 @@ class OSGGA_EXPORT SimpleViewer : public osgGA::GUIActionAdapter, public osg::Re EventHandlers& getEventHandlers() { return _eventHandlers; } const EventHandlers& getEventHandlers() const { return _eventHandlers; } - EventQueue* getEventQueue() { return _eventQueue.get(); } - const EventQueue* getEventQueue() const { return _eventQueue.get(); } - void setDatabasePager(osgDB::DatabasePager* dp); osgDB::DatabasePager* getDatabasePager() { return _databasePager.get(); } const osgDB::DatabasePager* getDatabasePager() const { return _databasePager.get(); } @@ -77,15 +74,6 @@ class OSGGA_EXPORT SimpleViewer : public osgGA::GUIActionAdapter, public osg::Re public: - // Override from GUIActionAdapter - virtual void requestRedraw() {} - - // Override from GUIActionAdapter - virtual void requestContinuousUpdate(bool /*needed*/=true) {} - - // Override from GUIActionAdapter - virtual void requestWarpPointer(float /*x*/,float /*y*/) {} - osgUtil::SceneView* getSceneView() { return _sceneView.get(); } const osgUtil::SceneView* getSceneView() const { return _sceneView.get(); } @@ -100,8 +88,6 @@ class OSGGA_EXPORT SimpleViewer : public osgGA::GUIActionAdapter, public osg::Re osg::ref_ptr _sceneView; - osg::ref_ptr _eventQueue; - osg::ref_ptr _cameraManipulator; EventHandlers _eventHandlers; diff --git a/src/osgGA/SimpleViewer.cpp b/src/osgGA/SimpleViewer.cpp index d7b541e68..ab7a52659 100644 --- a/src/osgGA/SimpleViewer.cpp +++ b/src/osgGA/SimpleViewer.cpp @@ -27,8 +27,7 @@ SimpleViewer::SimpleViewer(): _frameStamp = new osg::FrameStamp; _frameStamp->setFrameNumber(0); _frameStamp->setReferenceTime(0); - - _eventQueue = new osgGA::EventQueue; + _eventQueue->setStartTick(_startTick); _eventVisitor = new osgGA::EventVisitor;