2006-07-18 23:21:48 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2005-07-22 03:37:44 +08:00
|
|
|
*
|
|
|
|
* 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 OSGPRODUCER_GRAPHICSCONTEXTIMPLEMENTATION
|
|
|
|
#define OSGPRODUCER_GRAPHICSCONTEXTIMPLEMENTATION 1
|
|
|
|
|
|
|
|
|
|
|
|
#include <osg/GraphicsContext>
|
|
|
|
|
|
|
|
#include <Producer/RenderSurface>
|
|
|
|
|
|
|
|
#include <osgProducer/Export>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace osgProducer {
|
|
|
|
|
|
|
|
class OSGPRODUCER_EXPORT GraphicsContextImplementation : public osg::GraphicsContext
|
|
|
|
{
|
|
|
|
public :
|
|
|
|
|
|
|
|
/** Construct a graphics context to specified traits.*/
|
|
|
|
GraphicsContextImplementation(Traits* traits);
|
|
|
|
|
|
|
|
/** Construct a graphics context with specified RenderSurface.*/
|
|
|
|
GraphicsContextImplementation(Producer::RenderSurface* rs);
|
|
|
|
|
|
|
|
/** Return true of graphics context is realized.*/
|
|
|
|
|
|
|
|
/** Return the RenderSurface that implements the graphics context.*/
|
|
|
|
Producer::RenderSurface* getRenderSurface() { return _rs.get(); }
|
|
|
|
|
|
|
|
/** Return the const RenderSurface that implements the graphics context.*/
|
|
|
|
const Producer::RenderSurface* getRenderSurface() const { return _rs.get(); }
|
|
|
|
|
|
|
|
|
2005-08-16 21:29:07 +08:00
|
|
|
/** Realise the GraphicsContext.*/
|
2005-08-20 16:59:03 +08:00
|
|
|
virtual bool realizeImplementation();
|
2005-08-16 21:29:07 +08:00
|
|
|
|
|
|
|
/** Return true if the graphics context has been realised and is ready to use.*/
|
2005-08-20 16:59:03 +08:00
|
|
|
virtual bool isRealizedImplementation() const { return _rs.valid() && _rs->isRealized(); }
|
2005-08-16 21:29:07 +08:00
|
|
|
|
2005-08-31 03:03:02 +08:00
|
|
|
/** Close the graphics context.*/
|
2005-08-20 16:59:03 +08:00
|
|
|
virtual void closeImplementation();
|
2005-07-22 03:37:44 +08:00
|
|
|
|
|
|
|
/** Make this graphics context current.*/
|
2005-08-19 04:17:51 +08:00
|
|
|
virtual void makeCurrentImplementation();
|
2005-07-22 03:37:44 +08:00
|
|
|
|
|
|
|
/** Make this graphics context current with specified read context.*/
|
2005-10-26 17:22:13 +08:00
|
|
|
virtual void makeContextCurrentImplementation(osg::GraphicsContext* readContext);
|
2005-07-22 03:37:44 +08:00
|
|
|
|
|
|
|
/** Bind the graphics context to associated texture.*/
|
2005-08-20 16:59:03 +08:00
|
|
|
virtual void bindPBufferToTextureImplementation(GLenum buffer);
|
2005-07-22 03:37:44 +08:00
|
|
|
|
|
|
|
/** swap the front and back buffers.*/
|
2005-08-20 16:59:03 +08:00
|
|
|
virtual void swapBuffersImplementation();
|
2005-07-22 03:37:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~GraphicsContextImplementation();
|
|
|
|
|
2005-08-30 22:41:08 +08:00
|
|
|
bool _closeOnDestruction;
|
2005-07-22 03:37:44 +08:00
|
|
|
osg::ref_ptr<Producer::RenderSurface> _rs;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|