PDA

View Full Version : Weird FPS camera and framebuffer problem



syntax_error
06-27-2016, 03:01 AM
I am following this tutorial (http://learnopengl.com/#!Advanced-OpenGL/Framebuffers) about framebuffers in OpenGL. I have implemented a FPS camera before and now I implemented the framebuffer.
Now as long as I don't use any controls (WASD and mouse) it works perfectly. But as soon as I move the camera around, a weird error happens (http://imgur.com/STWTzX9).
It's as if the contents of the framebuffer texture from the last frame aren't erased, but just the current frame's contents are added.

I am using the object class from my previous question and a camera class and I'm also loading shaders with a function from another file, but it has nothing to do with this.

Code
main.cpp (http://pastebin.com/2DCqvz7r)
object.h (http://pastebin.com/tTZ0SVKS)
camera.h (http://pastebin.com/y3iPBHH5)
Shaders (for the framebuffer texture quad) (http://pastebin.com/AAtttVbk)

What am I missing?

Silence
06-27-2016, 06:05 AM
It's as if the contents of the framebuffer texture from the last frame aren't erased, but just the current frame's contents are added.

I did not read your code, but I'm pretty sure you made the right assumption. Just clear the FBO before rendering the new image, just like you clear other buffers.

See this: https://www.opengl.org/wiki/Framebuffer#Buffer_clearing

syntax_error
06-27-2016, 08:50 AM
Just clear the FBO before rendering the new image, just like you clear other buffers.
Exactly. Calling glClearColor and glClear after glBindFramebuffer fixed the problem.

Thanks