got pink screen after adding render target texture

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
gtimworks
Posts: 21
Joined: Sun Nov 03, 2013 8:07 pm

got pink screen after adding render target texture

Post by gtimworks »

Hi all,

I am new to Irrlicht. this is my first post.

I am using the prerelease 1.9 on iOS. I managed to have it work, even with my own simple diffuse light shader. Then I decided to write my own SSAO shader. I followed tutorial 13 (Render To Texture) to create a texture as rendering target. However after adding the following line

Code: Select all

    _rt = _pIrrDriver->addRenderTargetTexture(irr::core::dimension2du(480, 320),
                              "RTT1");
 
even without referring to the variable "_rt" anywhere in my code, I got a pink screen.

I am guessing this is something related to a FBO which is created and bind somewhere inside this function.I looked the code and it looks like by the end of the function driver binds back to NULL so the original rendering target should be used.

I couldn't figure out what went wrong, needs some hint here.

Thanks,

gtimworks
gtimworks
Posts: 21
Joined: Sun Nov 03, 2013 8:07 pm

Re: got pink screen after adding render target texture

Post by gtimworks »

OK I think I figured out what went wrong.

in file COGLES2Texture.cpp, function unbindRTT()

Code: Select all

 
void COGLES2FBOTexture::unbindRTT()
{
    if (ColorFrameBuffer != 0)
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
 
The intension of the code is to bind the frame buffer back to the default one. However, According to the link http://stackoverflow.com/questions/1076 ... ramebuffer, answer 2, quoted as below.
I feel it's necessary to point out here that the call to glBindFramebuffer(GL_FRAMEBUFFER, 0); does not return rendering to the main framebuffer although it would appear to work for machines that run Windows, Unix(Mac) or Linux. Desktops and laptops have no concept of a main default system buffer. This idea started with handheld devices. When you make an openGL bind call with zero as the parameter then what you are doing is setting this function to NULL. It's how you disable this function.
this function will NOT return rendering to the main frame buffer but instead it will have it disabled. A simple change from

Code: Select all

        glBindFramebuffer(GL_FRAMEBUFFER, 0);
 
to

Code: Select all

        glBindFramebuffer(GL_FRAMEBUFFER, 1);
 
will make it work since when the main frame buffer created in COGLRES2Driver constructor the handle of the default frame buffer is "1".

The proper behaviour should be binding back to the default frame buffer when unbinding a texture. This is true for all the platforms, not just iOS. Currently function unbindRTT() for all platforms has the same logic, it looks to me all of them should be updated.
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: got pink screen after adding render target texture

Post by CuteAlien »

Thanks - I'll move this to the bugreports forum for now.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply