3
votes

How do I create an OpenGL context in my program (C++) which will be used purely internally? That is, it will render a scene, then I will grab the pixel data to use in the rest of the program (saving to an image is a close-enough analogy — I'm fine with the framebuffer stuff, I just need to create the context).

I don't need a window at all, and this only needs to work on Unix (specifically OSX and Ubuntu, if the solution is different for each then Ubuntu is more important). I don't want to use GLUT or similar if I can help it.

2

2 Answers

4
votes
3
votes

I don't need a window at all

If you want this to work across all GPUs and installations on Linux you will have to use a X server (until off-screen EGL support is widespread, but so far NVidia told they won't support it). You can use either a GLX PBuffer or a unmapped (=invisible) window. The X server must be active, i.e. not being detached or on a inactive VT, so that it actually utilizes the GPU.

only needs to work on Unix (specifically OSX and Ubuntu

The way OpenGL is done in Linux and MacOS X is very, very different!