render to a buffer instead of screen and controlling the clipping

I am writing a program where I need to save a opengl scene as a image. The writing code is already working except one thing: The application is resizable and therefor the screenshot also is variable in size. Therefor I tried the gluscaleimage() that worked but as it seem to create horrible results if the window is very small I cant really use it.

Instead my idea is to adjust the viewport to whatever resolution I want the image in, render the scene to a buffer instead of screen (that is; a buffer that is not the framebuffer), and writing the buffer to file. However I do not know how to render to a buffer (if its even possible). I tried doing it with the framebuffer (adjusting the viewport) but the part of the scene that was outside the edges of the window was cut away. Other than that it worked as wanted. Any ideas on how to fix this problem?

use FBO

Originally posted by shelll:
use FBO
You know if FBO is supported by JOGL?

It’s better that you use from glReadPixels() to save the results of the framebuffer into a file.

FBO’s are new and maybe your implementation doesn’t support it. But as i remember, both the Render buffer object and Frame buffer object are part of the OpenGL extenstions. So you should query them to see if they are supported with your OpenGL implementation.
Here’s some useful information about the EXT_framebuffer_object extension:

http://www.opengl.org/documentation/extensions/EXT_framebuffer_object.txt

-Ehsan-