Gl tex formats simplification

Fixes #3039 and refactors the GL texture enum handling code to simplify it. Also fixes wrong hex number on GL_RG (it is 0x8277 instead of 0x8227) and simplifies glReadPixels to use the same machinery.
does this and the one after it not need `numChannels*`?