OpenSceneGraph 3.6.5
PixelBufferCocoa
Go to the documentation of this file.
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>
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):
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
70 virtual bool realizeImplementation();
71
73 virtual bool isRealizedImplementation() const { return _realized; }
74
76 virtual void closeImplementation();
77
79 virtual bool makeCurrentImplementation();
80
82 virtual bool makeContextCurrentImplementation(osg::GraphicsContext* readContext);
83
85 virtual bool releaseContextImplementation();
86
88 virtual void bindPBufferToTextureImplementation( GLenum buffer );
89
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
The osgViewer library provides high level viewer functionality designed to make it easier to write a ...
Base class for providing Windowing API agnostic access to creating and managing graphics context.
Definition GraphicsContext:30
static unsigned int createNewContextID()
Create a contextID for a new graphics context, this contextID is used to set up the osg::State associ...
GraphicsContext Traits object provides the specification of what type of graphics context is required...
Definition GraphicsContext:70
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
Class to encapsulate platform-specific OpenGL context handle variables.
Definition GraphicsHandleCocoa:34
#define NULL
Definition Export:55
#define OSGVIEWER_EXPORT
Definition Export:40

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.