Happy Friday everyone.

Forgive me if this turns out to be a terribly trivial problem.  I'm still a 
rookie with GL/OSG/graphics in general.

I'm attempting to get a two camera system set up, one RTT.  I'm attempting to 
read the texture back into an unsigned char array during a callback each frame. 
 My scene graph is set up such that I have:


Code:

viewer
 |_ setSceneData()
   |_topNode(osg::Group)
      |_FBOCamera(set to prerender)
         |_SceneRoot(osg::Group)




I don't have any nodes added under the viewer's main camera currently.

The setup for my FBOCamera is:


Code:

    primaryCamera->setFinalDrawCallback(new 
FBOFinalRenderCallback(renderTexture));

    FBOCamera->setClearColor(Vec4f(1., 1., 1., 1.));
    FBOCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    FBOCamera->setViewport(0, 0, WIDTH, HEIGHT);
    //FBOCamera->setViewMatrixAsLookAt(Vec3d(0., 0., 0.), Vec3d(0., 1., 0.), 
Vec3d(0., 0., 1.));
    FBOCamera->setViewMatrix(Matrixd::identity());
    //FBOCamera->setProjectionMatrixAsPerspective(60., 
(double)WIDTH/(double)HEIGHT, NEAR, FAR);
    FBOCamera->setProjectionMatrix(Matrixd::identity());

    FBOCamera->setRenderOrder(Camera::PRE_RENDER);
    FBOCamera->setRenderTargetImplementation(Camera::FRAME_BUFFER_OBJECT);
    FBOCamera->attach(Camera::BufferComponent(Camera::COLOR_BUFFER), 
renderTexture);






The setup for my texture is:

Code:

    StateSet *stateSet = topNode->getOrCreateStateSet();
    stateSet->setTextureAttributeAndModes(FBO_RENDER_TEXTURE_UNIT, 
renderTexture, StateAttribute::ON);

    renderTexture->setTextureSize(WIDTH, HEIGHT);
    renderTexture->setSourceFormat(GL_RGBA);
    renderTexture->setInternalFormat(GL_RGBA8UI);
    renderTexture->setSourceType(GL_UNSIGNED_BYTE);
    renderTexture->setFilter(Texture2D::MIN_FILTER, Texture2D::NEAREST);
    renderTexture->setFilter(Texture2D::MAG_FILTER, Texture2D::NEAREST);
    renderTexture->setWrap(Texture::WRAP_S, Texture::CLAMP_TO_EDGE);
    renderTexture->setWrap(Texture::WRAP_T, Texture::CLAMP_TO_EDGE);
    renderTexture->setWrap(Texture::WRAP_R, Texture::CLAMP_TO_EDGE);





My callback gets a ref_ptr to the texture.  Then each frame it:

Code:

  
    glBindTexture(GL_TEXTURE_RECTANGLE, FBO_RENDER_TEXTURE_UNIT);

    glGetTexImage(renderTexture->getTextureTarget(),
                  0,                                  
                  renderTexture->getInternalFormat(),
                  renderTexture->getSourceType(),     
                  data);

    glBindTexture(GL_TEXTURE_RECTANGLE, 0);

    PostCallbackValidateData(); // prints all the values in data to the console






When I print data to the screen, all I get are the values I initially populated 
data with.  I never even get the clear color for the camera.  What I've written 
looks right when compared to other things I've seen done.  What am I missing 
here?

(As an aside:  am I right in calling FBOCamera that?  I presume that by setting 
the camera to RTT, it's got to be using an FBO's GL_COLOR_BUFFER behind the 
scenes, even if I don't explicitly generate the FBO..  I don't know of any 
other way to RTT..)

Thanks all.

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





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

Reply via email to