glReadPixels for writing large Jpeg (4096 x 4096)?

Hi everybody
I am new in this forum and beginner in openGL, and I am trying to use openGL for creating a lot of Jpeg 3D-images.
I’d like to use glReadPixels to generate large Jpeg images, like 4096 x 4096, but I can not go beyond the size of my screen, that is only 1280 x 800, so that all the pixels in my jpeg that don’t correspond to a pixel in the screen are black.
On the reference page of glReadPixels it is said
“Values for pixels that lie outside the window connected to the current GL context are undefined”, so I tried to create a windows of size “4096 x 4096”, but it changes nothing, the Jpeg is still black outside the sreen. (I use SDL, so I wrote “SDL_SetVideoMode(4096,4096,32,SDL_OPENGL);”)
Is there another way to try to do it?
Thank you for your help

Render offscreen with an FBO (frame buffer object):

  1. Initialize a texture object of size 4096x4096 ( check first that glGetInteger(GL_MAX_TEXTURE_SIZE,&size) returns something greater or equal to 4096
  2. Attach the texture object to an FBO
  3. render in the FBO
  4. Transfer the contents of the texture in VRAM back to the RAM with glGetTexImage()

thanks. I will try it very soon.

Yes it works. Thanks again!