Additional cleanup exposed by building with a C++ compiler

This commit is contained in:
Sam Lantinga 2024-08-25 21:32:29 -07:00
parent f08ac438ed
commit 00c409cff8
26 changed files with 84 additions and 120 deletions

View File

@ -127,6 +127,7 @@ extern "C" {
*/
typedef enum SDL_AudioFormat
{
SDL_AUDIO_UNKNOWN = 0x0000u, /**< Unspecified audio format */
SDL_AUDIO_U8 = 0x0008u, /**< Unsigned 8-bit samples */
/* SDL_DEFINE_AUDIO_FORMAT(0, 0, 0, 8), */
SDL_AUDIO_S8 = 0x8008u, /**< Signed 8-bit samples */

View File

@ -86,7 +86,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr
SDL_LockProperties(hints);
SDL_Hint *hint = SDL_GetPointerProperty(hints, name, NULL);
SDL_Hint *hint = (SDL_Hint *)SDL_GetPointerProperty(hints, name, NULL);
if (hint) {
if (priority >= hint->priority) {
if (hint->value != value && (!value || !hint->value || SDL_strcmp(hint->value, value) != 0)) {
@ -137,7 +137,7 @@ SDL_bool SDL_ResetHint(const char *name)
SDL_LockProperties(hints);
SDL_Hint *hint = SDL_GetPointerProperty(hints, name, NULL);
SDL_Hint *hint = (SDL_Hint *)SDL_GetPointerProperty(hints, name, NULL);
if (hint) {
if ((!env && hint->value) || (env && !hint->value) || (env && SDL_strcmp(env, hint->value) != 0)) {
for (SDL_HintWatch *entry = hint->callbacks; entry;) {
@ -160,7 +160,7 @@ SDL_bool SDL_ResetHint(const char *name)
static void SDLCALL ResetHintsCallback(void *userdata, SDL_PropertiesID hints, const char *name)
{
SDL_Hint *hint = SDL_GetPointerProperty(hints, name, NULL);
SDL_Hint *hint = (SDL_Hint *)SDL_GetPointerProperty(hints, name, NULL);
if (!hint) {
return; // uh...okay.
}
@ -202,7 +202,7 @@ const char *SDL_GetHint(const char *name)
if (hints) {
SDL_LockProperties(hints);
SDL_Hint *hint = SDL_GetPointerProperty(hints, name, NULL);
SDL_Hint *hint = (SDL_Hint *)SDL_GetPointerProperty(hints, name, NULL);
if (hint) {
if (!result || hint->priority == SDL_HINT_OVERRIDE) {
result = SDL_GetPersistentString(hint->value);
@ -275,7 +275,7 @@ SDL_bool SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *
SDL_DelHintCallback(name, callback, userdata);
SDL_Hint *hint = SDL_GetPointerProperty(hints, name, NULL);
SDL_Hint *hint = (SDL_Hint *)SDL_GetPointerProperty(hints, name, NULL);
if (hint) {
result = true;
} else { // Need to add a hint entry for this watcher
@ -317,7 +317,7 @@ void SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *user
}
SDL_LockProperties(hints);
SDL_Hint *hint = SDL_GetPointerProperty(hints, name, NULL);
SDL_Hint *hint = (SDL_Hint *)SDL_GetPointerProperty(hints, name, NULL);
if (hint) {
SDL_HintWatch *prev = NULL;
for (SDL_HintWatch *entry = hint->callbacks; entry; entry = entry->next) {

View File

@ -1570,7 +1570,7 @@ static SDL_AudioFormat ParseAudioFormatString(const char *string)
CHECK_FMT_STRING(F32);
#undef CHECK_FMT_STRING
}
return 0;
return SDL_AUDIO_UNKNOWN;
}
static void PrepareAudioFormat(bool recording, SDL_AudioSpec *spec)
@ -1601,7 +1601,7 @@ static void PrepareAudioFormat(bool recording, SDL_AudioSpec *spec)
if (spec->format == 0) {
const SDL_AudioFormat val = ParseAudioFormatString(SDL_GetHint(SDL_HINT_AUDIO_FORMAT));
spec->format = (val != 0) ? val : (recording ? DEFAULT_AUDIO_RECORDING_FORMAT : DEFAULT_AUDIO_PLAYBACK_FORMAT);
spec->format = (val != SDL_AUDIO_UNKNOWN) ? val : (recording ? DEFAULT_AUDIO_RECORDING_FORMAT : DEFAULT_AUDIO_PLAYBACK_FORMAT);
}
}
@ -2151,14 +2151,14 @@ SDL_bool SDL_ResumeAudioStreamDevice(SDL_AudioStream *stream)
#define NUM_FORMATS 8
// always favor Float32 in native byte order, since we're probably going to convert to that for processing anyhow.
static const SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS + 1] = {
{ SDL_AUDIO_U8, NATIVE(F32), SWAPPED(F32), SDL_AUDIO_S8, NATIVE(S16), SWAPPED(S16), NATIVE(S32), SWAPPED(S32), 0 },
{ SDL_AUDIO_S8, NATIVE(F32), SWAPPED(F32), SDL_AUDIO_U8, NATIVE(S16), SWAPPED(S16), NATIVE(S32), SWAPPED(S32), 0 },
{ NATIVE(S16), NATIVE(F32), SWAPPED(F32), SWAPPED(S16), NATIVE(S32), SWAPPED(S32), SDL_AUDIO_U8, SDL_AUDIO_S8, 0 },
{ SWAPPED(S16), NATIVE(F32), SWAPPED(F32), NATIVE(S16), SWAPPED(S32), NATIVE(S32), SDL_AUDIO_U8, SDL_AUDIO_S8, 0 },
{ NATIVE(S32), NATIVE(F32), SWAPPED(F32), SWAPPED(S32), NATIVE(S16), SWAPPED(S16), SDL_AUDIO_U8, SDL_AUDIO_S8, 0 },
{ SWAPPED(S32), NATIVE(F32), SWAPPED(F32), NATIVE(S32), SWAPPED(S16), NATIVE(S16), SDL_AUDIO_U8, SDL_AUDIO_S8, 0 },
{ NATIVE(F32), SWAPPED(F32), NATIVE(S32), SWAPPED(S32), NATIVE(S16), SWAPPED(S16), SDL_AUDIO_U8, SDL_AUDIO_S8, 0 },
{ SWAPPED(F32), NATIVE(F32), SWAPPED(S32), NATIVE(S32), SWAPPED(S16), NATIVE(S16), SDL_AUDIO_U8, SDL_AUDIO_S8, 0 },
{ SDL_AUDIO_U8, NATIVE(F32), SWAPPED(F32), SDL_AUDIO_S8, NATIVE(S16), SWAPPED(S16), NATIVE(S32), SWAPPED(S32), SDL_AUDIO_UNKNOWN },
{ SDL_AUDIO_S8, NATIVE(F32), SWAPPED(F32), SDL_AUDIO_U8, NATIVE(S16), SWAPPED(S16), NATIVE(S32), SWAPPED(S32), SDL_AUDIO_UNKNOWN },
{ NATIVE(S16), NATIVE(F32), SWAPPED(F32), SWAPPED(S16), NATIVE(S32), SWAPPED(S32), SDL_AUDIO_U8, SDL_AUDIO_S8, SDL_AUDIO_UNKNOWN },
{ SWAPPED(S16), NATIVE(F32), SWAPPED(F32), NATIVE(S16), SWAPPED(S32), NATIVE(S32), SDL_AUDIO_U8, SDL_AUDIO_S8, SDL_AUDIO_UNKNOWN },
{ NATIVE(S32), NATIVE(F32), SWAPPED(F32), SWAPPED(S32), NATIVE(S16), SWAPPED(S16), SDL_AUDIO_U8, SDL_AUDIO_S8, SDL_AUDIO_UNKNOWN },
{ SWAPPED(S32), NATIVE(F32), SWAPPED(F32), NATIVE(S32), SWAPPED(S16), NATIVE(S16), SDL_AUDIO_U8, SDL_AUDIO_S8, SDL_AUDIO_UNKNOWN },
{ NATIVE(F32), SWAPPED(F32), NATIVE(S32), SWAPPED(S32), NATIVE(S16), SWAPPED(S16), SDL_AUDIO_U8, SDL_AUDIO_S8, SDL_AUDIO_UNKNOWN },
{ SWAPPED(F32), NATIVE(F32), SWAPPED(S32), NATIVE(S32), SWAPPED(S16), NATIVE(S16), SDL_AUDIO_U8, SDL_AUDIO_S8, SDL_AUDIO_UNKNOWN },
};
#undef NATIVE

View File

@ -233,7 +233,7 @@ SDL_AudioTrack *SDL_CreateAudioTrack(
Uint8 *data, size_t len, size_t capacity,
SDL_ReleaseAudioBufferCallback callback, void *userdata)
{
SDL_AudioTrack *track = AllocMemoryPoolBlock(&queue->track_pool);
SDL_AudioTrack *track = (SDL_AudioTrack *)AllocMemoryPoolBlock(&queue->track_pool);
if (!track) {
return NULL;
@ -261,14 +261,14 @@ SDL_AudioTrack *SDL_CreateAudioTrack(
static void SDLCALL FreeChunkedAudioBuffer(void *userdata, const void *buf, int len)
{
SDL_AudioQueue *queue = userdata;
SDL_AudioQueue *queue = (SDL_AudioQueue *)userdata;
FreeMemoryPoolBlock(&queue->chunk_pool, (void *)buf);
}
static SDL_AudioTrack *CreateChunkedAudioTrack(SDL_AudioQueue *queue, const SDL_AudioSpec *spec, const int *chmap)
{
void *chunk = AllocMemoryPoolBlock(&queue->chunk_pool);
Uint8 *chunk = (Uint8 *)AllocMemoryPoolBlock(&queue->chunk_pool);
if (!chunk) {
return NULL;
@ -636,7 +636,7 @@ bool SDL_ResetAudioQueueHistory(SDL_AudioQueue *queue, int num_frames)
Uint8 *history_buffer = queue->history_buffer;
if (queue->history_capacity < length) {
history_buffer = SDL_aligned_alloc(SDL_GetSIMDAlignment(), length);
history_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), length);
if (!history_buffer) {
return false;
}

View File

@ -2032,7 +2032,7 @@ static bool WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uin
*/
spec->freq = format->frequency;
spec->channels = (Uint8)format->channels;
spec->format = 0;
spec->format = SDL_AUDIO_UNKNOWN;
switch (format->encoding) {
case MS_ADPCM_CODE:

View File

@ -377,7 +377,7 @@ SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat)
return SDL_AUDIO_S32;
}
}
return 0;
return SDL_AUDIO_UNKNOWN;
}

View File

@ -63,7 +63,7 @@ char *convert_filters(const SDL_DialogFileFilter *filters, int nfilters,
new_length = SDL_strlen(combined) + SDL_strlen(converted)
+ SDL_strlen(terminator) + 1;
new_combined = SDL_realloc(combined, new_length);
new_combined = (char *)SDL_realloc(combined, new_length);
if (!new_combined) {
SDL_free(converted);
@ -82,7 +82,7 @@ char *convert_filters(const SDL_DialogFileFilter *filters, int nfilters,
if (!filters->name || !filters->pattern) {
new_length = SDL_strlen(combined) + SDL_strlen(suffix) + 1;
new_combined = SDL_realloc(combined, new_length);
new_combined = (char *)SDL_realloc(combined, new_length);
if (!new_combined) {
SDL_free(combined);

View File

@ -172,8 +172,7 @@ void windows_ShowFileDialog(void *ptr)
}
int filter_wlen = MultiByteToWideChar(CP_UTF8, 0, filterlist, filter_len, NULL, 0);
filter_wchar = SDL_malloc(filter_wlen * sizeof(wchar_t));
filter_wchar = (wchar_t *)SDL_malloc(filter_wlen * sizeof(wchar_t));
if (!filter_wchar) {
SDL_free(filterlist);
callback(userdata, NULL, -1);
@ -439,7 +438,7 @@ void SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL
return;
}
args = SDL_malloc(sizeof(winArgs));
args = (winArgs *)SDL_malloc(sizeof(*args));
if (args == NULL) {
callback(userdata, NULL, -1);
return;
@ -450,7 +449,7 @@ void SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL
args->nfilters = nfilters;
args->default_file = default_location;
args->parent = window;
args->flags = (allow_many == true) ? OFN_ALLOWMULTISELECT : 0;
args->flags = (allow_many != SDL_FALSE) ? OFN_ALLOWMULTISELECT : 0;
args->callback = callback;
args->userdata = userdata;
@ -476,7 +475,7 @@ void SDL_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL
return;
}
args = SDL_malloc(sizeof(winArgs));
args = (winArgs *)SDL_malloc(sizeof(*args));
if (args == NULL) {
callback(userdata, NULL, -1);
return;
@ -513,7 +512,7 @@ void SDL_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, S
return;
}
args = SDL_malloc(sizeof(winFArgs));
args = (winFArgs *)SDL_malloc(sizeof(*args));
if (args == NULL) {
callback(userdata, NULL, -1);
return;

View File

@ -123,7 +123,7 @@ static SDL_TemporaryMemoryState *SDL_GetTemporaryMemoryState(bool create)
{
SDL_TemporaryMemoryState *state;
state = SDL_GetTLS(&SDL_temporary_memory);
state = (SDL_TemporaryMemoryState *)SDL_GetTLS(&SDL_temporary_memory);
if (!state) {
if (!create) {
return NULL;
@ -298,7 +298,7 @@ void *SDL_AllocateTemporaryMemory(size_t size)
const char *SDL_CreateTemporaryString(const char *string)
{
if (string) {
return SDL_FreeLater(SDL_strdup(string));
return (const char *)SDL_FreeLater(SDL_strdup(string));
}
return NULL;
}
@ -1634,8 +1634,6 @@ void SDL_SetEventEnabled(Uint32 type, SDL_bool enabled)
Uint8 hi = ((type >> 8) & 0xff);
Uint8 lo = (type & 0xff);
enabled = !!enabled; // make sure this is definitely either true or false.
if (SDL_disabled_events[hi] &&
(SDL_disabled_events[hi]->bits[lo / 32] & (1 << (lo & 31)))) {
current_state = false;
@ -1643,7 +1641,7 @@ void SDL_SetEventEnabled(Uint32 type, SDL_bool enabled)
current_state = true;
}
if (enabled != current_state) {
if ((enabled != SDL_FALSE) != current_state) {
if (enabled) {
SDL_assert(SDL_disabled_events[hi] != NULL);
SDL_disabled_events[hi]->bits[lo / 32] &= ~(1 << (lo & 31));

View File

@ -214,14 +214,14 @@ const char *SDL_GetKeyboardNameForID(SDL_KeyboardID instance_id)
void SDL_ResetKeyboard(void)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_Scancode scancode;
int scancode;
#ifdef DEBUG_KEYBOARD
printf("Resetting keyboard\n");
#endif
for (scancode = (SDL_Scancode)0; scancode < SDL_NUM_SCANCODES; ++scancode) {
for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) {
if (keyboard->keystate[scancode] == SDL_PRESSED) {
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, scancode, SDL_RELEASED);
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, (SDL_Scancode)scancode, SDL_RELEASED);
}
}
}
@ -696,12 +696,12 @@ bool SDL_SendKeyboardKeyAutoRelease(Uint64 timestamp, SDL_Scancode scancode)
void SDL_ReleaseAutoReleaseKeys(void)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_Scancode scancode;
int scancode;
if (keyboard->autorelease_pending) {
for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) {
if (keyboard->keysource[scancode] == KEYBOARD_AUTORELEASE) {
SDL_SendKeyboardKeyInternal(0, KEYBOARD_AUTORELEASE, SDL_GLOBAL_KEYBOARD_ID, 0, scancode, SDL_RELEASED);
SDL_SendKeyboardKeyInternal(0, KEYBOARD_AUTORELEASE, SDL_GLOBAL_KEYBOARD_ID, 0, (SDL_Scancode)scancode, SDL_RELEASED);
}
}
keyboard->autorelease_pending = false;
@ -718,7 +718,7 @@ void SDL_ReleaseAutoReleaseKeys(void)
bool SDL_HardwareKeyboardKeyPressed(void)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_Scancode scancode;
int scancode;
for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) {
if (keyboard->keysource[scancode] & KEYBOARD_HARDWARE) {

View File

@ -221,7 +221,7 @@ static char *CaseFoldUtf8String(const char *fname)
if (remaining > 0) {
SDL_assert(allocation > remaining);
ptr = SDL_realloc(result, allocation - remaining); // shrink it down.
ptr = (char *)SDL_realloc(result, allocation - remaining); // shrink it down.
if (ptr) { // shouldn't fail, but if it does, `result` is still valid.
result = ptr;
}

View File

@ -3132,7 +3132,7 @@ SDL_bool SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type,
SDL_JoystickSensorInfo *sensor = &joystick->sensors[i];
if (sensor->type == type) {
if (sensor->enabled == enabled) {
if (sensor->enabled == (enabled != SDL_FALSE)) {
SDL_UnlockJoysticks();
return true;
}

View File

@ -257,7 +257,7 @@ static bool WriteRegister(SDL_DriverWii_Context *ctx, Uint32 address, const Uint
SDL_zeroa(writeRequest);
writeRequest[0] = k_eWiiOutputReportIDs_WriteMemory;
writeRequest[1] = (Uint8)(0x04 | ctx->m_bRumbleActive);
writeRequest[1] = (Uint8)(0x04 | (Uint8)ctx->m_bRumbleActive);
writeRequest[2] = (address >> 16) & 0xff;
writeRequest[3] = (address >> 8) & 0xff;
writeRequest[4] = address & 0xff;
@ -286,7 +286,7 @@ static bool ReadRegister(SDL_DriverWii_Context *ctx, Uint32 address, int size, b
Uint8 readRequest[7];
readRequest[0] = k_eWiiOutputReportIDs_ReadMemory;
readRequest[1] = (Uint8)(0x04 | ctx->m_bRumbleActive);
readRequest[1] = (Uint8)(0x04 | (Uint8)ctx->m_bRumbleActive);
readRequest[2] = (address >> 16) & 0xff;
readRequest[3] = (address >> 8) & 0xff;
readRequest[4] = address & 0xff;

View File

@ -110,7 +110,7 @@ SDL_AppResult SDL_InitMainCallbacks(int argc, char* argv[], SDL_AppInit_func app
}
}
return SDL_AtomicGet(&apprc);
return (SDL_AppResult)SDL_AtomicGet(&apprc);
}
SDL_AppResult SDL_IterateMainCallbacks(bool pump_events)
@ -120,11 +120,11 @@ SDL_AppResult SDL_IterateMainCallbacks(bool pump_events)
}
SDL_DispatchMainCallbackEvents();
SDL_AppResult rc = SDL_AtomicGet(&apprc);
SDL_AppResult rc = (SDL_AppResult)SDL_AtomicGet(&apprc);
if (rc == SDL_APP_CONTINUE) {
rc = SDL_main_iteration_callback(SDL_main_appstate);
if (!SDL_AtomicCompareAndSwap(&apprc, SDL_APP_CONTINUE, rc)) {
rc = SDL_AtomicGet(&apprc); // something else already set a quit result, keep that.
rc = (SDL_AppResult)SDL_AtomicGet(&apprc); // something else already set a quit result, keep that.
}
}
return rc;

View File

@ -1286,7 +1286,7 @@ static bool IsSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormat format)
return false;
}
static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormat format)
static SDL_PixelFormat GetClosestSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormat format)
{
int i;
@ -1405,7 +1405,7 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert
return NULL;
}
} else {
int closest_format;
SDL_PixelFormat closest_format;
SDL_PropertiesID native_props = SDL_CreateProperties();
if (!texture_is_fourcc_and_target) {

View File

@ -492,7 +492,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
int is8bit, angle90;
SDL_BlendMode blendmode;
Uint32 colorkey = 0;
int colorKeyAvailable = false;
bool colorKeyAvailable = false;
double sangleinv, cangleinv;
// Sanity check
@ -538,7 +538,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
SDL_GetSurfaceBlendMode(src, &blendmode);
if (colorKeyAvailable == true) {
if (colorKeyAvailable) {
// If available, the colorkey will be used to discard the pixels that are outside of the rotated area.
SDL_SetSurfaceColorKey(rz_dst, true, colorkey);
SDL_FillSurfaceRect(rz_dst, NULL, colorkey);

View File

@ -2165,7 +2165,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
swapchainCreateInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
swapchainCreateInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
swapchainCreateInfo.preTransform = rendererData->surfaceCapabilities.currentTransform;
swapchainCreateInfo.compositeAlpha = (renderer->window->flags & SDL_WINDOW_TRANSPARENT) ? 0 : VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
swapchainCreateInfo.compositeAlpha = (renderer->window->flags & SDL_WINDOW_TRANSPARENT) ? (VkCompositeAlphaFlagBitsKHR)0 : VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
swapchainCreateInfo.presentMode = presentMode;
swapchainCreateInfo.clipped = VK_TRUE;
swapchainCreateInfo.oldSwapchain = rendererData->swapchain;

View File

@ -93,7 +93,7 @@ SDL_bool SDL_GetCurrentTime(SDL_Time *ticks)
// Only available in Win8/Server 2012 or higher.
if (!pGetSystemTimePreciseAsFileTime && !load_attempted) {
HANDLE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
if (kernel32) {
pGetSystemTimePreciseAsFileTime = (pfnGetSystemTimePreciseAsFileTime)GetProcAddress(kernel32, "GetSystemTimePreciseAsFileTime");
}

View File

@ -11534,7 +11534,7 @@ SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
{ SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale },
{ SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend },
{ SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend_Scale },
{ 0, 0, 0, 0, NULL }
{ SDL_PIXELFORMAT_UNKNOWN, SDL_PIXELFORMAT_UNKNOWN, 0, 0, NULL }
};
/* *INDENT-ON* */ // clang-format on

View File

@ -1085,9 +1085,9 @@ SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surfa
_this->egl_data->egl_swapinterval = 0;
if (!SDL_EGL_MakeCurrent(_this, egl_surface, egl_context)) {
if (!SDL_EGL_MakeCurrent(_this, egl_surface, (SDL_GLContext)egl_context)) {
// Delete the context
SDL_EGL_DestroyContext(_this, egl_context);
SDL_EGL_DestroyContext(_this, (SDL_GLContext)egl_context);
return NULL;
}

View File

@ -1371,13 +1371,13 @@ SDL_bool SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int
return true;
}
static bool DisplayModeChanged(const SDL_DisplayMode *old, const SDL_DisplayMode *new)
static bool DisplayModeChanged(const SDL_DisplayMode *old_mode, const SDL_DisplayMode *new_mode)
{
return ((old->displayID && old->displayID != new->displayID) ||
(old->format && old->format != new->format) ||
(old->w && old->h && (old->w != new->w ||old->h != new->h)) ||
(old->pixel_density != 0.0f && old->pixel_density != new->pixel_density) ||
(old->refresh_rate != 0.0f && old->refresh_rate != new->refresh_rate));
return ((old_mode->displayID && old_mode->displayID != new_mode->displayID) ||
(old_mode->format && old_mode->format != new_mode->format) ||
(old_mode->w && old_mode->h && (old_mode->w != new_mode->w ||old_mode->h != new_mode->h)) ||
(old_mode->pixel_density != 0.0f && old_mode->pixel_density != new_mode->pixel_density) ||
(old_mode->refresh_rate != 0.0f && old_mode->refresh_rate != new_mode->refresh_rate));
}
void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
@ -1781,7 +1781,7 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b
// If we are in the process of hiding don't go back to fullscreen
if (window->is_destroying || window->is_hiding) {
fullscreen = false;
fullscreen = SDL_FULLSCREEN_OP_LEAVE;
}
// Get the correct display for this operation
@ -2132,7 +2132,7 @@ SDL_Window **SDLCALL SDL_GetWindows(int *count)
++num_windows;
}
SDL_Window **windows = SDL_malloc((num_windows + 1) * sizeof(*windows));
SDL_Window **windows = (SDL_Window **)SDL_malloc((num_windows + 1) * sizeof(*windows));
if (!windows) {
return NULL;
}

View File

@ -118,9 +118,9 @@ bool OFFSCREEN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path)
}
}
_this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
_this->vulkan_config.vkGetInstanceProcAddr = (SDL_FunctionPointer)vkGetInstanceProcAddr;
_this->vulkan_config.vkEnumerateInstanceExtensionProperties =
(void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
(SDL_FunctionPointer)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
if (!_this->vulkan_config.vkEnumerateInstanceExtensionProperties) {
goto fail;

View File

@ -536,8 +536,8 @@ bool WIN_UpdateGameInputEnabled(SDL_VideoDevice *_this)
SDL_LockMutex(data->lock);
{
data->enabled_input = (raw_mouse_enabled ? GameInputKindMouse : 0) |
(raw_keyboard_enabled ? GameInputKindKeyboard : 0);
data->enabled_input = (raw_mouse_enabled ? GameInputKindMouse : GameInputKindUnknown) |
(raw_keyboard_enabled ? GameInputKindKeyboard : GameInputKindUnknown);
// Reset input if not enabled
for (int i = 0; i < data->num_devices; ++i) {

View File

@ -375,7 +375,7 @@ static SDL_WindowEraseBackgroundMode GetEraseBackgroundModeHint(void)
return SDL_ERASEBACKGROUNDMODE_INITIAL;
}
return mode;
return (SDL_WindowEraseBackgroundMode)mode;
}
static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd, HWND parent)
@ -904,7 +904,7 @@ bool WIN_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window)
window->internal->floating_rect_pending = true;
}
} else {
return SDL_UpdateFullscreenMode(window, true, true);
return SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_ENTER, true);
}
return true;
@ -1306,7 +1306,7 @@ SDL_FullscreenResult WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window
} else {
BOOL menu;
WIN_UpdateCornerRoundingForHWND(hwnd, data->windowed_mode_corner_rounding);
WIN_UpdateCornerRoundingForHWND(hwnd, (DWM_WINDOW_CORNER_PREFERENCE)data->windowed_mode_corner_rounding);
WIN_UpdateBorderColorForHWND(hwnd, data->dwma_border_color);
/* Restore window-maximization state, as applicable.
@ -1896,7 +1896,7 @@ static STDMETHODIMP SDLDropTarget_Drop(SDLDropTarget *target,
". In Drop File for GlobalLock, format %08x '%s', memory (%lu) %p\n",
fetc.cfFormat, format_mime, (unsigned long)bsize, buffer);
if (buffer) {
char *text = SDL_malloc(bsize + sizeof(Uint32));
char *text = (char *)SDL_malloc(bsize + sizeof(Uint32));
SDL_memcpy((Uint8 *)text, buffer, bsize);
SDL_memset((Uint8 *)text + bsize, 0, sizeof(Uint32));
char *saveptr = NULL;
@ -1944,7 +1944,7 @@ static STDMETHODIMP SDLDropTarget_Drop(SDLDropTarget *target,
". In Drop Text for GlobalLock, format %08x '%s', memory (%lu) %p\n",
fetc.cfFormat, format_mime, (unsigned long)bsize, buffer);
if (buffer) {
char *text = SDL_malloc(bsize + sizeof(Uint32));
char *text = (char *)SDL_malloc(bsize + sizeof(Uint32));
SDL_memcpy((Uint8 *)text, buffer, bsize);
SDL_memset((Uint8 *)text + bsize, 0, sizeof(Uint32));
char *saveptr = NULL;
@ -1990,13 +1990,13 @@ static STDMETHODIMP SDLDropTarget_Drop(SDLDropTarget *target,
". In Drop Text for GlobalLock, format %08x '%s', memory (%lu) %p\n",
fetc.cfFormat, format_mime, (unsigned long)bsize, buffer);
if (buffer) {
buffer = WIN_StringToUTF8(buffer);
buffer = WIN_StringToUTF8((const wchar_t *)buffer);
if (buffer) {
const size_t lbuffer = SDL_strlen(buffer);
const size_t lbuffer = SDL_strlen((const char *)buffer);
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
". In Drop Text for StringToUTF8, format %08x '%s', memory (%lu) %p\n",
fetc.cfFormat, format_mime, (unsigned long)lbuffer, buffer);
char *text = SDL_malloc(lbuffer + sizeof(Uint32));
char *text = (char *)SDL_malloc(lbuffer + sizeof(Uint32));
SDL_memcpy((Uint8 *)text, buffer, lbuffer);
SDL_memset((Uint8 *)text + lbuffer, 0, sizeof(Uint32));
char *saveptr = NULL;
@ -2044,7 +2044,7 @@ static STDMETHODIMP SDLDropTarget_Drop(SDLDropTarget *target,
". In Drop Text for GlobalLock, format %08x '%s', memory (%lu) %p\n",
fetc.cfFormat, format_mime, (unsigned long)bsize, buffer);
if (buffer) {
char *text = SDL_malloc(bsize + sizeof(Uint32));
char *text = (char *)SDL_malloc(bsize + sizeof(Uint32));
SDL_memcpy((Uint8 *)text, buffer, bsize);
SDL_memset((Uint8 *)text + bsize, 0, sizeof(Uint32));
char *saveptr = NULL;

View File

@ -430,23 +430,6 @@ static void RepositionRowOfThings(const ThingType what, const float y)
}
}
static const char *AudioFmtToString(const SDL_AudioFormat fmt)
{
switch (fmt) {
#define FMTCASE(x) case SDL_AUDIO_##x: return #x
FMTCASE(U8);
FMTCASE(S8);
FMTCASE(S16LE);
FMTCASE(S16BE);
FMTCASE(S32LE);
FMTCASE(S32BE);
FMTCASE(F32LE);
FMTCASE(F32BE);
#undef FMTCASE
}
return "?";
}
static const char *AudioChansToStr(const int channels)
{
switch (channels) {
@ -686,7 +669,7 @@ static Thing *LoadWavThing(const char *fname, float x, float y)
nodirs = fname;
}
SDL_asprintf(&titlebar, "WAV file (\"%s\", %s, %s, %uHz)", nodirs, AudioFmtToString(spec.format), AudioChansToStr(spec.channels), (unsigned int) spec.freq);
SDL_asprintf(&titlebar, "WAV file (\"%s\", %s, %s, %uHz)", nodirs, SDL_GetAudioFormatName(spec.format), AudioChansToStr(spec.channels), (unsigned int) spec.freq);
thing = CreateThing(THING_WAV, x - (audio_texture->w / 2), y - (audio_texture->h / 2), 5, -1, -1, audio_texture, titlebar);
if (thing) {
SDL_free(titlebar);
@ -772,7 +755,7 @@ static void SetLogicalDeviceTitlebar(Thing *thing)
int frames = 0;
SDL_GetAudioDeviceFormat(thing->data.logdev.devid, spec, &frames);
SDL_free(thing->titlebar);
SDL_asprintf(&thing->titlebar, "Logical device #%u (%s, %s, %s, %uHz, %d frames)", (unsigned int) thing->data.logdev.devid, thing->data.logdev.recording ? "RECORDING" : "PLAYBACK", AudioFmtToString(spec->format), AudioChansToStr(spec->channels), (unsigned int) spec->freq, frames);
SDL_asprintf(&thing->titlebar, "Logical device #%u (%s, %s, %s, %uHz, %d frames)", (unsigned int) thing->data.logdev.devid, thing->data.logdev.recording ? "RECORDING" : "PLAYBACK", SDL_GetAudioFormatName(spec->format), AudioChansToStr(spec->channels), (unsigned int) spec->freq, frames);
}
static void LogicalDeviceThing_ondrop(Thing *thing, int button, float x, float y)
@ -959,11 +942,11 @@ static void SetPhysicalDeviceTitlebar(Thing *thing)
SDL_GetAudioDeviceFormat(thing->data.physdev.devid, spec, &frames);
SDL_free(thing->titlebar);
if (thing->data.physdev.devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING) {
SDL_asprintf(&thing->titlebar, "Default system device (RECORDING, %s, %s, %uHz, %d frames)", AudioFmtToString(spec->format), AudioChansToStr(spec->channels), (unsigned int) spec->freq, frames);
SDL_asprintf(&thing->titlebar, "Default system device (RECORDING, %s, %s, %uHz, %d frames)", SDL_GetAudioFormatName(spec->format), AudioChansToStr(spec->channels), (unsigned int) spec->freq, frames);
} else if (thing->data.physdev.devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) {
SDL_asprintf(&thing->titlebar, "Default system device (PLAYBACK, %s, %s, %uHz, %d frames)", AudioFmtToString(spec->format), AudioChansToStr(spec->channels), (unsigned int) spec->freq, frames);
SDL_asprintf(&thing->titlebar, "Default system device (PLAYBACK, %s, %s, %uHz, %d frames)", SDL_GetAudioFormatName(spec->format), AudioChansToStr(spec->channels), (unsigned int) spec->freq, frames);
} else {
SDL_asprintf(&thing->titlebar, "Physical device #%u (%s, \"%s\", %s, %s, %uHz, %d frames)", (unsigned int) thing->data.physdev.devid, thing->data.physdev.recording ? "RECORDING" : "PLAYBACK", thing->data.physdev.name, AudioFmtToString(spec->format), AudioChansToStr(spec->channels), (unsigned int) spec->freq, frames);
SDL_asprintf(&thing->titlebar, "Physical device #%u (%s, \"%s\", %s, %s, %uHz, %d frames)", (unsigned int) thing->data.physdev.devid, thing->data.physdev.recording ? "RECORDING" : "PLAYBACK", thing->data.physdev.name, SDL_GetAudioFormatName(spec->format), AudioChansToStr(spec->channels), (unsigned int) spec->freq, frames);
}
}

View File

@ -168,23 +168,6 @@ static void skip_audio(float amount)
}
}
static const char *AudioFmtToString(const SDL_AudioFormat fmt)
{
switch (fmt) {
#define FMTCASE(x) case SDL_AUDIO_##x: return #x
FMTCASE(U8);
FMTCASE(S8);
FMTCASE(S16LE);
FMTCASE(S16BE);
FMTCASE(S32LE);
FMTCASE(S32BE);
FMTCASE(F32LE);
FMTCASE(F32BE);
#undef FMTCASE
}
return "?";
}
static const char *AudioChansToStr(const int channels)
{
switch (channels) {
@ -343,15 +326,15 @@ static void loop(void)
draw_y = state->window_h - FONT_LINE_HEIGHT * 3;
draw_textf(rend, 0, draw_y, "Wav: %6s/%6s/%i",
AudioFmtToString(spec.format), AudioChansToStr(spec.channels), spec.freq);
SDL_GetAudioFormatName(spec.format), AudioChansToStr(spec.channels), spec.freq);
draw_y += FONT_LINE_HEIGHT;
draw_textf(rend, 0, draw_y, "Src: %6s/%6s/%i",
AudioFmtToString(src_spec.format), AudioChansToStr(src_spec.channels), src_spec.freq);
SDL_GetAudioFormatName(src_spec.format), AudioChansToStr(src_spec.channels), src_spec.freq);
draw_y += FONT_LINE_HEIGHT;
draw_textf(rend, 0, draw_y, "Dst: %6s/%6s/%i",
AudioFmtToString(dst_spec.format), AudioChansToStr(dst_spec.channels), dst_spec.freq);
SDL_GetAudioFormatName(dst_spec.format), AudioChansToStr(dst_spec.channels), dst_spec.freq);
draw_y += FONT_LINE_HEIGHT;
SDL_RenderPresent(rend);