At my company, we are working on huge library, which is a platform independent renderer (but it's main pupropse is not to be used with games, but with professional and office apps). Everything is going fine, we have already a very efficient D3D11 and OpenGL renderers, as well as 'software' renderers for Windows and Linux (GDI/X11).

Recently, we have started to implement additional improvements in lower layers of our API. We thought it may be good idea to test them also on slower machines. Because update interacts with OpenGL-specific logic, this specific version needs to be tested.

We have implemented RTT (Render To Texture) in GL using core framebuffer object. Because older HW wasn't able to work with this solution (no ARB_framebuffer support), we have created simple wrapper, which detects supported version of FBO (ARB_fb_object or EXT_fb_object) and wraps all cals in a transprent way. Example from creating depth stencil attachment:
Code :
    gxFBO::gen_renderbuffers(1, &stencil_buffer_id);
    gxFBO::bind_renderbuffer(GX_RENDERBUFFER, stencil_buffer_id);
    gxFBO::renderbuffer_storage(GX_RENDERBUFFER, GX_DEPTH24_STENCIL8, width, height);
    gxFBO::bind_renderbuffer(GX_RENDERBUFFER, 0);
    gxFBO::framebuffer_renderbuffer(GX_FRAMEBUFFER, GX_DEPTH_STENCIL_ATTACHMENT, stencil_buffer_id);
    gxFBO::check_framebuffer_status();

Quick explanation: functions calls are equivalent to gl* versions (for example, gxFBO::renderbuffer_storage() calls internally glRenderbufferStorage() or glRenderbufferStorageEXT(), based on supported version). Preprocessor constants are also the same (GX_DEPTH24_STENCIL8 = (GL_DEPTH24_STENCIL8 or GL_DEPTH24_STENCIL8_EXT)).

This works perfectly fine on hardware with 3.0+ support (everything renders correctly). It fails, however on older hardware (with GL 2.1 and EXT_framebuffer support).

Returned error in gxFBO::check_framebuffer_status() is: GL_FRAMEBUFFER_UNSUPPORTED_EXT.

I also tried to create separate renderbuffers for depth and stencil:

Code :
    gxFBO::gen_renderbuffers(1, &depth_buffer_id);
    gxFBO::gen_renderbuffers(1, &stencil_buffer_id);
 
    gxFBO::bind_renderbuffer(GX_RENDERBUFFER, depth_buffer_id);
    gxFBO::renderbuffer_storage(GX_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
 
    gxFBO::bind_renderbuffer(GX_RENDERBUFFER, stencil_buffer_id);   
    gxFBO::renderbuffer_storage(GX_RENDERBUFFER, GX_STENCIL_INDEX8, width, height);
    gxFBO::bind_renderbuffer(GX_RENDERBUFFER, 0);
 
    gxFBO::framebuffer_renderbuffer(GX_FRAMEBUFFER,
                    GX_DEPTH_ATTACHMENT,
                    GX_RENDERBUFFER, 
                    depth_buffer_id);
 
    gxFBO::framebuffer_renderbuffer(GX_FRAMEBUFFER,
                    GX_STENCIL_ATTACHMENT,
                    GX_RENDERBUFFER, 
                    stencil_buffer_id);
 
    gxFBO::check_framebuffer_status();

Same error at framebuffer status check. Could anyone help with proper setup in this case? Is it possible to do what I'm trying to do using GL_EXT_framebuffer?

Thanks in advance for any help.