I've been attempting to implement deferred shading/rendering into my engine for a while now, however I haven't been able to actually see the final product of it.
To test where the issue may lie, I've devised an experiment to see if my target FBO was actually being read from and into my default FBO, via the glBlitFramebuffer() command.
I've made it so that before my default FBO clears itself, the clear color was set to black, and before my target FBO clears itself the clear color was set to red.
The result is that when I render my scene, all I see is black.
If one fbo is set to a read_framebuffer, and the default is set to a draw_framebuffer, would the "clear colored" pixels also get copied during the "glBlitFramebuffer" operation?
If no, then there is no telling whether or not my target FBO is actually being rendered, as that color wouldn't copy anyways.
If yes, then I should be seeing the color red, and I have no idea what is wrong with my FBO set up...
As I've previously stated, I've been trying to work on a deferred shading system. That system required me to perform all my operations in an FBO, and then render its entirety back onto the default FBO.
Since it wasn't working, I've simplified its procedure to either render a basic scene straight to the default FBO (which works), or render it onto a target FBO and follow the procedure to copy that FBO back onto the default FBO (which doesn't work).
The frame buffer set up I'm trying to use is the same as the tutorial I've been following:
glGenFramebuffers(1, &m_fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo);
glGenTextures(1, &m_finalTexture);
glBindTexture(GL_TEXTURE_2D, m_finalTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WindowWidth, WindowHeight, 0, GL_RGB, GL_FLOAT, NULL);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT4, GL_TEXTURE_2D, m_finalTexture, 0);
And I render my scene like this (simplified):
//Flush content out of fbo at color attachment 4
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo);
glDrawBuffer(GL_COLOR_ATTACHMENT4);
glClear(GL_COLOR_BUFFER_BIT);
//Render scene to m_fbo
RenderPass();
//Swap default FBO back ("0"), read from target fbo (m_fbo)
//Draw target fbo onto default fbo
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo);
glDrawBuffer(GL_COLOR_ATTACHMENT4);
glReadBuffer(GL_COLOR_ATTACHMENT4);
glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
I've checked my frame buffer status every step of the way and I get no errors.
The problem all along was that my call to bind the default frame buffer just wouldn't work if done outside of the main rendering class. So I moved that line out of my GBuffer and into my main rendering class and performed that before calling GBuffer.FinalPass();