Changeset 10887
- Timestamp:
- 12/10/09 18:52:40 (4 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 1 added
- 5 modified
-
include/osgViewer/api/Cocoa/GraphicsHandleCocoa (added)
-
include/osgViewer/api/Cocoa/GraphicsWindowCocoa (modified) (4 diffs)
-
include/osgViewer/api/Cocoa/PixelBufferCocoa (modified) (2 diffs)
-
src/osgViewer/CMakeLists.txt (modified) (1 diff)
-
src/osgViewer/GraphicsWindowCocoa.mm (modified) (1 diff)
-
src/osgViewer/PixelBufferCocoa.mm (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgViewer/api/Cocoa/GraphicsWindowCocoa
r10456 r10887 37 37 38 38 #include <osgViewer/GraphicsWindow> 39 #include <osgViewer/api/Cocoa/GraphicsHandleCocoa> 39 40 40 41 // we may not include any cocoa-header here, because this will pollute the name-sapce and tend to compile-errors … … 43 44 { 44 45 45 class GraphicsWindowCocoa : public osgViewer::GraphicsWindow 46 class GraphicsWindowCocoa : public osgViewer::GraphicsWindow, public osgViewer::GraphicsHandleCocoa 46 47 { 47 48 public: … … 49 50 50 51 GraphicsWindowCocoa(osg::GraphicsContext::Traits* traits): 52 osgViewer::GraphicsWindow(), 53 osgViewer::GraphicsHandleCocoa(), 51 54 _valid(false), 52 55 _initialized(false), … … 56 59 _ownsWindow(true), 57 60 _currentCursor(RightArrowCursor), 58 _window(NULL), 59 _context(NULL) 61 _window(NULL) 60 62 { 61 63 _traits = traits; -
OpenSceneGraph/trunk/include/osgViewer/api/Cocoa/PixelBufferCocoa
r10858 r10887 21 21 #include <osg/GraphicsContext> 22 22 #include <osgViewer/Export> 23 24 25 #ifdef __OBJC__ 26 @class NSOpenGLContext; 27 #else 28 class NSOpenGLContext; 29 #endif 23 #include <osgViewer/api/Cocoa/GraphicsHandleCocoa> 30 24 31 25 namespace osgViewer 32 26 { 33 27 34 class OSGVIEWER_EXPORT PixelBufferCocoa : public osg::GraphicsContext 28 class OSGVIEWER_EXPORT PixelBufferCocoa : public osg::GraphicsContext, public osgViewer::GraphicsHandleCocoa 35 29 { 36 30 public: … … 38 32 39 33 PixelBufferCocoa(osg::GraphicsContext::Traits* traits): 34 osg::GraphicsContext(), 35 osgViewer::GraphicsHandleCocoa(), 40 36 _valid(false), 41 37 _initialized(false), -
OpenSceneGraph/trunk/src/osgViewer/CMakeLists.txt
r10813 r10887 73 73 ADD_DEFINITIONS(-DUSE_DARWIN_COCOA_IMPLEMENTATION) 74 74 SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS} 75 ${HEADER_PATH}/api/Cocoa/GraphicsHandleCocoa 75 76 ${HEADER_PATH}/api/Cocoa/GraphicsWindowCocoa 76 77 ${HEADER_PATH}/api/Cocoa/PixelBufferCocoa -
OpenSceneGraph/trunk/src/osgViewer/GraphicsWindowCocoa.mm
r10456 r10887 972 972 NSOpenGLContext* sharedContext = NULL; 973 973 974 GraphicsWindowCocoa* graphicsWindowCocoa = dynamic_cast<GraphicsWindowCocoa*>(_traits->sharedContext); 975 if (graphicsWindowCocoa) 976 { 977 sharedContext = graphicsWindowCocoa->getContext(); 978 } 979 else 980 { 981 PixelBufferCocoa* pixelbuffer = dynamic_cast<PixelBufferCocoa*>(_traits->sharedContext); 982 if (pixelbuffer) { 983 sharedContext = pixelbuffer->getContext(); 984 } 974 GraphicsHandleCocoa* graphicsHandleCocoa = dynamic_cast<GraphicsHandleCocoa*>(_traits->sharedContext); 975 if (graphicsHandleCocoa) 976 { 977 sharedContext = graphicsHandleCocoa->getNSOpenGLContext(); 985 978 } 986 979 -
OpenSceneGraph/trunk/src/osgViewer/PixelBufferCocoa.mm
r9879 r10887 18 18 void PixelBufferCocoa::init() 19 19 { 20 //std::cout << "PixelBufferCocoa :: init not implemented yet " << std::endl;21 22 _valid = _initialized = true;23 20 //std::cout << "PixelBufferCocoa :: init not implemented yet " << std::endl; 21 22 _valid = _initialized = true; 23 24 24 25 25 } … … 27 27 bool PixelBufferCocoa::realizeImplementation() 28 28 { 29 std::cout << "PixelBufferCocoa :: realizeImplementation not implemented yet " << std::endl;30 29 std::cout << "PixelBufferCocoa :: realizeImplementation not implemented yet " << std::endl; 30 31 31 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 32 33 NSOpenGLPixelFormatAttribute attr[32];32 33 NSOpenGLPixelFormatAttribute attr[32]; 34 34 int i = 0; 35 35 … … 66 66 NSOpenGLContext* sharedContext = NULL; 67 67 68 Graphics WindowCocoa* graphicsWindowCocoa = dynamic_cast<GraphicsWindowCocoa*>(_traits->sharedContext);69 if (graphics WindowCocoa)68 GraphicsHandleCocoa* graphicsHandleCocoa = dynamic_cast<GraphicsHandleCocoa*>(_traits->sharedContext); 69 if (graphicsHandleCocoa) 70 70 { 71 sharedContext = graphics WindowCocoa->getContext();71 sharedContext = graphicsHandleCocoa->getNSOpenGLContext(); 72 72 } 73 else 74 { 75 PixelBufferCocoa* pixelbuffer = dynamic_cast<PixelBufferCocoa*>(_traits->sharedContext); 76 if (pixelbuffer) { 77 sharedContext = pixelbuffer->getContext(); 78 } 79 } 80 81 NSOpenGLPixelFormat* pixelformat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr ]; 73 74 75 NSOpenGLPixelFormat* pixelformat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr ]; 82 76 _context = [[NSOpenGLContext alloc] initWithFormat: pixelformat shareContext: sharedContext]; 83 77 NSOpenGLPixelBuffer* pbuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget: _traits->target textureInternalFormat: _traits->format textureMaxMipMapLevel: _traits->level pixelsWide: _traits->width pixelsHigh: _traits->height]; … … 94 88 void PixelBufferCocoa::closeImplementation() 95 89 { 96 _realized = false;90 _realized = false; 97 91 98 92 … … 104 98 bool PixelBufferCocoa::makeCurrentImplementation() 105 99 { 106 // osg::notify(osg::INFO) << "PixelBufferCocoa::makeCurrentImplementation" << std::endl;100 // osg::notify(osg::INFO) << "PixelBufferCocoa::makeCurrentImplementation" << std::endl; 107 101 108 102 [_context makeCurrentContext]; 109 return true;103 return true; 110 104 } 111 105 … … 114 108 bool PixelBufferCocoa::makeContextCurrentImplementation(osg::GraphicsContext* readContext) 115 109 { 116 return makeCurrentImplementation();110 return makeCurrentImplementation(); 117 111 } 118 112 … … 120 114 bool PixelBufferCocoa::releaseContextImplementation() 121 115 { 122 // osg::notify(osg::INFO) << "PixelBufferCocoa::releaseContextImplementation" << std::endl;116 // osg::notify(osg::INFO) << "PixelBufferCocoa::releaseContextImplementation" << std::endl; 123 117 124 118 [NSOpenGLContext clearCurrentContext]; … … 129 123 void PixelBufferCocoa::bindPBufferToTextureImplementation( GLenum buffer ) 130 124 { 131 std::cout << "PixelBufferCocoa :: bindPBufferToTextureImplementation not implemented yet " << std::endl;125 std::cout << "PixelBufferCocoa :: bindPBufferToTextureImplementation not implemented yet " << std::endl; 132 126 } 133 127 … … 135 129 void PixelBufferCocoa::swapBuffersImplementation() 136 130 { 137 osg::notify(osg::INFO) << "PixelBufferCocoa::swapBuffersImplementation" << std::endl;131 osg::notify(osg::INFO) << "PixelBufferCocoa::swapBuffersImplementation" << std::endl; 138 132 [_context flushBuffer]; 139 133 } 140 134 141 135 PixelBufferCocoa::~PixelBufferCocoa() 142 { 136 { 143 137 [_context release]; 144 138 }
