FBOs and Shaders

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

FBOs and Shaders

bgroenks96
This is probably more of a general OpenGL question than just JOGL, but I'm trying to figure out how to get my shaders to render to the currently bound FBO?

I tried glBindFragDataLocation, but that didn't seem to work properly.

If anyone could just tell me the appropriate steps to set up that kind of system, I would really appreciate it :)

Thanks for your time!
Reply | Threaded
Open this post in threaded view
|

Re: FBOs and Shaders

Sven Gothel
Administrator
On 02/13/2014 05:46 AM, bgroenks96 [via jogamp] wrote:
> This is probably more of a general OpenGL question than just JOGL, but I'm
> trying to figure out how to get my shaders to render to the currently bound FBO?

Simply by binding the FBO, i.e. FBObject.bind(GL gl):
    if(samples > 0 && fullFBOSupport) {
        // draw to multisampling - read from samplesSink
        gl.glBindFramebuffer(GL2ES3.GL_DRAW_FRAMEBUFFER, getWriteFramebuffer());
        gl.glBindFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER, getReadFramebuffer());
    } else {
        // one for all
        gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, getWriteFramebuffer());
    }

Look at our unit test demo code: FBOMix2DemosES2.

~Sven



signature.asc (894 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: FBOs and Shaders

bgroenks96
Sven Gothel wrote
Simply by binding the FBO, i.e. FBObject.bind(GL gl):
    if(samples > 0 && fullFBOSupport) {
        // draw to multisampling - read from samplesSink
        gl.glBindFramebuffer(GL2ES3.GL_DRAW_FRAMEBUFFER, getWriteFramebuffer());
        gl.glBindFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER, getReadFramebuffer());
    } else {
        // one for all
        gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, getWriteFramebuffer());
    }
I have the FBO bound, and I do syncSamplingSink before drawing to screen.  It works if I draw via FFP, but when I draw using the shaders, the window remains black.  Do I need to set a particular sampler in the frag shader or something?