Hi osg-users, In the application I'am working on we use PixelBufferWin32. I found there was a large memory leak and noticed incorrect shader result after destroying and creating a new pbuffer-enabled viewer. ( I adapted the pbuffertest code posted a while ago to create and destroy multiple pbuffers to see that this caused the leakage) :
traits->pbuffer = true //leaks v.s. traits->pbuffer = false //doesn't leak After some experimenting I decided to reuse the existing pbuffer to solve the problems. However this did not work if the pbuffer needed a different size. So I created a resize function in the PixelBufferWin32 class. This function does something like this (short version): //create new pbuffer newhwnd =wgle->wglCreatePbufferARB(_hdc, _format, width, height, &bAttribList[0]); newhdc = wgle->wglGetPbufferDCARB(newhwnd); newhglrc = wglCreateContext(newhdc); // delete the old context and pbuffer wglMakeCurrent(_hdc,0); if ( !wglDeleteContext(_hglrc) ) {} if ( !wgle->wglReleasePbufferDCARB(_hwnd, _hdc) ) {} if ( !wgle->wglDestroyPbufferARB(_hwnd) ) {} _hwnd = newhwnd; _hdc = newhdc; _hglrc = newhglrc; This solved the problems, now I could reuse and resize pbuffers. The difference with this function and creating and destroying the entire PixelBufferWin32 is that there is no TempWindow involved. It is the TempWindow class that was causing the memory leak. There is a comment in the code of this class: PixelBufferWin32.cpp: 319: // mew 2005-05-09 commented out due to crashes. 320: // possible causes are unsafe destructor ordering, or context already 321: // deleted by window deletion; see: 322: // http://openscenegraph.org/pipermail/osg-users/2005-May/052753.html 323: //wglDeleteContext(_context); 324: _context = 0; after uncommenting the wglDeleteContext(_context) call the memory leak was gone. I could not read the original post and now I am not sure how to procede. If we want a resize function in the PixelBufferWin32 class I can submit this? Can the wglDeleteContext(_context) be uncommented without causing the original crashes? Other suggestions? Thanks! René
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org