PixelBufferCocoa
Go to the documentation of this file.
/* -*-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 OSGVIEWER_PIXELBUFFERCOCOA
#define OSGVIEWER_PIXELBUFFERCOCOA 1
#ifdef __APPLE__
#include <osg/GraphicsContext>
#include <osgViewer/Export>
#include <osgViewer/api/Cocoa/GraphicsHandleCocoa>
namespace osgViewer
{
class OSGVIEWER_EXPORT PixelBufferCocoa : public osg::GraphicsContext, public osgViewer::GraphicsHandleCocoa
{
public:
struct Implementation;
PixelBufferCocoa(osg::GraphicsContext::Traits* traits):
osg::GraphicsContext(),
osgViewer::GraphicsHandleCocoa(),
_valid(false),
_initialized(false),
_realized(false),
_context(NULL)
{
_traits = traits;
init();
if (valid())
{
setState( new osg::State );
getState()->setGraphicsContext(this);
if (_traits.valid() && _traits->sharedContext.valid())
{
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
}
else
{
getState()->setContextID( osg::GraphicsContext::createNewContextID() );
}
}
}
virtual bool isSameKindAs(const Object* object) const { return dynamic_cast<const PixelBufferCocoa*>(object)!=0; }
virtual const char* libraryName() const { return "osgViewer"; }
virtual const char* className() const { return "PixelBufferCarbon"; }
virtual bool valid() const { return _valid; }
virtual bool realizeImplementation();
virtual bool isRealizedImplementation() const { return _realized; }
virtual void closeImplementation();
virtual bool makeCurrentImplementation();
virtual bool makeContextCurrentImplementation(osg::GraphicsContext* readContext);
virtual bool releaseContextImplementation();
virtual void bindPBufferToTextureImplementation( GLenum buffer );
virtual void swapBuffersImplementation();
NSOpenGLContext* getContext() { return _context; }
public:
protected:
~PixelBufferCocoa();
void init();
bool _valid;
bool _initialized;
bool _realized;
NSOpenGLContext* _context;
};
}
#endif
#endif
GraphicsContext
GraphicsHandleCocoa
osgViewer::GraphicsHandleCocoa
Definition GraphicsHandleCocoa:34
osg::GraphicsContext
Definition GraphicsContext:30
osg::GraphicsContext::createNewContextID
static unsigned int createNewContextID()
osg::State
Definition State:80
osgViewer
Export
OSGVIEWER_EXPORT
#define OSGVIEWER_EXPORT
Definition osgViewer/Export:40
NULL
#define NULL
Definition osg/Export:55
osg::GraphicsContext::Traits
Definition GraphicsContext:70