Use 2D version of glFramebufferTexture

glFramebufferTexture is not supported on GL 3.1 context, while
glFramebufferTexture2D is.
Also fix an inverted comparaison.