update SDL3 from 3.2.20 to 3.4.2

This commit is contained in:
Sven Balzer
2026-04-01 18:25:03 +02:00
parent 1daf4d79f1
commit 05b19704f8
1626 changed files with 124218 additions and 191491 deletions
+39 -2
View File
@@ -1,5 +1,5 @@
/*
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -12,6 +12,7 @@
/* Sample program: Create open and save dialogs. */
#include <SDL3/SDL.h>
#include <SDL3/SDL_iostream.h>
#include <SDL3/SDL_main.h>
#include <SDL3/SDL_test.h>
@@ -23,6 +24,8 @@ const SDL_DialogFileFilter filters[] = {
};
static void SDLCALL callback(void *userdata, const char * const *files, int filter) {
char **saved_path = userdata;
if (files) {
const char* filter_name = "(filter fetching unsupported)";
@@ -36,6 +39,13 @@ static void SDLCALL callback(void *userdata, const char * const *files, int filt
SDL_Log("Filter used: '%s'", filter_name);
if (*files && saved_path) {
*saved_path = SDL_strdup(*files);
/* Create the file */
SDL_IOStream *stream = SDL_IOFromFile(*saved_path, "w");
SDL_CloseIO(stream);
}
while (*files) {
SDL_Log("'%s'", *files);
files++;
@@ -45,6 +55,23 @@ static void SDLCALL callback(void *userdata, const char * const *files, int filt
}
}
char *concat_strings(const char *a, const char *b)
{
char *out = NULL;
if (a != NULL && b != NULL) {
const size_t out_size = SDL_strlen(a) + SDL_strlen(b) + 1;
out = (char *)SDL_malloc(out_size);
if (out) {
*out = '\0';
SDL_strlcat(out, a, out_size);
SDL_strlcat(out, b, out_size);
}
}
return out;
}
int main(int argc, char *argv[])
{
SDL_Window *w;
@@ -54,7 +81,9 @@ int main(int argc, char *argv[])
const SDL_FRect save_file_rect = { 50, 290, 220, 140 };
const SDL_FRect open_folder_rect = { 370, 50, 220, 140 };
int i;
const char *default_filename = "Untitled.index";
const char *initial_path = NULL;
char *last_saved_path = NULL;
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, 0);
@@ -116,7 +145,14 @@ int main(int argc, char *argv[])
} else if (SDL_PointInRectFloat(&p, &open_folder_rect)) {
SDL_ShowOpenFolderDialog(callback, NULL, w, initial_path, 1);
} else if (SDL_PointInRectFloat(&p, &save_file_rect)) {
SDL_ShowSaveFileDialog(callback, NULL, w, filters, SDL_arraysize(filters), initial_path);
char *save_path = NULL;
if (last_saved_path) {
save_path = SDL_strdup(last_saved_path);
} else {
save_path = concat_strings(initial_path, default_filename);
}
SDL_ShowSaveFileDialog(callback, &last_saved_path, w, filters, SDL_arraysize(filters), save_path ? save_path : default_filename);
SDL_free(save_path);
}
}
}
@@ -145,6 +181,7 @@ int main(int argc, char *argv[])
SDL_RenderPresent(r);
}
SDL_free(last_saved_path);
SDLTest_CleanupTextDrawing();
SDL_DestroyRenderer(r);
SDL_DestroyWindow(w);