Changeset 10887

Show
Ignore:
Timestamp:
12/10/09 18:52:40 (5 years ago)
Author:
robert
Message:

From Stephan Huber, "attached you'll find the missing GraphicsHandleCocoa?-implementation."

Location:
OpenSceneGraph/trunk
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osgViewer/api/Cocoa/GraphicsWindowCocoa

    r10456 r10887  
    3737 
    3838#include <osgViewer/GraphicsWindow> 
     39#include <osgViewer/api/Cocoa/GraphicsHandleCocoa> 
    3940 
    4041// we may not include any cocoa-header here, because this will pollute the name-sapce and tend to compile-errors 
     
    4344{ 
    4445 
    45 class GraphicsWindowCocoa : public osgViewer::GraphicsWindow 
     46class GraphicsWindowCocoa : public osgViewer::GraphicsWindow, public osgViewer::GraphicsHandleCocoa 
    4647{ 
    4748    public: 
     
    4950 
    5051        GraphicsWindowCocoa(osg::GraphicsContext::Traits* traits): 
     52            osgViewer::GraphicsWindow(), 
     53            osgViewer::GraphicsHandleCocoa(), 
    5154            _valid(false), 
    5255            _initialized(false), 
     
    5659            _ownsWindow(true), 
    5760            _currentCursor(RightArrowCursor), 
    58             _window(NULL), 
    59             _context(NULL) 
     61            _window(NULL) 
    6062        { 
    6163            _traits = traits; 
  • OpenSceneGraph/trunk/include/osgViewer/api/Cocoa/PixelBufferCocoa

    r10858 r10887  
    2121#include <osg/GraphicsContext> 
    2222#include <osgViewer/Export> 
    23  
    24  
    25 #ifdef __OBJC__ 
    26 @class NSOpenGLContext; 
    27 #else 
    28 class NSOpenGLContext; 
    29 #endif 
     23#include <osgViewer/api/Cocoa/GraphicsHandleCocoa> 
    3024 
    3125namespace osgViewer 
    3226{ 
    3327 
    34 class OSGVIEWER_EXPORT PixelBufferCocoa : public osg::GraphicsContext 
     28class OSGVIEWER_EXPORT PixelBufferCocoa : public osg::GraphicsContext, public osgViewer::GraphicsHandleCocoa 
    3529{ 
    3630    public: 
     
    3832 
    3933        PixelBufferCocoa(osg::GraphicsContext::Traits* traits): 
     34            osg::GraphicsContext(), 
     35            osgViewer::GraphicsHandleCocoa(), 
    4036            _valid(false), 
    4137            _initialized(false), 
  • OpenSceneGraph/trunk/src/osgViewer/CMakeLists.txt

    r10813 r10887  
    7373        ADD_DEFINITIONS(-DUSE_DARWIN_COCOA_IMPLEMENTATION) 
    7474        SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}  
     75            ${HEADER_PATH}/api/Cocoa/GraphicsHandleCocoa 
    7576            ${HEADER_PATH}/api/Cocoa/GraphicsWindowCocoa 
    7677            ${HEADER_PATH}/api/Cocoa/PixelBufferCocoa 
  • OpenSceneGraph/trunk/src/osgViewer/GraphicsWindowCocoa.mm

    r10456 r10887  
    972972    NSOpenGLContext* sharedContext = NULL; 
    973973     
    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(); 
    985978    } 
    986979     
  • OpenSceneGraph/trunk/src/osgViewer/PixelBufferCocoa.mm

    r9879 r10887  
    1818void PixelBufferCocoa::init() 
    1919{ 
    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     
    2424 
    2525} 
     
    2727bool PixelBufferCocoa::realizeImplementation()  
    2828{ 
    29         std::cout << "PixelBufferCocoa :: realizeImplementation not implemented yet " << std::endl; 
    30          
     29    std::cout << "PixelBufferCocoa :: realizeImplementation not implemented yet " << std::endl; 
     30     
    3131    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 
    32          
    33         NSOpenGLPixelFormatAttribute attr[32]; 
     32         
     33    NSOpenGLPixelFormatAttribute attr[32]; 
    3434    int i = 0; 
    3535     
     
    6666    NSOpenGLContext* sharedContext = NULL; 
    6767     
    68     GraphicsWindowCocoa* graphicsWindowCocoa = dynamic_cast<GraphicsWindowCocoa*>(_traits->sharedContext); 
    69     if (graphicsWindowCocoa)  
     68    GraphicsHandleCocoa* graphicsHandleCocoa = dynamic_cast<GraphicsHandleCocoa*>(_traits->sharedContext); 
     69    if (graphicsHandleCocoa)  
    7070    { 
    71         sharedContext = graphicsWindowCocoa->getContext(); 
     71        sharedContext = graphicsHandleCocoa->getNSOpenGLContext(); 
    7272    } 
    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 ]; 
    8276    _context = [[NSOpenGLContext alloc] initWithFormat: pixelformat shareContext: sharedContext]; 
    8377    NSOpenGLPixelBuffer* pbuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget: _traits->target textureInternalFormat: _traits->format textureMaxMipMapLevel: _traits->level pixelsWide: _traits->width pixelsHigh: _traits->height]; 
     
    9488void PixelBufferCocoa::closeImplementation() 
    9589{ 
    96         _realized = false; 
     90    _realized = false; 
    9791     
    9892     
     
    10498bool PixelBufferCocoa::makeCurrentImplementation() 
    10599{ 
    106         // osg::notify(osg::INFO) << "PixelBufferCocoa::makeCurrentImplementation" << std::endl; 
     100    // osg::notify(osg::INFO) << "PixelBufferCocoa::makeCurrentImplementation" << std::endl; 
    107101     
    108102    [_context makeCurrentContext]; 
    109         return true; 
     103    return true; 
    110104} 
    111105 
     
    114108bool PixelBufferCocoa::makeContextCurrentImplementation(osg::GraphicsContext* readContext) 
    115109{ 
    116         return makeCurrentImplementation(); 
     110    return makeCurrentImplementation(); 
    117111} 
    118112 
     
    120114bool PixelBufferCocoa::releaseContextImplementation() 
    121115{ 
    122         // osg::notify(osg::INFO) << "PixelBufferCocoa::releaseContextImplementation" << std::endl; 
     116    // osg::notify(osg::INFO) << "PixelBufferCocoa::releaseContextImplementation" << std::endl; 
    123117     
    124118    [NSOpenGLContext clearCurrentContext]; 
     
    129123void PixelBufferCocoa::bindPBufferToTextureImplementation( GLenum buffer ) 
    130124{ 
    131         std::cout << "PixelBufferCocoa :: bindPBufferToTextureImplementation not implemented yet " << std::endl; 
     125    std::cout << "PixelBufferCocoa :: bindPBufferToTextureImplementation not implemented yet " << std::endl; 
    132126} 
    133127 
     
    135129void PixelBufferCocoa::swapBuffersImplementation() 
    136130{ 
    137         osg::notify(osg::INFO) << "PixelBufferCocoa::swapBuffersImplementation" << std::endl; 
     131    osg::notify(osg::INFO) << "PixelBufferCocoa::swapBuffersImplementation" << std::endl; 
    138132    [_context flushBuffer]; 
    139133} 
    140134 
    141135 PixelBufferCocoa::~PixelBufferCocoa() 
    142  {       
     136 {     
    143137    [_context release]; 
    144138 }