20 GLXFBConfig *configs = glXChooseFBConfig(display, DefaultScreen(display),
21 attributes, &configCount);
30 std::deque<FBConfig> candidates;
32 for (
int i = 0; i < configCount; i++) {
34 glXGetFBConfigAttrib(display, configs[i], GLX_DEPTH_SIZE, &depth);
35 glXGetFBConfigAttrib(display, configs[i], GLX_STENCIL_SIZE, &stencil);
37 candidates.emplace_back(FBConfig{configs[i], depth, stencil});
40 if (configCount > 0) {
44 std::stable_sort(candidates.begin(), candidates.end(), [](
const FBConfig &left,
const FBConfig &right) {
45 if (left.depth < right.depth) {
49 if (left.stencil < right.stencil) {
56 return candidates.empty() ? nullptr : candidates.front().config;