You could use a pbuffer instead of a window. See the osgscreencapture example's pbuffer options.

jp

On 16/04/11 00:46, Matthias Asselborn wrote:
Hi,


i want to render a loaded scene into an image.
i dont want to see any viewer windows.

I have tried to realize it with osg::Viewer, but after the call
viewer->frame a viewer window poped up.

Now ive tried it with osgUtils::SceneViewer
but after the draw call - the program crashes

whats wrong?

Code:


osg::ref_ptr<osg::Image>  shot = new osg::Image();
shot->allocateImage( 800, 600, 1, GL_RGB, GL_UNSIGNED_BYTE );
osg::ref_ptr<osg::Node>  subgraph = m_pNode.get();
osg::ref_ptr<osg::Camera>  camera = new osg::Camera;
osg::ref_ptr<osg::Camera>  oldcamera = m_pViewer->getCamera();

//Copy the settings from sceneView-camera to get exactly the view
//the user sees at the moment:

camera->setClearColor( oldcamera->getClearColor() );
camera->setClearMask( oldcamera->getClearMask() );
camera->setColorMask( oldcamera->getColorMask() );
camera->setTransformOrder( oldcamera->getTransformOrder() );
camera->setProjectionMatrix( oldcamera->getProjectionMatrix() );
camera->setViewMatrix( oldcamera->getViewMatrix() );

// set view
camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );

// set viewport
camera->setViewport( 0, 0, 800, 600 );

//set the camera to render before after the main camera.
camera->setRenderOrder( osg::Camera::POST_RENDER );

// tell the camera to use OpenGL frame buffer object where supported.
camera->setRenderTargetImplementation( osg::Camera::FRAME_BUFFER_OBJECT );

camera->attach( osg::Camera::COLOR_BUFFER, shot.get() );

// add subgraph to render
camera->addChild( subgraph.get() );
//camera->addChild(TheDocument->GetHUD().get() );
//Need to mage it part of the scene :
m_pViewer->setSceneData( camera.get() );

//Make it frame:

m_pViewer->update();
m_pViewer->cull();
m_pViewer->draw();

// in draw call the software crashes

osgDB::writeImageFile( *shot, "C:/tools/test.bmp" );





The crash appers in
RenderStage.cpp Line 1146 - trunk


Code:


     if (_graphicsContext.valid()&&  _graphicsContext != callingContext)
     {
         // show we release the context so that others can use it?? will do so 
right
         // now as an experiment.
         callingContext->releaseContext();




Thank you!

Cheers,
Matthias

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38516#38516





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


--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks Transtec Computers for their support.

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

Reply via email to