Hi Matt,

The best thing to do is have a look at the osgprerender* examples to
see how to set up render to texture.  You don't normally explicitly
call frame on viewer just to invoke a render to texture, rather the
OSG's rendering backend automatically do the rendering required by
your scene graph - and in the render to texture case you have a pre
rendering stage that does the render to texture, then the main
rendering stage that renders the main scene.

W.r.t copying textures back to CPU based imagery, this can be done by
simply attaching a osg::Image to the camera, the copy will be done for
your automatically.  The osgprerender example has a code path that
does this and even modifies the image on the CPU before using that for
a new texture rendered in the main scene.

However, for performance reasons I would recommend against doing any
copying back from the GPU to the CPU.  The OSG support
FrambeBufferObjects natively, and with modern shaders you can do most
work on the GPU and never need to copy data back to the CPU.

Robert.

On Thu, Apr 22, 2010 at 1:36 AM, Matt Jenkins <[email protected]> wrote:
> Hi,
>
> I'm new to OSG and as part of my crash course decided to take on moving an 
> openGL water shading mechanism and moving it to OSG. However, in doing so 
> I've come upon a few scenarios I don't know how to handle and find sparse 
> documentation for.
>
> First, I'd like to know the best way to cause a render. Right now I'm trying 
> this:
>
> Code:
> osgViewer::Viewer view;
> view.setCamera(camera);
>
> camera->attach(osg::Camera::COLOR_BUFFER, refraction);
>
> view.frame();
>
>  In this, the camera is set up by another function to render to a frame 
> buffer object, this function simply takes the camera, binds it to a texture, 
> loads it into an osgViewer and then calls frame. This was the only way I 
> could think to cause a render.
>
> Second, what's the proper usage of Texture2D's copyTexSubImage2D? in openGL 
> it would be
> Code:
> glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,texSize, texSize);
>
>  but I can't find the equivalent of GL_TEXTURE_2D as an osgState which is 
> what Texture2D requires.
>
> A note: I'm not using ref_ptrs. I know I probably should, but for the time 
> being they add a complexity I'm not yet ready to deal with.
>
>
> Thanks in advance,
> Matt
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=27116#27116
>
>
>
>
>
> _______________________________________________
> 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

Reply via email to