Hi,

I have somewhat similar questions  to recent FBO  question,
but not quite, so I would ask in a new thread.

I try to extend Blender with osg rendering ( just because osg does many
things better than Blender namely I use osgPango to render dynamically
text).

First - it is fairly easy to create in osg app pbuffer

by
setting
traits->pbuffer = true;
and then
 osg::ref_ptr<osg::GraphicsContext> pbuffer =
osg::GraphicsContext::createGraphicsContext(traits.get());
       if (pbuffer.valid())
       {
           osg::notify(osg::NOTICE)<<"Pixel buffer has been created
successfully."<<std::endl;
           osg::ref_ptr<osg::Camera> camera =
createOrthoCamera(WINDOW_WIDTH, WINDOW_HEIGHT);
           camera->setGraphicsContext(pbuffer.get());
   osg::GraphicsContext* context = camera->getGraphicsContext();
           camera->setViewport(new
osg::Viewport(0,0,WINDOW_WIDTH/*traits->width*/,WINDOW_HEIGHT/*traits->height*/));
           GLenum buffer = pbuffer->getTraits()->doubleBuffer ? GL_BACK :
GL_FRONT;
           camera->setDrawBuffer(buffer);
           camera->setReadBuffer(buffer);
           viewer.setCamera(camera.get());
        }

set viewer data,
set render callback
and make it  viewer.renderingTraversals(); to perform rendering once.

after which it is possible to read glReadPixels and apply them as texture.

Obviously, Blender has another context and
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
 traits->width = WINDOW_WIDTH;
 traits->height = WINDOW_HEIGHT;
 traits->pbuffer = true;
 osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
osg::GraphicsContext::Traits(ds);
osg::ref_ptr<osg::GraphicsContext> pbuffer =
osg::GraphicsContext::createGraphicsContext(traits.get());

causes subsequent attachment to blender texture to fail.

I tried to notify pbuffer traits with
  traits->setInheritedWindowPixelFormat = true;
  osg::ref_ptr<osgViewer::GraphicsWindowWin32::WindowData> wdata = new
osgViewer::GraphicsWindowWin32::WindowData( GetActiveWindow(),false );

  traits->inheritedWindowData = wdata.get();

but to no avail - I still have problems ( and BTW I found that code in
windows pbuffer won't use inherited data - it will created  temporary
window).

so the question is - if I use osg to render to pbuffer in complex OpenGL
application, how to make that contexts problems does not occur?
I seen in replies for osg/OpenGL apps integration that FrameBuffer ( pbuffer
) is easiest way to go.

but in my case I did not got working solution.

so what should be changed to get rendering to pbuffer with osg  in outside
app ( even if it requires to make changes in core osg - what - to get rid of
makecurrent or instead keep track of makecurrent etc?).

Best regards
Sergey
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to