root/OpenSceneGraph/trunk/include/osgViewer/api/Carbon/PixelBufferCarbon @ 9904

Revision 9904, 3.6 kB (checked in by robert, 5 years ago)

From Stephan Huber, files were are missed by Robert in check in of changes to GraphicsWindowCarbon?.cpp

RevLine 
[7039]1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
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.
7 *
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.
12*/
13
14
15
16#ifndef OSGVIEWER_PIXELBUFFERCARBON
17#define OSGVIEWER_PIXELBUFFERCARBON 1
18
[9904]19#if defined (__APPLE__) && (!__LP64__)
[7039]20
21#include <osg/GraphicsContext>
22#include <osgViewer/Export>
23
24#include <Carbon/Carbon.h>
25#include <AGL/agl.h>
26
27
28namespace osgViewer
29{
30
31class OSGVIEWER_EXPORT PixelBufferCarbon : public osg::GraphicsContext
32{
33    public:
34
35        PixelBufferCarbon(osg::GraphicsContext::Traits* traits):
36            _valid(false),
[9904]37            _initialized(false),
[7039]38            _realized(false),
[9904]39            _pixelformat(0),
[7039]40            _pbuffer(0),
41            _context(0)
[9904]42        {
[7039]43            _traits = traits;
44
45            init();
46           
47            if (valid())
48            {
49                setState( new osg::State );
50                getState()->setGraphicsContext(this);
51
52                if (_traits.valid() && _traits->sharedContext)
53                {
54                    getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
55                    incrementContextIDUsageCount( getState()->getContextID() );   
56                }
57                else
58                {
59                    getState()->setContextID( osg::GraphicsContext::createNewContextID() );
60                }
61
62            }
63        }
64   
65        virtual bool isSameKindAs(const Object* object) const { return dynamic_cast<const PixelBufferCarbon*>(object)!=0; }
66        virtual const char* libraryName() const { return "osgViewer"; }
67        virtual const char* className() const { return "PixelBufferCarbon"; }
68
69        virtual bool valid() const { return _valid; }
70
71        /** Realise the GraphicsContext.*/
72        virtual bool realizeImplementation();
73
74        /** Return true if the graphics context has been realised and is ready to use.*/
75        virtual bool isRealizedImplementation() const { return _realized; }
76
77        /** Close the graphics context.*/
78        virtual void closeImplementation();
79
80        /** Make this graphics context current.*/
81        virtual bool makeCurrentImplementation();
82
83        /** Make this graphics context current with specified read context implementation. */
84        virtual bool makeContextCurrentImplementation(osg::GraphicsContext* readContext);
85
86        /** Release the graphics context.*/
87        virtual bool releaseContextImplementation();
88
89        /** Bind the graphics context to associated texture implementation.*/
90        virtual void bindPBufferToTextureImplementation( GLenum buffer );
91
92        /** Swap the front and back buffers.*/
93        virtual void swapBuffersImplementation();
[9904]94       
95        static AGLPixelFormat createPixelFormat(osg::GraphicsContext::Traits* traits);
96       
97        AGLContext getAGLContext() { return _context; }
[7039]98
99    public:
100   
101
102    protected:
[9904]103       
[7039]104
105   
106        ~PixelBufferCarbon();
107   
108        void init();
109
110        bool            _valid;
111        bool            _initialized;
112        bool            _realized;
113       
[9904]114        AGLPixelFormat    _pixelformat;
115        AGLPbuffer        _pbuffer;
116        AGLContext        _context;
117       
[7039]118};
119
120}
121
122#endif
123
124#endif
Note: See TracBrowser for help on using the browser.