From f10a08efde0ace7cb701577a4ca334598b47b8c3 Mon Sep 17 00:00:00 2001 From: DRC Date: Tue, 27 Feb 2024 21:45:27 -0500 Subject: [PATCH] GLXSpheres: Fix segfault w/ -srgb We can't check for the existence of GLX_EXT_framebuffer_sRGB until the X display has been opened. Oops. --- demos/glxspheres.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/demos/glxspheres.c b/demos/glxspheres.c index 4b87bf34..e459cf19 100644 --- a/demos/glxspheres.c +++ b/demos/glxspheres.c @@ -1,5 +1,5 @@ /* Copyright (C)2007 Sun Microsystems, Inc. - * Copyright (C)2011, 2013-2015, 2017-2019, 2021-2022 D. R. Commander + * Copyright (C)2011, 2013-2015, 2017-2019, 2021-2022, 2024 D. R. Commander * * This library is free software and may be redistributed and/or modified under * the terms of the wxWindows Library License, Version 3.1 or (at your option) @@ -527,8 +527,6 @@ int main(int argc, char **argv) } else if(!stricmp(argv[i], "-srgb")) { - if(!GLX_EXTENSION_EXISTS(GLX_EXT_framebuffer_sRGB)) - THROW("GLX_EXT_framebuffer_sRGB extension is not available"); useSRGB = 1; rgbAttribs[17] = 1; } else if(!stricmp(argv[i], "-s")) @@ -589,6 +587,9 @@ int main(int argc, char **argv) rgbAttribs[19] = 32 - bpc * 3; } + if(!GLX_EXTENSION_EXISTS(GLX_EXT_framebuffer_sRGB)) + THROW("GLX_EXT_framebuffer_sRGB extension is not available"); + c = glXChooseFBConfig(dpy, screen, rgbAttribs, &n); if(!c || n < 1) THROW("Could not obtain RGB visual with requested properties");