Skip to content

Commit

Permalink
GLXSpheres: Fix segfault w/ -srgb
Browse files Browse the repository at this point in the history
We can't check for the existence of GLX_EXT_framebuffer_sRGB until the
X display has been opened.  Oops.
  • Loading branch information
dcommander committed Feb 28, 2024
1 parent 5217ce2 commit f10a08e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions demos/glxspheres.c
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit f10a08e

Please sign in to comment.