Skip to content

Commit

Permalink
glxinfo: Query GLX extensions for correct X screen
Browse files Browse the repository at this point in the history
It is possible that the GLX implementation for one X screen supports
GLX_ARB_create_context_profile or GLX_EXT_create_context_es2_profile
while the GLX implementation for another X screen doesn't.
  • Loading branch information
dcommander committed Feb 15, 2024
1 parent ca6dcfa commit 2975d46
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions demos/glxinfo.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
* Copyright (C) 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (C) 2011, 2013, 2015, 2019, 2022 D. R. Commander
* All Rights Reserved.
* Copyright (C) 2011, 2013, 2015, 2019, 2022, 2024 D. R. Commander
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -183,8 +183,8 @@ create_context_error_handler(Display *dpy, XErrorEvent *error)
* (at least w/ NVIDIA).
*/
static GLXContext
create_context_flags(Display *dpy, GLXFBConfig fbconfig, int major, int minor,
int contextFlags, int profileMask, Bool direct)
create_context_flags(Display *dpy, int scrnum, GLXFBConfig fbconfig, int major,
int minor, int contextFlags, int profileMask, Bool direct)
{
#ifdef GLX_ARB_create_context
static PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB_func = 0;
Expand All @@ -198,7 +198,7 @@ create_context_flags(Display *dpy, GLXFBConfig fbconfig, int major, int minor,
/* See if we have GLX_ARB_create_context_profile and get pointer to
* glXCreateContextAttribsARB() function.
*/
const char *glxExt = glXQueryExtensionsString(dpy, 0);
const char *glxExt = glXQueryExtensionsString(dpy, scrnum);
if (extension_supported("GLX_ARB_create_context_profile", glxExt)) {
glXCreateContextAttribsARB_func = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
glXGetProcAddress((const GLubyte *) "glXCreateContextAttribsARB");
Expand Down Expand Up @@ -263,7 +263,7 @@ create_context_flags(Display *dpy, GLXFBConfig fbconfig, int major, int minor,
* Try to create a GLX context of the newest version.
*/
static GLXContext
create_context_with_config(Display *dpy, GLXFBConfig config,
create_context_with_config(Display *dpy, int scrnum, GLXFBConfig config,
Bool coreProfile, Bool es2Profile, Bool direct)
{
GLXContext ctx = 0;
Expand All @@ -278,7 +278,7 @@ create_context_with_config(Display *dpy, GLXFBConfig config,
if (gl_versions[i].major == 3 &&
gl_versions[i].minor == 0)
return 0;
ctx = create_context_flags(dpy, config,
ctx = create_context_flags(dpy, scrnum, config,
gl_versions[i].major,
gl_versions[i].minor,
0x0,
Expand All @@ -294,8 +294,8 @@ create_context_with_config(Display *dpy, GLXFBConfig config,
if (es2Profile) {
#ifdef GLX_CONTEXT_ES2_PROFILE_BIT_EXT
if (extension_supported("GLX_EXT_create_context_es2_profile",
glXQueryExtensionsString(dpy, 0))) {
ctx = create_context_flags(dpy, config, 2, 0, 0x0,
glXQueryExtensionsString(dpy, scrnum))) {
ctx = create_context_flags(dpy, scrnum, config, 2, 0, 0x0,
GLX_CONTEXT_ES2_PROFILE_BIT_EXT,
direct);
return ctx;
Expand Down Expand Up @@ -418,12 +418,12 @@ print_screen_info(Display *dpy, int scrnum,
*/
fbconfigs = choose_fb_config(dpy, scrnum);
if (fbconfigs) {
ctx = create_context_with_config(dpy, fbconfigs[0],
ctx = create_context_with_config(dpy, scrnum, fbconfigs[0],
coreProfile, es2Profile,
opts->allowDirect);
if (!ctx && opts->allowDirect && !coreProfile) {
/* try indirect */
ctx = create_context_with_config(dpy, fbconfigs[0],
ctx = create_context_with_config(dpy, scrnum, fbconfigs[0],
coreProfile, es2Profile, False);
}

Expand Down

0 comments on commit 2975d46

Please sign in to comment.