Hi jp
thanks, but I'm using the texture directly in my shader so I don't use a
geometry. Don't ask me how I resolved all the problem, but now it works
(crossing my fingers) ;-) For the rotation I used a Matrix and a
MatrixTransform, added the node (which gets rendered to texture) and
added this MatrixTransform to the texture camera.
Thanks all you guys for the patient help!
Dominic
Am 06.01.10 10:57, schrieb J.P. Delport:
Hi,
just flip to texture coordinates of the quad you are drawing in the RTT
camera.
jp
Dominic Stalder wrote:
Hi
if I attach the texture instead of the image it is working. But when I
call the methode renderToTexture right after
osgViewer->setSceneData() I get the following error:
GraphicsWindowCarbon::grabFocusIfPointerInWindow
When I wait about 200 ms with an QTimer, it works but then I have the
problem that the scene is not yet ready when it gets painted to the
screen - ugly artefacts.
Another problem: how can I scale / mirror the texture directly? I
know TexMat's but they need to be applied to an osg:Node and can not
be applied to a osg:Texture2D?
Thanks a lot
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
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org