Reputation: 6958
I'm learning OpenGL under X11 with xcb and I'm having a hard time figuring out the difference between visuals and fbconfigs (the ones you find in glxinfo
)
As far as I could see a visual is a set of properties related to depth buffer, stencil buffer, framebuffer, etc.. what's the difference with fbconfigs and why would one be preferable to the other?
Upvotes: 6
Views: 3001
Reputation: 45352
The visual is a concept of X11 itself. It describes the color encoding properties. A particular X11 server my supper a set of different visuals, and and X11 client (graphical application) may choose one that is best suited for it's use case. Every X11 window is created with respect to one visual. See the documentation about X11 visual types for details.
On an X11 server with the glX extension, there are a couple of such visuals which provide hardware accelerated rendering via OpenGL. Before you can create a X11 window which you're going to use for GL rendering, you need to query a suitable visual. In traditional glX, you would use for example glXChooseVisual
to do that.
A GLXFBConfig
on the other hand is a entity that is only relevant for GLX itself, the classical X server does not know anything about it. GLXFBconfigs can be used to create off-screen rendering buffers called P-Buffers (which are kind of obsolete nowadays, though).
One could classify FBConfigs into two groups:
glXGetVisualFromFBConfig
to query that.FBConfigs provide a newer and more flexible interface via glxChooseFBConfig
, so it is preferable alwyas to use the FBConfig API, even if you want an off-screen window.
What a typical GL implementation will do is to provide an FBconfig for each visual type it is supporting, so you should find those twice in the glxinfo
output: as the actual visuals, and as more or less identical fbconfigs. Additionally, it will offer some more fbconfigs with formats which would be untypical for X11 windows (like more than 32bit color depth).
Upvotes: 6
Reputation: 7198
In the X Window System a Visual encapsulates the color mapping (color type, color depth) for a Display. The same Display can be configured with different Visuals.
When OpenGL was born, about a decade after X System, a structure XVisualInfo
was created in the OGL part, not in the X System. This new structure extended the Visual
type by adding more features, such as ancillary buffers, double buffer, and stereo. This XVisualInfo
was used to create the gl-context.
In 1998 the GLX 1.3 specification (find it at Khronos page), added more features, notably GLXPbuffer
for off-screen rendering, but easier than GLXPixmap
. Also added were transparency, multi-sampling, and samples buffers. The configuration for the GLXDrawable
(Window or GLXPixmap, or now also GLXWindow and GLXPbuffer) was going too different from the Visual abilities, and so GLXFBConfig
was introduced.
The current GLX 1.4 specification allows, for backwards compatibility reasons and if you don't use GLX>1.2 features, the use of XVisualInfo
. But the prefered way of creating a context is by GLXFBConfig.
Notice that rendering to a GLXPbuffer does not use a X Visual. Notice also that using Framebuffer objects since OGL 3.0 makes obsolete the use of GLXPbuffer.
Upvotes: 4