Hi,

I see you mention fft in your code. Is this what you want to do? Do you have a working fft with multiple OSG cameras? Is it too slow for you?

jp

On 28/09/2011 11:30, Emmanuel Roche wrote:
Thanks J.P,

but actually I know the gameoflife example almost by heart already and
this won't fit the bill: I need a real "single pass ping pong" rendering
here if I want to achieve good performances.

Cheers,
Manu.


2011/9/28 J.P. Delport <jpdelp...@csir.co.za <mailto:jpdelp...@csir.co.za>>

    Hi,

    I can't help you with your specific drawable question, but what
    would you like to achieve? In the osggameoflife example there is an
    example of ping-pong using multiple cameras and switches. You can
    also swap output textures if they are exactly the same using a
    callback. See here for inspiration:
    
http://code.google.com/p/__flitr/source/browse/trunk/__examples/keep_history_pass/__keep_history_pass.cpp
    
<http://code.google.com/p/flitr/source/browse/trunk/examples/keep_history_pass/keep_history_pass.cpp>

    cheers
    jp


    On 28/09/2011 10:45, Emmanuel Roche wrote:

        Hi everyone,

        I'm trying to setup an pure OpenGL FBO with render to texture
        target in
        an OSG drawable. But I just can't figure out how to do that
        "properly"
        (eg. how to "isolate those pure openGL calls from the rest of
        the OSG
        scene).

        in my drawa implementation I just have:

        virtual void drawImplementation(osg::__RenderInfo& info) const
        {
             OSG_NOTICE << "Drawing PingPongDrawable...";

             osg::State* state = info.getState();
             const unsigned int contextID = state->getContextID();

             if(!_initialized && !init(contextID,*state)) {
                 OSG_WARN << "Failed FBO setup!";
                 return;
             }

             state->checkGLErrors("end of PingPongDrawable drawing.");
        }

        So i'm really just calling an "init" function once to jus try to
        _create_ an FBO... I didn't even start using it..., the code of
        the init
        function is as follow:

        bool init(unsigned int contextID, osg::State& state) const {

             const FBOExtensions* fbo_ext =
        FBOExtensions::instance(__contextID,true);
             const osg::Texture2DArray::__Extensions* t2darray_ext =
        osg::Texture2DArray::__getExtensions(contextID,true);

             // Push attribs to avoid collisions with existing OSG scene ?
             glPushAttrib(GL_VIEWPORT_BIT | GL_COLOR_BUFFER_BIT |
        GL_TEXTURE_BIT
        | GL_ENABLE_BIT);

             state.checkGLErrors("Before PPD init.");

             // Prepare the target texture for the FBO:
             state.setActiveTextureUnit(1);
             state.checkGLErrors("__Activating texture slot 1");

             int FFT_SIZE=256;

             GLuint fftaTex = 0;
             glGenTextures(1, &fftaTex);
             glBindTexture(GL_TEXTURE_2D___ARRAY_EXT, fftaTex);
             glTexParameteri(GL_TEXTURE_2D___ARRAY_EXT,
        GL_TEXTURE_MIN_FILTER,
        GL_LINEAR_MIPMAP_LINEAR);
             glTexParameteri(GL_TEXTURE_2D___ARRAY_EXT,
        GL_TEXTURE_MAG_FILTER,
        GL_LINEAR);
             glTexParameteri(GL_TEXTURE_2D___ARRAY_EXT,
        GL_TEXTURE_WRAP_S, GL_REPEAT);
             glTexParameteri(GL_TEXTURE_2D___ARRAY_EXT,
        GL_TEXTURE_WRAP_T, GL_REPEAT);
             glTexParameterf(GL_TEXTURE_2D___ARRAY_EXT,
        GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);
             t2darray_ext->glTexImage3D(GL___TEXTURE_2D_ARRAY_EXT, 0,
        GL_RGBA16F_ARB, FFT_SIZE, FFT_SIZE, 5, 0, GL_RGBA, GL_FLOAT, NULL);
             fbo_ext->glGenerateMipmap(GL___TEXTURE_2D_ARRAY_EXT);
             state.checkGLErrors("preparing target texture");


             // Initialize the FBO
             fbo_ext->glGenFramebuffers(1, &_fftFbo);
             state.checkGLErrors("__Generating FBO");


             fbo_ext->glBindFramebuffer(GL___FRAMEBUFFER_EXT, _fftFbo);
             state.checkGLErrors("Bind Framebuffer in init.");
        #ifdef ATTACH_TEXTURE
             fbo_ext->glFramebufferTexture(__GL_FRAMEBUFFER_EXT,
        GL_COLOR_ATTACHMENT0_EXT, fftaTex, 0);
             state.checkGLErrors("__FramebufferTexture setup");
        #endif
             GLuint fboId = state.getGraphicsContext() ?
        state.getGraphicsContext()->__getDefaultFboId() : 0;
             fbo_ext->glBindFramebuffer(GL___FRAMEBUFFER_EXT, fboId);


             if(fbo_ext->__glCheckFramebufferStatus(GL___FRAMEBUFFER_EXT) !=
        GL_FRAMEBUFFER_COMPLETE_EXT) {
                 OSG_WARN << "Error while setting up Pingpong FBO.";
             }

             state.checkGLErrors("end of Framebuffer settings");

             glBindTexture( GL_TEXTURE_2D_ARRAY_EXT, 0 );

             glPopAttrib();

             _initialized = true;
             return true;
        }

        Adding such a drawable in my scene, i don't have any problem as
        long as
        ATTACH_TEXTURE is *undefined*. But when I define this, I still don't
        have any error reported by the drawable itself (all the
        checkGLErrors I
        inserted). But then getcontinous list of

        " Warning: detected OpenGL error 'invalid operation' at after
        RenderBin::draw(..)" messages :-(

        => Any idea what I'm doing wrong here ? How can I "enforce" the
        isolation between those openGL calls and what's left from the
        OSG scene
        ? after all, since this init function is called only once, there
        should
        not be any continous warning report if it didn't have a side effect
        outside of this drawable encapsulation...


        Thanks for you help !! I really feel desperated now... :'(

        Manu.





        _________________________________________________
        osg-users mailing list
        osg-users@lists.__openscenegraph.org
        <mailto:osg-users@lists.openscenegraph.org>
        
http://lists.openscenegraph.__org/listinfo.cgi/osg-users-__openscenegraph.org
        
<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
    <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.

    _________________________________________________
    osg-users mailing list
    osg-users@lists.__openscenegraph.org
    <mailto:osg-users@lists.openscenegraph.org>
    
http://lists.openscenegraph.__org/listinfo.cgi/osg-users-__openscenegraph.org
    <http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>




_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
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.

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to