Removed SDL_bool in favor of plain bool

We require stdbool.h in the build environment, so we might as well use the plain bool type.

If your environment doesn't have stdbool.h, this simple replacement will suffice:
typedef signed char bool;
This commit is contained in:
Sam Lantinga
2024-09-18 07:52:28 -07:00
parent 9dd8859240
commit a90ad3b0e2
258 changed files with 4052 additions and 4057 deletions

View File

@@ -264,13 +264,13 @@ static int SDLCALL SDLTest_CommonStateParseVideoArguments(void *data, char **arg
}
if (SDL_strcasecmp(argv[index], "--fullscreen") == 0) {
state->window_flags |= SDL_WINDOW_FULLSCREEN;
state->fullscreen_exclusive = SDL_TRUE;
state->fullscreen_exclusive = true;
state->num_windows = 1;
return 1;
}
if (SDL_strcasecmp(argv[index], "--fullscreen-desktop") == 0) {
state->window_flags |= SDL_WINDOW_FULLSCREEN;
state->fullscreen_exclusive = SDL_FALSE;
state->fullscreen_exclusive = false;
state->num_windows = 1;
return 1;
}
@@ -344,7 +344,7 @@ static int SDLCALL SDLTest_CommonStateParseVideoArguments(void *data, char **arg
return 2;
}
if (SDL_strcasecmp(argv[index], "--usable-bounds") == 0) {
state->fill_usable_bounds = SDL_TRUE;
state->fill_usable_bounds = true;
return 1;
}
if (SDL_strcasecmp(argv[index], "--geometry") == 0) {
@@ -448,7 +448,7 @@ static int SDLCALL SDLTest_CommonStateParseVideoArguments(void *data, char **arg
return 1;
}
if (SDL_strcasecmp(argv[index], "--auto-scale-content") == 0) {
state->auto_scale_content = SDL_TRUE;
state->auto_scale_content = true;
if (state->logical_presentation == SDL_LOGICAL_PRESENTATION_DISABLED) {
state->logical_presentation = SDL_LOGICAL_PRESENTATION_STRETCH;
@@ -562,7 +562,7 @@ static int SDLCALL SDLTest_CommonStateParseVideoArguments(void *data, char **arg
return 1;
}
if (SDL_strcasecmp(argv[index], "--flash-on-focus-loss") == 0) {
state->flash_on_focus_loss = SDL_TRUE;
state->flash_on_focus_loss = true;
return 1;
}
if (SDL_strcasecmp(argv[index], "--grab") == 0) {
@@ -578,7 +578,7 @@ static int SDLCALL SDLTest_CommonStateParseVideoArguments(void *data, char **arg
return 1;
}
if (SDL_strcasecmp(argv[index], "--hide-cursor") == 0) {
state->hide_cursor = SDL_TRUE;
state->hide_cursor = true;
return 1;
}
if (SDL_strcasecmp(argv[index], "--gpu") == 0) {
@@ -803,18 +803,18 @@ void SDLTest_CommonLogUsage(SDLTest_CommonState *state, const char *argv0, const
}
}
SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **argv)
bool SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **argv)
{
int i = 1;
while (i < argc) {
const int consumed = SDLTest_CommonArg(state, i);
if (consumed <= 0) {
SDLTest_CommonLogUsage(state, argv[0], NULL);
return SDL_FALSE;
return false;
}
i += consumed;
}
return SDL_TRUE;
return true;
}
static void SDLTest_PrintDisplayOrientation(char *text, size_t maxlen, SDL_DisplayOrientation orientation)
@@ -1192,7 +1192,7 @@ static SDL_HitTestResult SDLCALL SDLTest_ExampleHitTestCallback(SDL_Window *win,
return SDL_HITTEST_NORMAL;
}
SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
bool SDLTest_CommonInit(SDLTest_CommonState *state)
{
int i, j, m, n, w, h;
char text[1024];
@@ -1216,7 +1216,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
if (!SDL_InitSubSystem(SDL_INIT_VIDEO)) {
SDL_Log("Couldn't initialize video driver: %s\n",
SDL_GetError());
return SDL_FALSE;
return false;
}
if (state->verbose & VERBOSE_VIDEO) {
SDL_Log("Video driver: %s\n",
@@ -1367,9 +1367,9 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
}
{
SDL_bool include_high_density_modes = SDL_FALSE;
bool include_high_density_modes = false;
if (state->window_flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) {
include_high_density_modes = SDL_TRUE;
include_high_density_modes = true;
}
SDL_GetClosestFullscreenDisplayMode(state->displayID, state->window_w, state->window_h, state->refresh_rate, include_high_density_modes, &state->fullscreen_mode);
}
@@ -1385,7 +1385,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
sizeof(*state->targets));
if (!state->windows || !state->renderers) {
SDL_Log("Out of memory!\n");
return SDL_FALSE;
return false;
}
for (i = 0; i < state->num_windows; ++i) {
char title[1024];
@@ -1424,7 +1424,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
if (!state->windows[i]) {
SDL_Log("Couldn't create window: %s\n",
SDL_GetError());
return SDL_FALSE;
return false;
}
if (state->window_minW || state->window_minH) {
SDL_SetWindowMinimumSize(state->windows[i], state->window_minW, state->window_minH);
@@ -1445,7 +1445,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
if (state->fullscreen_exclusive) {
SDL_SetWindowFullscreenMode(state->windows[i], &state->fullscreen_mode);
}
SDL_SetWindowFullscreen(state->windows[i], SDL_TRUE);
SDL_SetWindowFullscreen(state->windows[i], true);
}
/* Add resize/drag areas for windows that are borderless and resizable */
@@ -1471,7 +1471,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
if (!state->renderers[i]) {
SDL_Log("Couldn't create renderer: %s\n",
SDL_GetError());
return SDL_FALSE;
return false;
}
if (state->logical_w == 0 || state->logical_h == 0) {
state->logical_w = state->window_w;
@@ -1482,7 +1482,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
}
if (!SDL_SetRenderLogicalPresentation(state->renderers[i], state->logical_w, state->logical_h, state->logical_presentation, state->logical_scale_mode)) {
SDL_Log("Couldn't set logical presentation: %s\n", SDL_GetError());
return SDL_FALSE;
return false;
}
if (state->scale != 0.0f) {
SDL_SetRenderScale(state->renderers[i], state->scale, state->scale);
@@ -1519,7 +1519,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
if (!SDL_InitSubSystem(SDL_INIT_AUDIO)) {
SDL_Log("Couldn't initialize audio driver: %s\n",
SDL_GetError());
return SDL_FALSE;
return false;
}
if (state->verbose & VERBOSE_AUDIO) {
SDL_Log("Audio driver: %s\n",
@@ -1530,7 +1530,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
state->audio_id = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec);
if (!state->audio_id) {
SDL_Log("Couldn't open audio: %s\n", SDL_GetError());
return SDL_FALSE;
return false;
}
}
@@ -1538,7 +1538,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_InitSubSystem(SDL_INIT_CAMERA);
}
return SDL_TRUE;
return true;
}
static const char *SystemThemeName(void)
@@ -2108,7 +2108,7 @@ static void FullscreenTo(SDLTest_CommonState *state, int index, int windowId)
flags = SDL_GetWindowFlags(window);
if (flags & SDL_WINDOW_FULLSCREEN) {
SDL_SetWindowFullscreen(window, SDL_FALSE);
SDL_SetWindowFullscreen(window, false);
SDL_Delay(15);
}
@@ -2121,9 +2121,9 @@ static void FullscreenTo(SDLTest_CommonState *state, int index, int windowId)
new_mode.displayID = displays[index];
if (!SDL_SetWindowFullscreenMode(window, &new_mode)) {
/* Try again with a default mode */
SDL_bool include_high_density_modes = SDL_FALSE;
bool include_high_density_modes = false;
if (state->window_flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) {
include_high_density_modes = SDL_TRUE;
include_high_density_modes = true;
}
if (SDL_GetClosestFullscreenDisplayMode(displays[index], state->window_w, state->window_h, state->refresh_rate, include_high_density_modes, &new_mode)) {
SDL_SetWindowFullscreenMode(window, &new_mode);
@@ -2133,7 +2133,7 @@ static void FullscreenTo(SDLTest_CommonState *state, int index, int windowId)
if (!mode) {
SDL_SetWindowPosition(window, rect.x, rect.y);
}
SDL_SetWindowFullscreen(window, SDL_TRUE);
SDL_SetWindowFullscreen(window, true);
}
}
SDL_free(displays);
@@ -2184,9 +2184,9 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
}
case SDL_EVENT_KEY_DOWN:
{
SDL_bool withControl = !!(event->key.mod & SDL_KMOD_CTRL);
SDL_bool withShift = !!(event->key.mod & SDL_KMOD_SHIFT);
SDL_bool withAlt = !!(event->key.mod & SDL_KMOD_ALT);
bool withControl = !!(event->key.mod & SDL_KMOD_CTRL);
bool withShift = !!(event->key.mod & SDL_KMOD_SHIFT);
bool withAlt = !!(event->key.mod & SDL_KMOD_ALT);
switch (event->key.key) {
/* Add hotkeys here */
@@ -2404,8 +2404,8 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
if (withShift) {
SDL_Window *window = SDL_GetWindowFromEvent(event);
if (window) {
const SDL_bool shouldCapture = !(SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_CAPTURE);
const SDL_bool rc = SDL_CaptureMouse(shouldCapture);
const bool shouldCapture = !(SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_CAPTURE);
const bool rc = SDL_CaptureMouse(shouldCapture);
SDL_Log("%sapturing mouse %s!\n", shouldCapture ? "C" : "Unc", rc ? "succeeded" : "failed");
}
}
@@ -2426,9 +2426,9 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
if (window) {
SDL_WindowFlags flags = SDL_GetWindowFlags(window);
if (flags & SDL_WINDOW_ALWAYS_ON_TOP) {
SDL_SetWindowAlwaysOnTop(window, SDL_FALSE);
SDL_SetWindowAlwaysOnTop(window, false);
} else {
SDL_SetWindowAlwaysOnTop(window, SDL_TRUE);
SDL_SetWindowAlwaysOnTop(window, true);
}
}
}
@@ -2451,9 +2451,9 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
if (!(flags & SDL_WINDOW_FULLSCREEN) ||
!SDL_GetWindowFullscreenMode(window)) {
SDL_SetWindowFullscreenMode(window, &state->fullscreen_mode);
SDL_SetWindowFullscreen(window, SDL_TRUE);
SDL_SetWindowFullscreen(window, true);
} else {
SDL_SetWindowFullscreen(window, SDL_FALSE);
SDL_SetWindowFullscreen(window, false);
}
}
} else if (withAlt) {
@@ -2464,9 +2464,9 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
if (!(flags & SDL_WINDOW_FULLSCREEN) ||
SDL_GetWindowFullscreenMode(window)) {
SDL_SetWindowFullscreenMode(window, NULL);
SDL_SetWindowFullscreen(window, SDL_TRUE);
SDL_SetWindowFullscreen(window, true);
} else {
SDL_SetWindowFullscreen(window, SDL_FALSE);
SDL_SetWindowFullscreen(window, false);
}
}
}
@@ -2478,7 +2478,7 @@ SDL_AppResult SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const
SDL_Window *window = SDL_GetWindowFromEvent(event);
if (window) {
const SDL_WindowFlags flags = SDL_GetWindowFlags(window);
const SDL_bool b = (flags & SDL_WINDOW_BORDERLESS) ? SDL_TRUE : SDL_FALSE;
const bool b = (flags & SDL_WINDOW_BORDERLESS) ? true : false;
SDL_SetWindowBordered(window, b);
}
}