From the link I provided:
glGet with argument GL_READ_BUFFER
Follow the "glGet" link and search for GL_READ_BUFFER and we find:
params returns one value, a symbolic constant indicating which color buffer is selected for reading. The initial value is GL_BACK if there is a back buffer, otherwise it is GL_FRONT.
Because we know that the read buffer is specified by a GLenum, and because we've read the documentation we know that a GLenum is just an integer, the code for it is:
// ensure that our read buffer is GL_BACK GLenum currentReadBuffer; glGetIntegerv (GL_READ_BUFFER, ¤tReadBuffer); if (currentReadBuffer != GL_BACK) glReadBuffer (GL_BACK);
Incidentally, if the only reason you want to read back the data is to transfer it to a texture, consider using (preferably) an FBO or (alternatively) glCopyTexImage2D or glCopyTexSubImage2D. Either way will put the data into a texture directly on the GPU without needing a round-trip to-and-from system memory beforehand.
Also, you're not calling glBindTexture before your glTexImage2D in your code. Not to mention generating a brand-new texture object each frame. I'd suggest after all this that you may get more benefit from jumping back to more basic tutorial work instead of trying anything too fancy right now, because your approach appears to be one of hacking-and-slashing at code rather than working to understand what's actually happening and what you actually need to do.