render a scene without an opengl window

i want to write an opengl program that it can render the scene but it has no
opengl window. it record the rendered images in files. who can give me some
suggestion on how to do it or some similar opengl code?thanks very much

You need to have a window and set the pixel format (on windowing GUI anyway).

PS: Did you do a search to try to find some information before posting this?

You could probably do it with a PBuffer. Render to that, and you should be able to copy the data out, without the need to create a window.

You need to create a window to get a context so that you can get the extensions for using pbuffers, though. However, nothing says that this window has to be visible :slight_smile:

If you’re using Windows, you might be able to to choose a pixel format with the PFD_DRAW_TO_BITMAP flag without creating a window. As far as I know, only the generic implementation can do this, so you’ll be limited to (almost) unextended OpenGL 1.1. This all assumes that it is possible to get a handle to a device context for the desktop, which I’m not sure of. You might want to look into this, though.

i have found something
but my program is written in glut. i really don’t know how to deal with it under glut.

you can use the glCopyPixels function tu grab what you have on a portion of the
window (or on the entire window) into a buffer. Notice that the size of a line of your image must be align on a multiple of 4 (so take care qhen reserving
memory for the buffer). You can then write the contents of the buffer into
a file (like a BMP for example).