Remove sRGB framebuffer config filtering and add some debug output.

This commit is contained in:
Roz K 2022-12-16 03:21:10 +01:00
parent 8f3612bed2
commit fa7f1bdaa9
Signed by: roz
GPG Key ID: 51FBF4E483E1C822

View File

@ -109,19 +109,17 @@ rk_window_t rk_create_context(
int fbcount; int fbcount;
GLXFBConfig * const fbc = glXChooseFBConfig(rk_display, DefaultScreen(rk_display), rk_visual_attribs, &fbcount); GLXFBConfig * const fbc = glXChooseFBConfig(rk_display, DefaultScreen(rk_display), rk_visual_attribs, &fbcount);
if (!fbc) { if (!fbc) {
rk_printf("Failed to retrieve a framebuffer config."); rk_printf("Failed to retrieve framebuffer configs.");
rk_destroy_context(); rk_destroy_context();
return nullptr; return nullptr;
} }
printf("[GLX] Found %d framebuffer configs.\n", fbcount);
int best_fbc = -1; int best_fbc = -1;
int best_num_samp = -1; int best_num_samp = -1;
for (int i = 0; i < fbcount; ++i) { for (int i = 0; i < fbcount; ++i) {
XVisualInfo * vi = glXGetVisualFromFBConfig(rk_display, fbc[i]); XVisualInfo * vi = glXGetVisualFromFBConfig(rk_display, fbc[i]);
if (vi) { if (vi) {
int srgb = 0;
glXGetFBConfigAttrib(rk_display, fbc[i], GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &srgb);
if (srgb) {
int samp_buf, samples; int samp_buf, samples;
glXGetFBConfigAttrib(rk_display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf); glXGetFBConfigAttrib(rk_display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf);
glXGetFBConfigAttrib(rk_display, fbc[i], GLX_SAMPLES, &samples); glXGetFBConfigAttrib(rk_display, fbc[i], GLX_SAMPLES, &samples);
@ -129,18 +127,18 @@ rk_window_t rk_create_context(
best_fbc = i; best_fbc = i;
best_num_samp = samples; best_num_samp = samples;
} }
}
XFree(vi); XFree(vi);
} }
} }
if (best_fbc == -1) { if (best_fbc == -1) {
XFree(fbc); XFree(fbc);
rk_printf("Failed to find sRGB framebuffer."); rk_printf("Failed to find a suitable framebuffer config.");
rk_destroy_context(); rk_destroy_context();
return nullptr; return nullptr;
} }
GLXFBConfig const bestFbc = fbc[best_fbc]; GLXFBConfig const bestFbc = fbc[best_fbc];
XFree(fbc); XFree(fbc);
printf("[GLX] Select framebuffer config with %d samples.\n", best_num_samp);
XVisualInfo * const vi = glXGetVisualFromFBConfig(rk_display, bestFbc); XVisualInfo * const vi = glXGetVisualFromFBConfig(rk_display, bestFbc);
rk_colormap = XCreateColormap(rk_display, RootWindow(rk_display, vi->screen), vi->visual, AllocNone); rk_colormap = XCreateColormap(rk_display, RootWindow(rk_display, vi->screen), vi->visual, AllocNone);