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

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

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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 }