Use C99 booleans in config structs

This commit is contained in:
Camilla Löwy
2026-02-25 16:57:28 +01:00
parent f472380d7e
commit 0d15b54c7a
7 changed files with 70 additions and 80 deletions
+1 -1
View File
@@ -195,7 +195,7 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
{ {
current = alternatives + i; current = alternatives + i;
if (desired->stereo > 0 && current->stereo == 0) if (desired->stereo && !current->stereo)
{ {
// Stereo is a hard constraint // Stereo is a hard constraint
continue; continue;
+1 -1
View File
@@ -650,7 +650,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
if (ctxconfig->noerror) if (ctxconfig->noerror)
{ {
if (_glfw.egl.KHR_create_context_no_error) if (_glfw.egl.KHR_create_context_no_error)
SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE); SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, true);
} }
if (mask) if (mask)
+1 -3
View File
@@ -119,9 +119,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE); u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS); u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS);
u->stereo = getGLXFBConfigAttrib(n, GLX_STEREO);
if (getGLXFBConfigAttrib(n, GLX_STEREO))
u->stereo = GLFW_TRUE;
if (_glfw.glx.ARB_multisample) if (_glfw.glx.ARB_multisample)
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES); u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
+4 -4
View File
@@ -49,18 +49,18 @@ static GLFWerrorfun _glfwErrorCallback;
static GLFWallocator _glfwInitAllocator; static GLFWallocator _glfwInitAllocator;
static _GLFWinitconfig _glfwInitHints = static _GLFWinitconfig _glfwInitHints =
{ {
.hatButtons = GLFW_TRUE, .hatButtons = true,
.angleType = GLFW_ANGLE_PLATFORM_TYPE_NONE, .angleType = GLFW_ANGLE_PLATFORM_TYPE_NONE,
.platformID = GLFW_ANY_PLATFORM, .platformID = GLFW_ANY_PLATFORM,
.vulkanLoader = NULL, .vulkanLoader = NULL,
.ns = .ns =
{ {
.menubar = GLFW_TRUE, .menubar = true,
.chdir = GLFW_TRUE .chdir = true
}, },
.x11 = .x11 =
{ {
.xcbVulkanSurface = GLFW_TRUE, .xcbVulkanSurface = true,
}, },
.wl = .wl =
{ {
+26 -26
View File
@@ -374,16 +374,16 @@ struct _GLFWerror
// //
struct _GLFWinitconfig struct _GLFWinitconfig
{ {
GLFWbool hatButtons; bool hatButtons;
int angleType; int angleType;
int platformID; int platformID;
PFN_vkGetInstanceProcAddr vulkanLoader; PFN_vkGetInstanceProcAddr vulkanLoader;
struct { struct {
GLFWbool menubar; bool menubar;
GLFWbool chdir; bool chdir;
} ns; } ns;
struct { struct {
GLFWbool xcbVulkanSurface; bool xcbVulkanSurface;
} x11; } x11;
struct { struct {
int libdecorMode; int libdecorMode;
@@ -402,18 +402,18 @@ struct _GLFWwndconfig
int ypos; int ypos;
int width; int width;
int height; int height;
GLFWbool resizable; bool resizable;
GLFWbool visible; bool visible;
GLFWbool decorated; bool decorated;
GLFWbool focused; bool focused;
GLFWbool autoIconify; bool autoIconify;
GLFWbool floating; bool floating;
GLFWbool maximized; bool maximized;
GLFWbool centerCursor; bool centerCursor;
GLFWbool focusOnShow; bool focusOnShow;
GLFWbool mousePassthrough; bool mousePassthrough;
GLFWbool scaleToMonitor; bool scaleToMonitor;
GLFWbool scaleFramebuffer; bool scaleFramebuffer;
struct { struct {
char frameName[256]; char frameName[256];
} ns; } ns;
@@ -422,8 +422,8 @@ struct _GLFWwndconfig
char instanceName[256]; char instanceName[256];
} x11; } x11;
struct { struct {
GLFWbool keymenu; bool keymenu;
GLFWbool showDefault; bool showDefault;
} win32; } win32;
struct { struct {
char appId[256]; char appId[256];
@@ -442,15 +442,15 @@ struct _GLFWctxconfig
int source; int source;
int major; int major;
int minor; int minor;
GLFWbool forward; bool forward;
GLFWbool debug; bool debug;
GLFWbool noerror; bool noerror;
int profile; int profile;
int robustness; int robustness;
int release; int release;
_GLFWwindow* share; _GLFWwindow* share;
struct { struct {
GLFWbool offline; bool offline;
} nsgl; } nsgl;
}; };
@@ -475,11 +475,11 @@ struct _GLFWfbconfig
int accumBlueBits; int accumBlueBits;
int accumAlphaBits; int accumAlphaBits;
int auxBuffers; int auxBuffers;
GLFWbool stereo; bool stereo;
int samples; int samples;
GLFWbool sRGB; bool sRGB;
GLFWbool doublebuffer; bool doublebuffer;
GLFWbool transparent; bool transparent;
uintptr_t handle; uintptr_t handle;
}; };
+6 -14
View File
@@ -186,28 +186,22 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
u->accumAlphaBits = FIND_ATTRIB_VALUE(WGL_ACCUM_ALPHA_BITS_ARB); u->accumAlphaBits = FIND_ATTRIB_VALUE(WGL_ACCUM_ALPHA_BITS_ARB);
u->auxBuffers = FIND_ATTRIB_VALUE(WGL_AUX_BUFFERS_ARB); u->auxBuffers = FIND_ATTRIB_VALUE(WGL_AUX_BUFFERS_ARB);
u->stereo = FIND_ATTRIB_VALUE(WGL_STEREO_ARB);
if (FIND_ATTRIB_VALUE(WGL_STEREO_ARB))
u->stereo = GLFW_TRUE;
if (_glfw.wgl.ARB_multisample) if (_glfw.wgl.ARB_multisample)
u->samples = FIND_ATTRIB_VALUE(WGL_SAMPLES_ARB); u->samples = FIND_ATTRIB_VALUE(WGL_SAMPLES_ARB);
if (ctxconfig->client == GLFW_OPENGL_API) if (ctxconfig->client == GLFW_OPENGL_API)
{ {
if (_glfw.wgl.ARB_framebuffer_sRGB || if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB)
_glfw.wgl.EXT_framebuffer_sRGB) u->sRGB = FIND_ATTRIB_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
{
if (FIND_ATTRIB_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB))
u->sRGB = GLFW_TRUE;
}
} }
else else
{ {
if (_glfw.wgl.EXT_colorspace) if (_glfw.wgl.EXT_colorspace)
{ {
if (FIND_ATTRIB_VALUE(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT) if (FIND_ATTRIB_VALUE(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT)
u->sRGB = GLFW_TRUE; u->sRGB = true;
} }
} }
} }
@@ -261,9 +255,7 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
u->accumAlphaBits = pfd.cAccumAlphaBits; u->accumAlphaBits = pfd.cAccumAlphaBits;
u->auxBuffers = pfd.cAuxBuffers; u->auxBuffers = pfd.cAuxBuffers;
u->stereo = (pfd.dwFlags & PFD_STEREO);
if (pfd.dwFlags & PFD_STEREO)
u->stereo = GLFW_TRUE;
} }
u->handle = pixelFormat; u->handle = pixelFormat;
@@ -664,7 +656,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
if (ctxconfig->noerror) if (ctxconfig->noerror)
{ {
if (_glfw.wgl.ARB_create_context_no_error) if (_glfw.wgl.ARB_create_context_no_error)
SET_ATTRIB(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE); SET_ATTRIB(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, true);
} }
// NOTE: Only request an explicitly versioned context when necessary, as // NOTE: Only request an explicitly versioned context when necessary, as
+31 -31
View File
@@ -265,16 +265,16 @@ void glfwDefaultWindowHints(void)
// The default is a focused, visible, resizable window with decorations // The default is a focused, visible, resizable window with decorations
memset(&_glfw.hints.window, 0, sizeof(_glfw.hints.window)); memset(&_glfw.hints.window, 0, sizeof(_glfw.hints.window));
_glfw.hints.window.resizable = GLFW_TRUE; _glfw.hints.window.resizable = true;
_glfw.hints.window.visible = GLFW_TRUE; _glfw.hints.window.visible = true;
_glfw.hints.window.decorated = GLFW_TRUE; _glfw.hints.window.decorated = true;
_glfw.hints.window.focused = GLFW_TRUE; _glfw.hints.window.focused = true;
_glfw.hints.window.autoIconify = GLFW_TRUE; _glfw.hints.window.autoIconify = true;
_glfw.hints.window.centerCursor = GLFW_TRUE; _glfw.hints.window.centerCursor = true;
_glfw.hints.window.focusOnShow = GLFW_TRUE; _glfw.hints.window.focusOnShow = true;
_glfw.hints.window.xpos = GLFW_ANY_POSITION; _glfw.hints.window.xpos = GLFW_ANY_POSITION;
_glfw.hints.window.ypos = GLFW_ANY_POSITION; _glfw.hints.window.ypos = GLFW_ANY_POSITION;
_glfw.hints.window.scaleFramebuffer = GLFW_TRUE; _glfw.hints.window.scaleFramebuffer = true;
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil, // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,
// double buffered // double buffered
@@ -285,7 +285,7 @@ void glfwDefaultWindowHints(void)
_glfw.hints.framebuffer.alphaBits = 8; _glfw.hints.framebuffer.alphaBits = 8;
_glfw.hints.framebuffer.depthBits = 24; _glfw.hints.framebuffer.depthBits = 24;
_glfw.hints.framebuffer.stencilBits = 8; _glfw.hints.framebuffer.stencilBits = 8;
_glfw.hints.framebuffer.doublebuffer = GLFW_TRUE; _glfw.hints.framebuffer.doublebuffer = true;
// The default is to select the highest available refresh rate // The default is to select the highest available refresh rate
_glfw.hints.refreshRate = GLFW_DONT_CARE; _glfw.hints.refreshRate = GLFW_DONT_CARE;
@@ -331,40 +331,40 @@ GLFWAPI void glfwWindowHint(int hint, int value)
_glfw.hints.framebuffer.auxBuffers = value; _glfw.hints.framebuffer.auxBuffers = value;
return; return;
case GLFW_STEREO: case GLFW_STEREO:
_glfw.hints.framebuffer.stereo = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.framebuffer.stereo = value;
return; return;
case GLFW_DOUBLEBUFFER: case GLFW_DOUBLEBUFFER:
_glfw.hints.framebuffer.doublebuffer = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.framebuffer.doublebuffer = value;
return; return;
case GLFW_TRANSPARENT_FRAMEBUFFER: case GLFW_TRANSPARENT_FRAMEBUFFER:
_glfw.hints.framebuffer.transparent = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.framebuffer.transparent = value;
return; return;
case GLFW_SAMPLES: case GLFW_SAMPLES:
_glfw.hints.framebuffer.samples = value; _glfw.hints.framebuffer.samples = value;
return; return;
case GLFW_SRGB_CAPABLE: case GLFW_SRGB_CAPABLE:
_glfw.hints.framebuffer.sRGB = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.framebuffer.sRGB = value;
return; return;
case GLFW_RESIZABLE: case GLFW_RESIZABLE:
_glfw.hints.window.resizable = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.resizable = value;
return; return;
case GLFW_DECORATED: case GLFW_DECORATED:
_glfw.hints.window.decorated = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.decorated = value;
return; return;
case GLFW_FOCUSED: case GLFW_FOCUSED:
_glfw.hints.window.focused = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.focused = value;
return; return;
case GLFW_AUTO_ICONIFY: case GLFW_AUTO_ICONIFY:
_glfw.hints.window.autoIconify = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.autoIconify = value;
return; return;
case GLFW_FLOATING: case GLFW_FLOATING:
_glfw.hints.window.floating = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.floating = value;
return; return;
case GLFW_MAXIMIZED: case GLFW_MAXIMIZED:
_glfw.hints.window.maximized = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.maximized = value;
return; return;
case GLFW_VISIBLE: case GLFW_VISIBLE:
_glfw.hints.window.visible = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.visible = value;
return; return;
case GLFW_POSITION_X: case GLFW_POSITION_X:
_glfw.hints.window.xpos = value; _glfw.hints.window.xpos = value;
@@ -373,29 +373,29 @@ GLFWAPI void glfwWindowHint(int hint, int value)
_glfw.hints.window.ypos = value; _glfw.hints.window.ypos = value;
return; return;
case GLFW_WIN32_KEYBOARD_MENU: case GLFW_WIN32_KEYBOARD_MENU:
_glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.win32.keymenu = value;
return; return;
case GLFW_WIN32_SHOWDEFAULT: case GLFW_WIN32_SHOWDEFAULT:
_glfw.hints.window.win32.showDefault = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.win32.showDefault = value;
return; return;
case GLFW_COCOA_GRAPHICS_SWITCHING: case GLFW_COCOA_GRAPHICS_SWITCHING:
_glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.context.nsgl.offline = value;
return; return;
case GLFW_SCALE_TO_MONITOR: case GLFW_SCALE_TO_MONITOR:
_glfw.hints.window.scaleToMonitor = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.scaleToMonitor = value;
return; return;
case GLFW_SCALE_FRAMEBUFFER: case GLFW_SCALE_FRAMEBUFFER:
case GLFW_COCOA_RETINA_FRAMEBUFFER: case GLFW_COCOA_RETINA_FRAMEBUFFER:
_glfw.hints.window.scaleFramebuffer = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.scaleFramebuffer = value;
return; return;
case GLFW_CENTER_CURSOR: case GLFW_CENTER_CURSOR:
_glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.centerCursor = value;
return; return;
case GLFW_FOCUS_ON_SHOW: case GLFW_FOCUS_ON_SHOW:
_glfw.hints.window.focusOnShow = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.focusOnShow = value;
return; return;
case GLFW_MOUSE_PASSTHROUGH: case GLFW_MOUSE_PASSTHROUGH:
_glfw.hints.window.mousePassthrough = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.mousePassthrough = value;
return; return;
case GLFW_CLIENT_API: case GLFW_CLIENT_API:
_glfw.hints.context.client = value; _glfw.hints.context.client = value;
@@ -413,13 +413,13 @@ GLFWAPI void glfwWindowHint(int hint, int value)
_glfw.hints.context.robustness = value; _glfw.hints.context.robustness = value;
return; return;
case GLFW_OPENGL_FORWARD_COMPAT: case GLFW_OPENGL_FORWARD_COMPAT:
_glfw.hints.context.forward = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.context.forward = value;
return; return;
case GLFW_CONTEXT_DEBUG: case GLFW_CONTEXT_DEBUG:
_glfw.hints.context.debug = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.context.debug = value;
return; return;
case GLFW_CONTEXT_NO_ERROR: case GLFW_CONTEXT_NO_ERROR:
_glfw.hints.context.noerror = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.context.noerror = value;
return; return;
case GLFW_OPENGL_PROFILE: case GLFW_OPENGL_PROFILE:
_glfw.hints.context.profile = value; _glfw.hints.context.profile = value;