- Timestamp:
- 04/09/09 17:33:28 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgViewer/PixelBufferCarbon.cpp
r7039 r10005 28 28 attributes.push_back(AGL_RGBA); 29 29 if (!traits->pbuffer) 30 attributes.push_back(AGL_COMPLIANT);31 else32 attributes.push_back(AGL_CLOSEST_POLICY);30 attributes.push_back(AGL_COMPLIANT); 31 else 32 attributes.push_back(AGL_CLOSEST_POLICY); 33 33 34 34 if (traits->doubleBuffer) attributes.push_back(AGL_DOUBLEBUFFER); … … 74 74 bool PixelBufferCarbon::realizeImplementation() 75 75 { 76 if (!_valid) {77 osg::notify(osg::WARN) << "PixelBufferCarbon::realizeImplementation() aglChoosePixelFormat failed! " << aglErrorString(aglGetError()) << std::endl;78 return false;79 }80 81 AGLContext sharedContext = NULL;76 if (!_valid) { 77 osg::notify(osg::WARN) << "PixelBufferCarbon::realizeImplementation() aglChoosePixelFormat failed! " << aglErrorString(aglGetError()) << std::endl; 78 return false; 79 } 80 81 AGLContext sharedContext = NULL; 82 82 83 83 // get any shared GLX contexts … … 95 95 } 96 96 } 97 98 _context = aglCreateContext (_pixelformat, sharedContext);99 100 if (!_context) {101 osg::notify(osg::WARN) << "PixelBufferCarbon::realizeImplementation() aglCreateContext failed! " << aglErrorString(aglGetError()) << std::endl;102 return false;103 }104 97 98 _context = aglCreateContext (_pixelformat, sharedContext); 99 100 if (!_context) { 101 osg::notify(osg::WARN) << "PixelBufferCarbon::realizeImplementation() aglCreateContext failed! " << aglErrorString(aglGetError()) << std::endl; 102 return false; 103 } 104 105 105 106 107 _realized = aglCreatePBuffer (_traits->width, _traits->height, _traits->target, GL_RGBA, _traits->level, &(_pbuffer));108 if (!_realized) {109 osg::notify(osg::WARN) << "PixelBufferCarbon::realizeImplementation() aglCreatePBuffer failed! " << aglErrorString(aglGetError()) << std::endl;110 }111 112 makeCurrentImplementation();113 114 _realized = aglSetPBuffer(_context, _pbuffer, _traits->face, _traits->level, 0);115 if (!_realized) {116 osg::notify(osg::WARN) << "PixelBufferCarbon::realizeImplementation() aglSetPBuffer failed! " << aglErrorString(aglGetError()) << std::endl;117 }118 return _realized;106 107 _realized = aglCreatePBuffer (_traits->width, _traits->height, _traits->target, GL_RGBA, _traits->level, &(_pbuffer)); 108 if (!_realized) { 109 osg::notify(osg::WARN) << "PixelBufferCarbon::realizeImplementation() aglCreatePBuffer failed! " << aglErrorString(aglGetError()) << std::endl; 110 } 111 112 makeCurrentImplementation(); 113 114 _realized = aglSetPBuffer(_context, _pbuffer, _traits->face, _traits->level, 0); 115 if (!_realized) { 116 osg::notify(osg::WARN) << "PixelBufferCarbon::realizeImplementation() aglSetPBuffer failed! " << aglErrorString(aglGetError()) << std::endl; 117 } 118 return _realized; 119 119 } 120 120 121 121 void PixelBufferCarbon::closeImplementation() 122 122 { 123 if (_pbuffer) aglDestroyPBuffer(_pbuffer);124 if (_context) aglDestroyContext(_context);125 if (_pixelformat) aglDestroyPixelFormat(_pixelformat);126 _valid = _realized = false;123 if (_pbuffer) aglDestroyPBuffer(_pbuffer); 124 if (_context) aglDestroyContext(_context); 125 if (_pixelformat) aglDestroyPixelFormat(_pixelformat); 126 _valid = _realized = false; 127 127 } 128 128 … … 131 131 bool PixelBufferCarbon::makeCurrentImplementation() 132 132 { 133 return (_realized) ? (aglSetCurrentContext(_context) == GL_TRUE) : false;133 return (_realized) ? (aglSetCurrentContext(_context) == GL_TRUE) : false; 134 134 } 135 135 … … 137 137 * Pure virtual - must be implemented by concrate implementations of GraphicsContext. */ 138 138 bool PixelBufferCarbon::makeContextCurrentImplementation(GraphicsContext* /*readContext*/) { 139 return makeCurrentImplementation();139 return makeCurrentImplementation(); 140 140 } 141 141 … … 143 143 bool PixelBufferCarbon::releaseContextImplementation() 144 144 { 145 return (aglSetCurrentContext(NULL) == GL_TRUE);145 return (aglSetCurrentContext(NULL) == GL_TRUE); 146 146 } 147 147 … … 151 151 void PixelBufferCarbon::bindPBufferToTextureImplementation( GLenum buffer ){ 152 152 153 osg::notify(osg::NOTICE)<<"GraphicsWindow::void bindPBufferToTextureImplementation(..) not implemented."<<std::endl;153 osg::notify(osg::NOTICE)<<"GraphicsWindow::void bindPBufferToTextureImplementation(..) not implemented."<<std::endl; 154 154 } 155 155 … … 158 158 void PixelBufferCarbon::swapBuffersImplementation() 159 159 { 160 aglSwapBuffers(_context);160 aglSwapBuffers(_context); 161 161 } 162 162 163 163 164 164 PixelBufferCarbon::~PixelBufferCarbon() 165 165 { 166 close(true);166 close(true); 167 167 } 168 168
