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

Revision 13130, 3.5 kB (checked in by robert, 5 days ago)

Fixed comment

  • Property svn:eol-style set to native
Line 
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
19#if defined (__APPLE__) && (!__LP64__)
20
21#include <osg/GraphicsContext>
22#include <osgViewer/api/Carbon/GraphicsHandleCarbon>
23
24
25namespace osgViewer
26{
27
28class OSGVIEWER_EXPORT PixelBufferCarbon : public osg::GraphicsContext, public osgViewer::GraphicsHandleCarbon
29{
30    public:
31
32        PixelBufferCarbon(osg::GraphicsContext::Traits* traits):
33            _valid(false),
34            _initialized(false),
35            _realized(false),
36            _pixelformat(0),
37            _pbuffer(0)
38        {
39            _traits = traits;
40
41            init();
42           
43            if (valid())
44            {
45                setState( new osg::State );
46                getState()->setGraphicsContext(this);
47
48                if (_traits.valid() && _traits->sharedContext.valid())
49                {
50                    getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
51                    incrementContextIDUsageCount( getState()->getContextID() );   
52                }
53                else
54                {
55                    getState()->setContextID( osg::GraphicsContext::createNewContextID() );
56                }
57
58            }
59        }
60   
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"; }
64
65        virtual bool valid() const { return _valid; }
66
67        /** Realise the GraphicsContext.*/
68        virtual bool realizeImplementation();
69
70        /** Return true if the graphics context has been realised and is ready to use.*/
71        virtual bool isRealizedImplementation() const { return _realized; }
72
73        /** Close the graphics context.*/
74        virtual void closeImplementation();
75
76        /** Make this graphics context current.*/
77        virtual bool makeCurrentImplementation();
78
79        /** Make this graphics context current with specified read context implementation. */
80        virtual bool makeContextCurrentImplementation(osg::GraphicsContext* readContext);
81
82        /** Release the graphics context.*/
83        virtual bool releaseContextImplementation();
84
85        /** Bind the graphics context to associated texture implementation.*/
86        virtual void bindPBufferToTextureImplementation( GLenum buffer );
87
88        /** Swap the front and back buffers.*/
89        virtual void swapBuffersImplementation();
90       
91        static AGLPixelFormat createPixelFormat(osg::GraphicsContext::Traits* traits);
92
93    public:
94   
95
96    protected:
97       
98
99   
100        ~PixelBufferCarbon();
101   
102        void init();
103
104        bool            _valid;
105        bool            _initialized;
106        bool            _realized;
107       
108        AGLPixelFormat    _pixelformat;
109        AGLPbuffer        _pbuffer;       
110};
111
112}
113
114#endif
115
116#endif
Note: See TracBrowser for help on using the browser.