Hi,

I can't help more than by pointing you to the working osgprerender.
Start from that and modify as needed. You don't need to call frame()
manually in you own rendering, just attach the RTT camera to your scene.

jp

Dominic Stalder wrote:
I'm sorry for posting that much, but I can't do it right the FBO rendering to texture.

If I take some other osg:Node's it brings the following warning:

Warning: detected OpenGL error 'invalid framebuffer operation' after RenderBin::draw(,)

If someone knows how to do it rigth, just mail ;-)

Am 05.01.10 13:45, schrieb Dominic Stalder:
Hi

I solved the problem, the projection matrix was the problem. Now if I call the following method, ONE image is made successful, if I call it a second time, the image gets all black again. Do I have to clear or reset something in between?

void GameViewOSG::renderToTexture(ref_ptr<Node> node, ref_ptr<Texture2D> texture, Camera::BufferComponent buffer)
{
    // just for testing
    ref_ptr<Image> image = new Image;
image->allocateImage(osgViewer->width(), osgViewer->height(), 1, GL_RGBA, GL_UNSIGNED_BYTE); // TODO: maybe GL_UNSIGNED_BYTE

    // sets the viewport of the texture camera
texCamera->setViewport(0, 0, osgViewer->width(), osgViewer->height());

    // attaches the texture to the texture camera
// buffer component, texture, level, face, mip map generation, samples, color samples
    //texCamera->attach(buffer, texture.get(), 0, 0, false, 4, 0);
    texCamera->attach(buffer, image, 4, 0); // just for testing

// adds the node to the texture camera (this node will be rendered to the texture)
    texCamera->addChild(node);

    if (!root->containsNode(texCamera))
        // adds the texture camera to the root node
        root->addChild(texCamera);

    osgViewer->frame();

    // just for testing
    osgDB::writeImageFile(*image, "/Users/dst/Downloads/test.bmp");
}

Dominic

Am 05.01.10 07:23, schrieb J.P. Delport:
Hi,

have you tried writing the image in the camera callback? Maybe have a look at osgprerender and osgscreencapture.

jp

Dominic Stalder wrote:
Sorry for hesitating, but the time of our project is running ;-)

Someone any idea what I did wrong with the texture / image camera? Or is there a problem with the addChild hirarchy?

Thanks a lot

Am 03.01.10 12:05, schrieb Dominic Stalder:
Hi Ulrich

thanks a lot, big mistake ;-)

Now the color is not black any more, but it only takes the gl clear color of the the camera. Do I have to set some view matrices?

Dominic

Am 03.01.10 11:50, schrieb Ulrich Hertlein:
Hi Dominic,

a happy new year to you too.

On 2/01/10 10:00 PM, Dominic Stalder wrote:
     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->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.
Did you omit some code between 'root->addChild()' and 'writeImageFile'? There should be a call to render the frame (like 'osgViewer->frame()') otherwise the Image will remain 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:
GL_U_B is fine, this will probably also give you better performance.

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


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


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



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


_______________________________________________
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