root/OpenSceneGraph/trunk/include/osgViewer/api/Cocoa/PixelBufferCocoa @ 13130

Revision 13130, 3.5 kB (checked in by robert, 18 hours ago)

Added VolumeSettings::Filename property.

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