Hi everybody
first of all, happy new year!
I wanted to implement the rendering to image part, so I did the following:
Image* image = new Image;
image->allocateImage(osgViewer->width(), osgViewer->height(), 1,
GL_RGBA, GL_UNSIGNED_BYTE);
// creates a new camera that will render into the image and sets
the rendering settings
ref_ptr<Camera> imgCamera = new Camera;
imgCamera->setReferenceFrame(Transform::ABSOLUTE_RF);
imgCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
imgCamera->setViewport(0, 0, osgViewer->width(), osgViewer->height());
imgCamera->setRenderTargetImplementation(Camera::FRAME_BUFFER_OBJECT);
imgCamera->setRenderOrder(Camera::PRE_RENDER);
imgCamera->attach(Camera::COLOR_BUFFER, image);
imgCamera->addChild(rootLighting.get());
root->addChild(imgCamera.get());
osgDB::writeImageFile(*image, "/Users/xyz/tmp/test.bmp");
It allocates the image with the right size (1400 x 736) and writes it to
disk. But the image is all black.
Does anybody see an error or what could be the problem? I also tried
with GL_INT instead of GL_UNSIGNED_BYTE but this didn't work too. Is
there a problem with the hirachy:
root
| |
rootLigthing imgCamera
Thanks a lot and regards
Dominic
-------- Original-Nachricht --------
Betreff: Re: [osg-users] Write to texture file for lightning
Datum: Wed, 30 Dec 2009 18:33:56 +0100
Von: Ulrich Hertlein <[email protected]>
An: Dominic Stalder <[email protected]>
On 30/12/09 5:15 PM, Dominic Stalder wrote:
no problem at all ;-) Is it something like this:
http://sourceforge.net/apps/mediawiki/delta3d/index.php?title=Tutorial_Render_To_Texture
Yes, except you want to attach an Image instead of a texture to save it to disk.
Thanks for the link btw!
Happy New Year,
Cheers,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org