Strange things happens when gettings attributes from glx config.

#1

Hi! There is a function to get XVisualInfo from config but not to get config from XVisualInfo, so I had to search the which config matche to the visual info. (Before passing the config to create the glx context)


int nbConfigs = 0;
            GLXFBConfig* configs = glXChooseFBConfig(m_display, DefaultScreen(m_display), NULL, &nbConfigs);
            int bestVersionMajor = 0, bestVersionMinor = 0, bestDepthBits = 0, bestStencilBits = 0, bestAntiAliasingLevel = 0;
            for (int i = 0; configs && (i < nbConfigs); ++i)
            {
                XVisualInfo* visual = glXGetVisualFromFBConfig(m_display, configs[i]);

                if (!visual)
                    continue;

                if (visual->visualid == vi->visualid)
                {
                    bestFbc = &configs[i];
                    XFree(visual);
                    break;
                }
                glXGetConfig(m_display,vi,GLX_CONTEXT_MAJOR_VERSION_ARB, &versionMajor);
                glXGetConfig(m_display,vi,GLX_CONTEXT_MINOR_VERSION_ARB, &versionMinor);
                glXGetConfig(m_display,vi,GLX_DEPTH_SIZE, &depthBits);
                glXGetConfig(m_display,vi,GLX_STENCIL_SIZE, &stencilBits);
                glXGetConfig(m_display,vi,GLX_SAMPLES, &antiAliasingLevel);
                if (versionMajor > bestVersionMajor) {
                    bestVersionMajor = versionMajor;
                    settings.versionMajor = versionMajor;
                }
                if (versionMinor > bestVersionMinor) {
                    bestVersionMinor = versionMinor;
                    settings.versionMinor = versionMinor;
                }
                if (depthBits > bestDepthBits) {
                    bestDepthBits = depthBits;
                    settings.depthBits = depthBits;
                }
                if (stencilBits > bestStencilBits) {
                    bestStencilBits = stencilBits;
                    settings.stencilBits = stencilBits;
                }
                if (antiAliasingLevel > bestAntiAliasingLevel) {
                    bestAntiAliasingLevel = antiAliasingLevel;
                    settings.antiAliasingLevel = antiAliasingLevel;
                }
                XFree(visual);
            }

But glxGetConfig doesn’t return the correct attributes values, when the visual info have a depthBits config of 24 by example it returns 0.

#2

Ok I retrieve the number of visuals (Like SFML does) instead of getting the number of configs matching a specific configuration like it’s explained on this link :
https://www.khronos.org/opengl/wiki/Tutorial:OpenGL_3.0_Context_Creation(GLX)
And it works.