Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualmhagain

Posted 20 February 2013 - 07:41 PM

From the link I provided:

 

Associated Gets

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, &currentReadBuffer);
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.


#1mhagain

Posted 20 February 2013 - 07:32 PM

From the link I provided:

 

Associated Gets

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, &currentReadBuffer);
if (currentReadBuffer != GL_BACK) glReadBuffer (GL_BACK);

PARTNERS