openglglx

When rendering OpenGL to offscreen framebuffer, is windowing system support still needed?


If all I want to do is to do some rendering with OpenGL functions, without even creating a window. Do I still need to use libraries like glx to bind OpenGL with platform windowing system?

If I don't need to, then where is OpenGL context created? As I need to use functions like glXCreateContext to create an OpenGL context. But if I remember right, every OpenGL program needs a context. So there seems to be a contradiction?

Hope someone can clarify this for me.


Solution

  • OpenGL itself (the specification) does not impose any requirements on window system integration and where and how a render context can be obtained. It is perfectly legal for a OpenGL implementation to offer off-screen context creation. The practical question is: Which OpenGL implementations do this and what's the API for that.

    On Linux with DRI/DRM/Mesa a window and screenless OpenGL context can be created with the GBM API/library on KMS supported GPUs.

    Also Mesa has an Off-Screen-Mesa variant (OSMesa), which however at the moment only does software based rendering (llvmpipe or softpipe), but it might add GPU support later.

    EGL (the Khronos cross platform API for context management) also offers windowless/screenless context creation options, that are optional to be supported by drivers. At least the NVidia proprietary drivers do support it: https://devblogs.nvidia.com/parallelforall/egl-eye-opengl-visualization-without-x-server/