I want to create a program that renders an openGL scene without creating any window. I need to do this because this is for a GIMP plugin than will open some file formats i render with OpenGL. The idea is to render the image with the desirable values (rotation,scale,shadows,…) and then read this an pass it to the GIMP. I think I can´t do this with glReadPixels() but i´m not sure.
Other idea I had was to redirect a buffer in openGL to a layer in a GIMP image so I can interact directly with OpenGL and don´t need to reload the image every time any value chages, but i think it´s impossible or almost very difficult.
You can’t do any OpenGL rendering without a window. Why? It’s simple - you need a window handle. If you ´write fro GIMP it would mean that you are under linux, right? Got no clue how one program under linux, but that’s how I would do it under windows:
I would create a fake window(not visible one, for example) and make a context for it to querry the pbbuffer extensions. Than I would create a pbuffer etc… and then comes ReadPixels or GetTextureImage
Well you’d normally use pbuffers for this to get an offscreen rendering context. There are a couple of ways to go. One would rely on hardware rendering capabilities and offscreen pbuffer contexts, the other would be to use Mesa software rendering to an offscreen buffer, that may be the fallback of the DRI anyway but your results would be more consistent and less prone to driver implementation issues. This is old info but still useful, the pbuffer extension has become more standard since then and ofcourse the whole DRI infrastructure is in place for Linux with the Mesa software path too: