2006-10-05 18:06:19 +08:00
|
|
|
/* -*-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.
|
|
|
|
*/
|
|
|
|
|
2006-11-02 20:27:15 +08:00
|
|
|
#ifndef OSGVIEWER_GRAPHICWINDOW
|
|
|
|
#define OSGVIEWER_GRAPHICWINDOW 1
|
2006-10-05 18:06:19 +08:00
|
|
|
|
|
|
|
#include <osg/GraphicsContext>
|
|
|
|
#include <osg/Notify>
|
|
|
|
|
|
|
|
#include <osgGA/EventQueue>
|
2006-11-29 04:35:31 +08:00
|
|
|
#include <osgGA/GUIActionAdapter>
|
2006-10-05 18:06:19 +08:00
|
|
|
|
2006-11-02 20:27:15 +08:00
|
|
|
#include <osgViewer/Export>
|
|
|
|
|
|
|
|
namespace osgViewer {
|
2006-10-05 18:06:19 +08:00
|
|
|
|
|
|
|
/** 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. */
|
2006-11-02 20:27:15 +08:00
|
|
|
class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgGA::GUIActionAdapter
|
2006-10-05 18:06:19 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
GraphicsWindow() { _eventQueue = new osgGA::EventQueue; }
|
|
|
|
|
2007-01-09 00:20:10 +08:00
|
|
|
|
2006-10-05 18:06:19 +08:00
|
|
|
void setEventQueue(osgGA::EventQueue* eventQueue) { _eventQueue = eventQueue; }
|
|
|
|
osgGA::EventQueue* getEventQueue() { return _eventQueue.get(); }
|
|
|
|
const osgGA::EventQueue* getEventQueue() const { return _eventQueue.get(); }
|
|
|
|
|
2006-12-21 05:13:29 +08:00
|
|
|
virtual void checkEvents() {}
|
|
|
|
|
2006-12-21 19:20:42 +08:00
|
|
|
/** 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() {}
|
|
|
|
|
2007-01-02 20:50:57 +08:00
|
|
|
/** Switch on/off the cursor.*/
|
|
|
|
virtual void useCursor(bool /*cursorOn*/) {}
|
|
|
|
|
2006-10-05 18:06:19 +08:00
|
|
|
public:
|
|
|
|
|
2007-01-09 00:20:10 +08:00
|
|
|
/** Return whether a valid and usable GraphicsContext has been created.*/
|
|
|
|
virtual bool valid() const { osg::notify(osg::NOTICE)<<"GraphicsWindow::realizeImplementation() not implemented."<<std::endl; return false; }
|
|
|
|
|
2006-10-05 18:06:19 +08:00
|
|
|
/** 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."<<std::endl; return false; }
|
|
|
|
|
|
|
|
/** Return true if the graphics context has been realised, and is ready to use, implementation.
|
|
|
|
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
|
|
|
|
virtual bool isRealizedImplementation() const { osg::notify(osg::NOTICE)<<"GraphicsWindow::isRealizedImplementation() not implemented."<<std::endl; return false; }
|
|
|
|
|
|
|
|
/** Close the graphics context implementation.
|
|
|
|
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
|
|
|
|
virtual void closeImplementation() { osg::notify(osg::NOTICE)<<"GraphicsWindow::closeImplementation() not implemented."<<std::endl; }
|
|
|
|
|
|
|
|
/** Make this graphics context current implementation.
|
|
|
|
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
|
2007-01-09 03:29:59 +08:00
|
|
|
virtual bool makeCurrentImplementation() { osg::notify(osg::NOTICE)<<"GraphicsWindow::makeCurrentImplementation() not implemented."<<std::endl; return false;}
|
2006-10-05 18:06:19 +08:00
|
|
|
|
|
|
|
/** Make this graphics context current with specified read context implementation.
|
|
|
|
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
|
2007-01-09 03:29:59 +08:00
|
|
|
virtual bool makeContextCurrentImplementation(GraphicsContext* /*readContext*/) { osg::notify(osg::NOTICE)<<"GraphicsWindow::makeContextCurrentImplementation(..) not implemented."<<std::endl; return false;}
|
|
|
|
|
|
|
|
/** Release the graphics context.*/
|
|
|
|
virtual bool releaseContextImplementation() { osg::notify(osg::NOTICE)<<"GraphicsWindow::releaseContextImplementation(..) not implemented."<<std::endl; return false; }
|
2006-10-05 18:06:19 +08:00
|
|
|
|
|
|
|
/** Pure virtual, Bind the graphics context to associated texture implementation.
|
|
|
|
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
|
2007-01-09 03:29:59 +08:00
|
|
|
virtual void bindPBufferToTextureImplementation(GLenum /*buffer*/) { osg::notify(osg::NOTICE)<<"GraphicsWindow::bindPBufferToTextureImplementation(..) not implemented."<<std::endl; }
|
2006-10-05 18:06:19 +08:00
|
|
|
|
|
|
|
/** Swap the front and back buffers implementation.
|
|
|
|
* Pure virtual - must be implemented by Concrate implementations of GraphicsContext. */
|
|
|
|
virtual void swapBuffersImplementation() { osg::notify(osg::NOTICE)<<"GraphicsWindow:: swapBuffersImplementation() not implemented."<<std::endl; }
|
|
|
|
|
|
|
|
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*/) {}
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
osg::ref_ptr<osgGA::EventQueue> _eventQueue;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|