1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
16#ifndef OSGVIEWER_PIXELBUFFERCARBON
17#define OSGVIEWER_PIXELBUFFERCARBON 1
19#if defined (__APPLE__) && (!__LP64__)
21#include <osg/GraphicsContext>
22#include <osgViewer/api/Carbon/GraphicsHandleCarbon>
28class OSGVIEWER_EXPORT PixelBufferCarbon : public osg::GraphicsContext, public osgViewer::GraphicsHandleCarbon
32 PixelBufferCarbon(osg::GraphicsContext::Traits* traits):
45 setState( new osg::State );
46 getState()->setGraphicsContext(this);
48 if (_traits.valid() && _traits->sharedContext.valid())
50 getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
51 incrementContextIDUsageCount( getState()->getContextID() );
55 getState()->setContextID( osg::GraphicsContext::createNewContextID() );
61 virtual bool isSameKindAs(const Object* object) const { return dynamic_cast<const PixelBufferCarbon*>(object)!=0; }
62 virtual const char* libraryName() const { return "osgViewer"; }
63 virtual const char* className() const { return "PixelBufferCarbon"; }
65 virtual bool valid() const { return _valid; }
67 /** Realise the GraphicsContext.*/
68 virtual bool realizeImplementation();
70 /** Return true if the graphics context has been realised and is ready to use.*/
71 virtual bool isRealizedImplementation() const { return _realized; }
73 /** Close the graphics context.*/
74 virtual void closeImplementation();
76 /** Make this graphics context current.*/
77 virtual bool makeCurrentImplementation();
79 /** Make this graphics context current with specified read context implementation. */
80 virtual bool makeContextCurrentImplementation(osg::GraphicsContext* readContext);
82 /** Release the graphics context.*/
83 virtual bool releaseContextImplementation();
85 /** Bind the graphics context to associated texture implementation.*/
86 virtual void bindPBufferToTextureImplementation( GLenum buffer );
88 /** Swap the front and back buffers.*/
89 virtual void swapBuffersImplementation();
91 static AGLPixelFormat createPixelFormat(osg::GraphicsContext::Traits* traits);
100 ~PixelBufferCarbon();
108 AGLPixelFormat _pixelformat;