mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 09:28:07 +02:00
glxinfo: Try creating a GLX context using an fbconfig if no visuals are available.
This commit is contained in:
parent
950fff0f9a
commit
a074857cdc
1 changed files with 46 additions and 13 deletions
|
|
@ -395,20 +395,61 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits)
|
|||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
GLXContext ctx;
|
||||
GLXContext ctx = NULL;
|
||||
XVisualInfo *visinfo;
|
||||
int width = 100, height = 100;
|
||||
|
||||
root = RootWindow(dpy, scrnum);
|
||||
|
||||
visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
|
||||
if (!visinfo) {
|
||||
if (!visinfo)
|
||||
visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
|
||||
if (!visinfo) {
|
||||
fprintf(stderr, "Error: couldn't find RGB GLX visual\n");
|
||||
return;
|
||||
|
||||
if (visinfo)
|
||||
ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect );
|
||||
|
||||
#ifdef GLX_VERSION_1_3
|
||||
{
|
||||
int fbAttribSingle[] = {
|
||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER, GL_TRUE,
|
||||
None };
|
||||
int fbAttribDouble[] = {
|
||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
None };
|
||||
GLXFBConfig *configs = NULL;
|
||||
int nConfigs;
|
||||
|
||||
if (!visinfo)
|
||||
configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs);
|
||||
if (!visinfo)
|
||||
configs = glXChooseFBConfig(dpy, scrnum, fbAttribDouble, &nConfigs);
|
||||
|
||||
if (configs) {
|
||||
visinfo = glXGetVisualFromFBConfig(dpy, configs[0]);
|
||||
ctx = glXCreateNewContext(dpy, configs[0], GLX_RGBA_TYPE, NULL, allowDirect);
|
||||
XFree(configs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!visinfo) {
|
||||
fprintf(stderr, "Error: couldn't find RGB GLX visual or fbconfig\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ctx) {
|
||||
fprintf(stderr, "Error: glXCreateContext failed\n");
|
||||
XFree(visinfo);
|
||||
XDestroyWindow(dpy, win);
|
||||
return;
|
||||
}
|
||||
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
|
|
@ -419,14 +460,6 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits)
|
|||
0, visinfo->depth, InputOutput,
|
||||
visinfo->visual, mask, &attr);
|
||||
|
||||
ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect );
|
||||
if (!ctx) {
|
||||
fprintf(stderr, "Error: glXCreateContext failed\n");
|
||||
XFree(visinfo);
|
||||
XDestroyWindow(dpy, win);
|
||||
return;
|
||||
}
|
||||
|
||||
if (glXMakeCurrent(dpy, win, ctx)) {
|
||||
const char *serverVendor = glXQueryServerString(dpy, scrnum, GLX_VENDOR);
|
||||
const char *serverVersion = glXQueryServerString(dpy, scrnum, GLX_VERSION);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue