I want to draw a 2D scene and after the scene i want to draw some light effects.
When i draw some light, i create a FBO, draw in it and when finished with drawing, i want to create a texture where i draw the content of the FBO.
My current code:
////////// //Init_ //Create Texture glActiveTexture(GL_TEXTURE0); glGenTextures(1, out _texfbo); glBindTexture(GL_TEXTURE_2D, _texfbo); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _screenWidth, _screenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); glBindTexture(GL_TEXTURE_2D, 0); //Create Renderbuffer glGenRenderbuffers(1, out _rb); glBindRenderbuffer(GL_RENDERBUFFER, _rb); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, _screenWidth, _screenHeight); glBindRenderbuffer(GL_RENDERBUFFER, 0); //Create Framebuffer glGenFramebuffers(1, out _fbo); glBindFramebuffer(GL_FRAMEBUFFER, _fbo); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texfbo, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _rb); glBindFramebuffer(GL_FRAMEBUFFER, 0); ////////// //Loop: glBindFramebuffer(GL_FRAMEBUFFER, _fbo); //Draw Scene glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindTexture(GL_TEXTURE_2D, _texfbo); //Draw Rectangle with texture from Framebuffer
The Scene is not drawn on the screen, i think that means it's drawn in the right buffer. But i can't get someting on the screen. What is wrong?