handle framebuffer set to 0
get the current FBO from the primary surface, fixes #2391
TODO note
Merge remote-tracking branch 'remotes/upstream/master'