mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-24 09:41:06 +01:00
Compare commits
22 Commits
prerelease
...
release-2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c9beb0c87 | ||
|
|
6e007c36e7 | ||
|
|
948dbe7d3f | ||
|
|
f6b81125b3 | ||
|
|
3bae2d57da | ||
|
|
51be30f3cd | ||
|
|
8acb4e45b3 | ||
|
|
7da74eb5be | ||
|
|
99e9156ff5 | ||
|
|
09b6956dcc | ||
|
|
2fcd8f889c | ||
|
|
222f1a2693 | ||
|
|
9670d2bb9e | ||
|
|
26948f01a3 | ||
|
|
650612fdcb | ||
|
|
cc9cc2028d | ||
|
|
0cc8dfdb58 | ||
|
|
c6c688ab01 | ||
|
|
b72cf207fb | ||
|
|
7d5ccae22d | ||
|
|
5b4b4fa1ff | ||
|
|
cf134235d7 |
@@ -80,8 +80,8 @@ endif()
|
||||
|
||||
# See docs/release_checklist.md
|
||||
set(SDL_MAJOR_VERSION 2)
|
||||
set(SDL_MINOR_VERSION 23)
|
||||
set(SDL_MICRO_VERSION 2)
|
||||
set(SDL_MINOR_VERSION 24)
|
||||
set(SDL_MICRO_VERSION 0)
|
||||
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
||||
|
||||
# Set defaults preventing destination file conflicts
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 23
|
||||
MICRO_VERSION = 2
|
||||
MINOR_VERSION = 24
|
||||
MICRO_VERSION = 0
|
||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||
DESCRIPTION = Simple DirectMedia Layer 2
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 23
|
||||
MICRO_VERSION = 2
|
||||
MINOR_VERSION = 24
|
||||
MICRO_VERSION = 0
|
||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||
DESCRIPTION = Simple DirectMedia Layer 2
|
||||
|
||||
|
||||
15
WhatsNew.txt
15
WhatsNew.txt
@@ -7,17 +7,10 @@ This is a list of major changes in SDL's version history.
|
||||
|
||||
General:
|
||||
* New version numbering scheme, similar to GLib and Flatpak.
|
||||
* An even number in the minor version (second component) indicates
|
||||
a production-ready stable release such as 2.24.0, which would have
|
||||
been 2.0.24 under the old system.
|
||||
* The patchlevel (micro version, third component) indicates a
|
||||
bugfix-only update: for example, 2.24.1 would be a bugfix-only
|
||||
release to fix bugs in 2.24.0, without adding new features.
|
||||
* An odd number in the minor version indicates a prerelease such
|
||||
as 2.23.0. Stable distributions should not use these prereleases.
|
||||
* The patchlevel indicates successive prereleases, for example
|
||||
2.23.1 and 2.23.2 would be prereleases during development of
|
||||
the SDL 2.24.0 stable release.
|
||||
* An even number in the minor version (second component) indicates a production-ready stable release such as 2.24.0, which would have been 2.0.24 under the old system.
|
||||
* The patchlevel (micro version, third component) indicates a bugfix-only update: for example, 2.24.1 would be a bugfix-only release to fix bugs in 2.24.0, without adding new features.
|
||||
* An odd number in the minor version indicates a prerelease such as 2.23.0. Stable distributions should not use these prereleases.
|
||||
* The patchlevel indicates successive prereleases, for example 2.23.1 and 2.23.2 would be prereleases during development of the SDL 2.24.0 stable release.
|
||||
* Added SDL_GetPointDisplayIndex() and SDL_GetRectDisplayIndex() to get the display associated with a point and rectangle in screen space
|
||||
* Added SDL_bsearch(), SDL_crc16(), and SDL_utf8strnlen() to the stdlib routines
|
||||
* Added SDL_CPUPauseInstruction() as a macro in SDL_atomic.h
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.23.2</string>
|
||||
<string>2.24.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>SDLX</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.23.2</string>
|
||||
<string>2.24.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -9397,7 +9397,7 @@
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEPLOYMENT_POSTPROCESSING = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1.0.0;
|
||||
DYLIB_CURRENT_VERSION = 2303.0.0;
|
||||
DYLIB_CURRENT_VERSION = 2401.0.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_ALTIVEC_EXTENSIONS = YES;
|
||||
@@ -9482,7 +9482,7 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1.0.0;
|
||||
DYLIB_CURRENT_VERSION = 2303.0.0;
|
||||
DYLIB_CURRENT_VERSION = 2401.0.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
|
||||
@@ -55,7 +55,7 @@ mkdir buildbot
|
||||
pushd buildbot
|
||||
|
||||
echo "Configuring..."
|
||||
emconfigure ../configure --host=wasm32-unknown-emscripten --disable-assembly --disable-threads --disable-cpuinfo CFLAGS="-O2 -Wno-warn-absolute-paths -Wdeclaration-after-statement -Werror=declaration-after-statement" --prefix="$PWD/emscripten-sdl2-installed" || exit $?
|
||||
emconfigure ../configure --host=wasm32-unknown-emscripten --disable-assembly --disable-threads --disable-cpuinfo CFLAGS="-s USE_SDL=0 -O2 -Wno-warn-absolute-paths -Wdeclaration-after-statement -Werror=declaration-after-statement" --prefix="$PWD/emscripten-sdl2-installed" || exit $?
|
||||
|
||||
echo "Building..."
|
||||
emmake $MAKE || exit $?
|
||||
|
||||
4
configure
vendored
4
configure
vendored
@@ -3433,8 +3433,8 @@ orig_CFLAGS="$CFLAGS"
|
||||
|
||||
# See docs/release_checklist.md
|
||||
SDL_MAJOR_VERSION=2
|
||||
SDL_MINOR_VERSION=23
|
||||
SDL_MICRO_VERSION=2
|
||||
SDL_MINOR_VERSION=24
|
||||
SDL_MICRO_VERSION=0
|
||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||
|
||||
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
|
||||
|
||||
@@ -12,8 +12,8 @@ orig_CFLAGS="$CFLAGS"
|
||||
dnl Set various version strings - taken gratefully from the GTk sources
|
||||
# See docs/release_checklist.md
|
||||
SDL_MAJOR_VERSION=2
|
||||
SDL_MINOR_VERSION=23
|
||||
SDL_MICRO_VERSION=2
|
||||
SDL_MINOR_VERSION=24
|
||||
SDL_MICRO_VERSION=0
|
||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||
|
||||
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
|
||||
|
||||
@@ -373,14 +373,22 @@ typedef uint64_t Uint64;
|
||||
#endif
|
||||
#endif /* SDL_DISABLE_ANALYZE_MACROS */
|
||||
|
||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
|
||||
#elif defined(__cplusplus) && (__cplusplus >= 201103L)
|
||||
#ifndef SDL_COMPILE_TIME_ASSERT
|
||||
#if defined(__cplusplus)
|
||||
#if (__cplusplus >= 201103L)
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
|
||||
#else /* universal, but may trigger -Wunused-local-typedefs */
|
||||
#endif
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
|
||||
#endif
|
||||
#endif /* !SDL_COMPILE_TIME_ASSERT */
|
||||
|
||||
#ifndef SDL_COMPILE_TIME_ASSERT
|
||||
/* universal, but may trigger -Wunused-local-typedefs */
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) \
|
||||
typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
|
||||
#endif
|
||||
|
||||
/** \cond */
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
|
||||
|
||||
@@ -58,8 +58,8 @@ typedef struct SDL_version
|
||||
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
|
||||
*/
|
||||
#define SDL_MAJOR_VERSION 2
|
||||
#define SDL_MINOR_VERSION 23
|
||||
#define SDL_PATCHLEVEL 2
|
||||
#define SDL_MINOR_VERSION 24
|
||||
#define SDL_PATCHLEVEL 0
|
||||
|
||||
/**
|
||||
* Macro to determine SDL version program was compiled against.
|
||||
|
||||
@@ -130,7 +130,7 @@ static void PS2AUDIO_ThreadInit(_THIS)
|
||||
ee_thread_status_t status;
|
||||
thid = GetThreadId();
|
||||
if (ReferThreadStatus(GetThreadId(), &status) == 0) {
|
||||
ChangeThreadPriority(thid, status.current_priority);
|
||||
ChangeThreadPriority(thid, status.current_priority - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
#define XDG_PORTAL_DBUS_PATH "/org/freedesktop/portal/desktop"
|
||||
#define XDG_PORTAL_DBUS_INTERFACE "org.freedesktop.portal.Realtime"
|
||||
|
||||
static DBusConnection *rtkit_dbus_conn;
|
||||
static SDL_bool rtkit_use_session_conn;
|
||||
static const char *rtkit_dbus_node;
|
||||
static const char *rtkit_dbus_path;
|
||||
static const char *rtkit_dbus_interface;
|
||||
@@ -87,37 +87,52 @@ set_rtkit_interface()
|
||||
|
||||
/* xdg-desktop-portal works in all instances, so check for it first. */
|
||||
if (dbus && realtime_portal_supported(dbus->session_conn)) {
|
||||
rtkit_dbus_conn = dbus->session_conn;
|
||||
rtkit_use_session_conn = SDL_TRUE;
|
||||
rtkit_dbus_node = XDG_PORTAL_DBUS_NODE;
|
||||
rtkit_dbus_path = XDG_PORTAL_DBUS_PATH;
|
||||
rtkit_dbus_interface = XDG_PORTAL_DBUS_INTERFACE;
|
||||
} else { /* Fall back to the standard rtkit interface in all other cases. */
|
||||
rtkit_dbus_conn = dbus ? dbus->system_conn : NULL;
|
||||
rtkit_use_session_conn = SDL_FALSE;
|
||||
rtkit_dbus_node = RTKIT_DBUS_NODE;
|
||||
rtkit_dbus_path = RTKIT_DBUS_PATH;
|
||||
rtkit_dbus_interface = RTKIT_DBUS_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
static DBusConnection*
|
||||
get_rtkit_dbus_connection()
|
||||
{
|
||||
SDL_DBusContext *dbus = SDL_DBus_GetContext();
|
||||
|
||||
if (dbus) {
|
||||
return rtkit_use_session_conn ? dbus->session_conn : dbus->system_conn;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
rtkit_initialize()
|
||||
{
|
||||
DBusConnection *dbus_conn;
|
||||
|
||||
set_rtkit_interface();
|
||||
dbus_conn = get_rtkit_dbus_connection();
|
||||
|
||||
/* Try getting minimum nice level: this is often greater than PRIO_MIN (-20). */
|
||||
if (!rtkit_dbus_conn || !SDL_DBus_QueryPropertyOnConnection(rtkit_dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel",
|
||||
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel",
|
||||
DBUS_TYPE_INT32, &rtkit_min_nice_level)) {
|
||||
rtkit_min_nice_level = -20;
|
||||
}
|
||||
|
||||
/* Try getting maximum realtime priority: this can be less than the POSIX default (99). */
|
||||
if (!rtkit_dbus_conn || !SDL_DBus_QueryPropertyOnConnection(rtkit_dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority",
|
||||
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority",
|
||||
DBUS_TYPE_INT32, &rtkit_max_realtime_priority)) {
|
||||
rtkit_max_realtime_priority = 99;
|
||||
}
|
||||
|
||||
/* Try getting maximum rttime allowed by rtkit: exceeding this value will result in SIGKILL */
|
||||
if (!rtkit_dbus_conn || !SDL_DBus_QueryPropertyOnConnection(rtkit_dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax",
|
||||
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax",
|
||||
DBUS_TYPE_INT64, &rtkit_max_rttime_usec)) {
|
||||
rtkit_max_rttime_usec = 200000;
|
||||
}
|
||||
@@ -190,16 +205,18 @@ rtkit_initialize_realtime_thread()
|
||||
static SDL_bool
|
||||
rtkit_setpriority_nice(pid_t thread, int nice_level)
|
||||
{
|
||||
DBusConnection *dbus_conn;
|
||||
Uint64 pid = (Uint64)getpid();
|
||||
Uint64 tid = (Uint64)thread;
|
||||
Sint32 nice = (Sint32)nice_level;
|
||||
|
||||
pthread_once(&rtkit_initialize_once, rtkit_initialize);
|
||||
dbus_conn = get_rtkit_dbus_connection();
|
||||
|
||||
if (nice < rtkit_min_nice_level)
|
||||
nice = rtkit_min_nice_level;
|
||||
|
||||
if (!rtkit_dbus_conn || !SDL_DBus_CallMethodOnConnection(rtkit_dbus_conn,
|
||||
if (!dbus_conn || !SDL_DBus_CallMethodOnConnection(dbus_conn,
|
||||
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadHighPriorityWithPID",
|
||||
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_INT32, &nice, DBUS_TYPE_INVALID,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
@@ -211,11 +228,13 @@ rtkit_setpriority_nice(pid_t thread, int nice_level)
|
||||
static SDL_bool
|
||||
rtkit_setpriority_realtime(pid_t thread, int rt_priority)
|
||||
{
|
||||
DBusConnection *dbus_conn;
|
||||
Uint64 pid = (Uint64)getpid();
|
||||
Uint64 tid = (Uint64)thread;
|
||||
Uint32 priority = (Uint32)rt_priority;
|
||||
|
||||
pthread_once(&rtkit_initialize_once, rtkit_initialize);
|
||||
dbus_conn = get_rtkit_dbus_connection();
|
||||
|
||||
if (priority > rtkit_max_realtime_priority)
|
||||
priority = rtkit_max_realtime_priority;
|
||||
@@ -228,7 +247,7 @@ rtkit_setpriority_realtime(pid_t thread, int rt_priority)
|
||||
// go through to determine whether it really needs to fail or not.
|
||||
rtkit_initialize_realtime_thread();
|
||||
|
||||
if (!rtkit_dbus_conn || !SDL_DBus_CallMethodOnConnection(rtkit_dbus_conn,
|
||||
if (!dbus_conn || !SDL_DBus_CallMethodOnConnection(dbus_conn,
|
||||
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadRealtimeWithPID",
|
||||
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_UINT32, &priority, DBUS_TYPE_INVALID,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
|
||||
@@ -1743,7 +1743,8 @@ SDL_JoystickEventState(int state)
|
||||
#else
|
||||
const Uint32 event_list[] = {
|
||||
SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION,
|
||||
SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED
|
||||
SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED,
|
||||
SDL_JOYBATTERYUPDATED
|
||||
};
|
||||
unsigned int i;
|
||||
|
||||
|
||||
@@ -522,21 +522,19 @@ void
|
||||
HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID)
|
||||
{
|
||||
int i, j;
|
||||
SDL_bool unique = HIDAPI_JoystickInstanceIsUnique(device, joystickID);
|
||||
|
||||
SDL_LockJoysticks();
|
||||
|
||||
if (!unique) {
|
||||
if (!HIDAPI_JoystickInstanceIsUnique(device, joystickID)) {
|
||||
/* Disconnecting a child always disconnects the parent */
|
||||
device = device->parent;
|
||||
unique = SDL_TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; i < device->num_joysticks; ++i) {
|
||||
if (device->joysticks[i] == joystickID) {
|
||||
if (unique) {
|
||||
SDL_Joystick *joystick = SDL_JoystickFromInstanceID(joystickID);
|
||||
if (joystick) {
|
||||
HIDAPI_JoystickClose(joystick);
|
||||
}
|
||||
SDL_Joystick *joystick = SDL_JoystickFromInstanceID(joystickID);
|
||||
if (joystick) {
|
||||
HIDAPI_JoystickClose(joystick);
|
||||
}
|
||||
|
||||
HIDAPI_DelJoystickInstanceFromDevice(device, joystickID);
|
||||
@@ -546,18 +544,18 @@ HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID
|
||||
HIDAPI_DelJoystickInstanceFromDevice(child, joystickID);
|
||||
}
|
||||
|
||||
if (unique) {
|
||||
--SDL_HIDAPI_numjoysticks;
|
||||
--SDL_HIDAPI_numjoysticks;
|
||||
|
||||
if (!shutting_down) {
|
||||
SDL_PrivateJoystickRemoved(joystickID);
|
||||
}
|
||||
if (!shutting_down) {
|
||||
SDL_PrivateJoystickRemoved(joystickID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Rescan the device list in case device state has changed */
|
||||
SDL_HIDAPI_change_count = 0;
|
||||
|
||||
SDL_UnlockJoysticks();
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,23,2,0
|
||||
PRODUCTVERSION 2,23,2,0
|
||||
FILEVERSION 2,24,0,0
|
||||
PRODUCTVERSION 2,24,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEFLAGS 0x0L
|
||||
FILEOS 0x40004L
|
||||
@@ -23,12 +23,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "\0"
|
||||
VALUE "FileDescription", "SDL\0"
|
||||
VALUE "FileVersion", "2, 23, 2, 0\0"
|
||||
VALUE "FileVersion", "2, 24, 0, 0\0"
|
||||
VALUE "InternalName", "SDL\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2022 Sam Lantinga\0"
|
||||
VALUE "OriginalFilename", "SDL2.dll\0"
|
||||
VALUE "ProductName", "Simple DirectMedia Layer\0"
|
||||
VALUE "ProductVersion", "2, 23, 2, 0\0"
|
||||
VALUE "ProductVersion", "2, 24, 0, 0\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -1919,6 +1919,10 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
if (data->shaders && data->num_texture_units >= 3) {
|
||||
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12;
|
||||
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
|
||||
}
|
||||
|
||||
/* We support NV12 textures using 2 textures and a shader */
|
||||
if (data->shaders && data->num_texture_units >= 2) {
|
||||
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV12;
|
||||
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21;
|
||||
}
|
||||
|
||||
@@ -678,9 +678,20 @@ static void
|
||||
PS2_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata;
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
|
||||
if (data == 0)
|
||||
return;
|
||||
|
||||
if(ps2_texture == 0)
|
||||
return;
|
||||
|
||||
// Free from vram
|
||||
gsKit_TexManager_free(data->gsGlobal, ps2_texture);
|
||||
|
||||
SDL_free(ps2_texture->Mem);
|
||||
SDL_free(ps2_texture);
|
||||
texture->driverdata = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -126,6 +126,7 @@ SDL_GetPixelFormatName(Uint32 format)
|
||||
CASE(SDL_PIXELFORMAT_YVYU)
|
||||
CASE(SDL_PIXELFORMAT_NV12)
|
||||
CASE(SDL_PIXELFORMAT_NV21)
|
||||
CASE(SDL_PIXELFORMAT_EXTERNAL_OES)
|
||||
#undef CASE
|
||||
default:
|
||||
return "SDL_PIXELFORMAT_UNKNOWN";
|
||||
|
||||
@@ -149,6 +149,12 @@ struct SDL_SysWMinfo;
|
||||
/* Define the SDL video driver structure */
|
||||
#define _THIS SDL_VideoDevice *_this
|
||||
|
||||
/* Video device flags */
|
||||
typedef enum {
|
||||
VIDEO_DEVICE_QUIRK_DISABLE_DISPLAY_MODE_SWITCHING = 0x01,
|
||||
VIDEO_DEVICE_QUIRK_DISABLE_UNSET_FULLSCREEN_ON_MINIMIZE = 0x02,
|
||||
} DeviceQuirkFlags;
|
||||
|
||||
struct SDL_VideoDevice
|
||||
{
|
||||
/* * * */
|
||||
@@ -347,7 +353,7 @@ struct SDL_VideoDevice
|
||||
Uint32 next_object_id;
|
||||
char *clipboard_text;
|
||||
SDL_bool setting_display_mode;
|
||||
SDL_bool disable_display_mode_switching;
|
||||
Uint32 quirk_flags;
|
||||
|
||||
/* * * */
|
||||
/* Data used by the GL drivers */
|
||||
|
||||
@@ -166,6 +166,18 @@ extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window * window);
|
||||
extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state);
|
||||
#endif
|
||||
|
||||
/* Convenience functions for reading driver flags */
|
||||
static SDL_bool
|
||||
DisableDisplayModeSwitching(_THIS)
|
||||
{
|
||||
return !!(_this->quirk_flags & VIDEO_DEVICE_QUIRK_DISABLE_DISPLAY_MODE_SWITCHING);
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
DisableUnsetFullscreenOnMinimize(_THIS)
|
||||
{
|
||||
return !!(_this->quirk_flags & VIDEO_DEVICE_QUIRK_DISABLE_UNSET_FULLSCREEN_ON_MINIMIZE);
|
||||
}
|
||||
|
||||
/* Support for framebuffer emulation using an accelerated renderer */
|
||||
|
||||
@@ -1419,7 +1431,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
|
||||
}
|
||||
|
||||
/* Don't try to change the display mode if the driver doesn't want it. */
|
||||
if (_this->disable_display_mode_switching == SDL_FALSE) {
|
||||
if (DisableDisplayModeSwitching(_this) == SDL_FALSE) {
|
||||
/* only do the mode change if we want exclusive fullscreen */
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
|
||||
if (SDL_SetDisplayModeForDisplay(display, &fullscreen_mode) < 0) {
|
||||
@@ -2524,7 +2536,9 @@ SDL_MinimizeWindow(SDL_Window * window)
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_UpdateFullscreenMode(window, SDL_FALSE);
|
||||
if (!DisableUnsetFullscreenOnMinimize(_this)) {
|
||||
SDL_UpdateFullscreenMode(window, SDL_FALSE);
|
||||
}
|
||||
|
||||
if (_this->MinimizeWindow) {
|
||||
_this->MinimizeWindow(_this, window);
|
||||
@@ -3072,7 +3086,9 @@ SDL_OnWindowMoved(SDL_Window * window)
|
||||
void
|
||||
SDL_OnWindowMinimized(SDL_Window * window)
|
||||
{
|
||||
SDL_UpdateFullscreenMode(window, SDL_FALSE);
|
||||
if (!DisableUnsetFullscreenOnMinimize(_this)) {
|
||||
SDL_UpdateFullscreenMode(window, SDL_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -3153,7 +3169,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
|
||||
hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
|
||||
if (!hint || !*hint || SDL_strcasecmp(hint, "auto") == 0) {
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP ||
|
||||
_this->disable_display_mode_switching == SDL_TRUE) {
|
||||
DisableDisplayModeSwitching(_this) == SDL_TRUE) {
|
||||
return SDL_FALSE;
|
||||
} else {
|
||||
return SDL_TRUE;
|
||||
|
||||
@@ -299,12 +299,14 @@ GetHintCtrlClickEmulateRightClick()
|
||||
static NSUInteger
|
||||
GetWindowWindowedStyle(SDL_Window * window)
|
||||
{
|
||||
NSUInteger style = 0;
|
||||
/* always allow miniaturization, otherwise you can't programatically
|
||||
minimize the window, whether there's a title bar or not */
|
||||
NSUInteger style = NSWindowStyleMaskMiniaturizable;
|
||||
|
||||
if (window->flags & SDL_WINDOW_BORDERLESS) {
|
||||
style = NSWindowStyleMaskBorderless;
|
||||
style |= NSWindowStyleMaskBorderless;
|
||||
} else {
|
||||
style = (NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskMiniaturizable);
|
||||
style |= (NSWindowStyleMaskTitled|NSWindowStyleMaskClosable);
|
||||
}
|
||||
if (window->flags & SDL_WINDOW_RESIZABLE) {
|
||||
style |= NSWindowStyleMaskResizable;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_system.h"
|
||||
#include "SDL_uikitevents.h"
|
||||
#include "SDL_uikitopengles.h"
|
||||
#include "SDL_uikitvideo.h"
|
||||
|
||||
@@ -22,10 +22,11 @@
|
||||
|
||||
#if SDL_VIDEO_DRIVER_UIKIT
|
||||
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_system.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_pixels_c.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
@@ -43,7 +43,7 @@ Wayland_SetClipboardText(_THIS, const char *text)
|
||||
if (text[0] != '\0') {
|
||||
SDL_WaylandDataSource* source = Wayland_data_source_create(_this);
|
||||
Wayland_data_source_add_data(source, TEXT_MIME, text,
|
||||
SDL_strlen(text) + 1);
|
||||
SDL_strlen(text));
|
||||
|
||||
status = Wayland_data_device_set_selection(data_device, source);
|
||||
if (status != 0) {
|
||||
|
||||
@@ -305,14 +305,22 @@ Wayland_data_source_get_data(SDL_WaylandDataSource *source,
|
||||
} else {
|
||||
mime_data = mime_data_list_find(&source->mimes, mime_type);
|
||||
if (mime_data != NULL && mime_data->length > 0) {
|
||||
buffer = SDL_malloc(mime_data->length);
|
||||
size_t buffer_length = mime_data->length;
|
||||
|
||||
if (null_terminate == SDL_TRUE) {
|
||||
++buffer_length;
|
||||
}
|
||||
buffer = SDL_malloc(buffer_length);
|
||||
if (buffer == NULL) {
|
||||
*length = SDL_OutOfMemory();
|
||||
} else {
|
||||
*length = mime_data->length;
|
||||
SDL_memcpy(buffer, mime_data->data, mime_data->length);
|
||||
if (null_terminate) {
|
||||
*((Uint8 *)buffer + mime_data->length) = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return buffer;
|
||||
|
||||
@@ -279,7 +279,8 @@ Wayland_CreateDevice(void)
|
||||
|
||||
device->free = Wayland_DeleteDevice;
|
||||
|
||||
device->disable_display_mode_switching = SDL_TRUE;
|
||||
device->quirk_flags = VIDEO_DEVICE_QUIRK_DISABLE_DISPLAY_MODE_SWITCHING |
|
||||
VIDEO_DEVICE_QUIRK_DISABLE_UNSET_FULLSCREEN_ON_MINIMIZE;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
@@ -547,9 +547,6 @@ handle_configure_xdg_toplevel(void *data,
|
||||
|
||||
if (!fullscreen) {
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
/* We might need to re-enter fullscreen after being restored from minimized */
|
||||
SetFullscreen(window, driverdata->output, SDL_FALSE);
|
||||
|
||||
/* Foolishly do what the compositor says here. If it's wrong, don't
|
||||
* blame us, we were explicitly instructed to do this.
|
||||
*
|
||||
@@ -785,13 +782,6 @@ decoration_frame_configure(struct libdecor_frame *frame,
|
||||
driverdata = (SDL_WaylandOutputData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
|
||||
if (!fullscreen) {
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
/* We might need to re-enter fullscreen after being restored from minimized */
|
||||
SetFullscreen(window, driverdata->output, SDL_FALSE);
|
||||
fullscreen = SDL_TRUE;
|
||||
floating = SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Always send a maximized/restore event; if the event is redundant it will
|
||||
* automatically be discarded (see src/events/SDL_windowevents.c)
|
||||
*
|
||||
@@ -1227,6 +1217,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||
if (data->shell_surface.libdecor.frame) {
|
||||
/* If the frame already exists, just set the visibility. */
|
||||
libdecor_frame_set_visibility(data->shell_surface.libdecor.frame, true);
|
||||
libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname);
|
||||
} else {
|
||||
data->shell_surface.libdecor.frame = libdecor_decorate(c->shell.libdecor,
|
||||
data->surface,
|
||||
@@ -1311,8 +1302,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||
* libdecor will call this as part of their configure event!
|
||||
* -flibit
|
||||
*/
|
||||
SDL_WaylandOutputData *odata = SDL_GetDisplayForWindow(window)->driverdata;
|
||||
SetFullscreen(window, (window->flags & SDL_WINDOW_FULLSCREEN) ? odata->output : NULL, SDL_TRUE);
|
||||
wl_surface_commit(data->surface);
|
||||
if (data->shell_surface.xdg.surface) {
|
||||
while (!data->shell_surface.xdg.initial_configure_seen) {
|
||||
WAYLAND_wl_display_flush(c->display);
|
||||
@@ -1370,10 +1360,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||
* Roundtrip required to avoid a possible protocol violation when
|
||||
* HideWindow was called immediately before ShowWindow.
|
||||
*/
|
||||
if (data->needs_roundtrip) {
|
||||
data->needs_roundtrip = SDL_FALSE;
|
||||
WAYLAND_wl_display_roundtrip(c->display);
|
||||
}
|
||||
WAYLAND_wl_display_roundtrip(c->display);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1430,6 +1417,7 @@ void Wayland_HideWindow(_THIS, SDL_Window *window)
|
||||
if (WINDOW_IS_LIBDECOR(data, window)) {
|
||||
if (wind->shell_surface.libdecor.frame) {
|
||||
libdecor_frame_set_visibility(wind->shell_surface.libdecor.frame, false);
|
||||
libdecor_frame_set_app_id(wind->shell_surface.libdecor.frame, data->classname);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
@@ -1450,7 +1438,6 @@ void Wayland_HideWindow(_THIS, SDL_Window *window)
|
||||
* Roundtrip required to avoid a possible protocol violation when
|
||||
* ShowWindow is called immediately after HideWindow.
|
||||
*/
|
||||
wind->needs_roundtrip = SDL_TRUE;
|
||||
WAYLAND_wl_display_roundtrip(data->display);
|
||||
}
|
||||
|
||||
@@ -2084,26 +2071,25 @@ void Wayland_SetWindowTitle(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *wind = window->driverdata;
|
||||
SDL_VideoData *viddata = _this->driverdata;
|
||||
const char *title = window->title ? window->title : "";
|
||||
|
||||
if (WINDOW_IS_XDG_POPUP(window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window->title != NULL) {
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
if (WINDOW_IS_LIBDECOR(viddata, window)) {
|
||||
if (wind->shell_surface.libdecor.frame == NULL) {
|
||||
return; /* Can't do anything yet, wait for ShowWindow */
|
||||
}
|
||||
libdecor_frame_set_title(wind->shell_surface.libdecor.frame, window->title);
|
||||
} else
|
||||
if (WINDOW_IS_LIBDECOR(viddata, window)) {
|
||||
if (wind->shell_surface.libdecor.frame == NULL) {
|
||||
return; /* Can't do anything yet, wait for ShowWindow */
|
||||
}
|
||||
libdecor_frame_set_title(wind->shell_surface.libdecor.frame, title);
|
||||
} else
|
||||
#endif
|
||||
if (viddata->shell.xdg) {
|
||||
if (wind->shell_surface.xdg.roleobj.toplevel == NULL) {
|
||||
return; /* Can't do anything yet, wait for ShowWindow */
|
||||
}
|
||||
xdg_toplevel_set_title(wind->shell_surface.xdg.roleobj.toplevel, window->title);
|
||||
if (wind->shell_surface.xdg.roleobj.toplevel == NULL) {
|
||||
return; /* Can't do anything yet, wait for ShowWindow */
|
||||
}
|
||||
xdg_toplevel_set_title(wind->shell_surface.xdg.roleobj.toplevel, title);
|
||||
}
|
||||
|
||||
WAYLAND_wl_display_flush(viddata->display);
|
||||
|
||||
@@ -107,7 +107,6 @@ typedef struct {
|
||||
SDL_Rect viewport_rect;
|
||||
SDL_bool needs_resize_event;
|
||||
SDL_bool floating_resize_pending;
|
||||
SDL_bool needs_roundtrip;
|
||||
} SDL_WindowData;
|
||||
|
||||
extern void Wayland_ShowWindow(_THIS, SDL_Window *window);
|
||||
|
||||
@@ -358,16 +358,20 @@ static int
|
||||
X11_CaptureMouse(SDL_Window *window)
|
||||
{
|
||||
Display *display = GetDisplay();
|
||||
SDL_Window *mouse_focus = SDL_GetMouseFocus();
|
||||
|
||||
if (window) {
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask;
|
||||
Window confined = (data->mouse_grabbed ? data->xwindow : None);
|
||||
const int rc = X11_XGrabPointer(display, data->xwindow, False,
|
||||
mask, GrabModeAsync, GrabModeAsync,
|
||||
None, None, CurrentTime);
|
||||
confined, None, CurrentTime);
|
||||
if (rc != GrabSuccess) {
|
||||
return SDL_SetError("X server refused mouse capture");
|
||||
}
|
||||
} else if (mouse_focus) {
|
||||
SDL_UpdateWindowGrab(mouse_focus);
|
||||
} else {
|
||||
X11_XUngrabPointer(display, CurrentTime);
|
||||
}
|
||||
|
||||
@@ -1600,6 +1600,7 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
if (data == NULL) {
|
||||
return;
|
||||
}
|
||||
data->mouse_grabbed = SDL_FALSE;
|
||||
|
||||
display = data->videodata->display;
|
||||
|
||||
@@ -1622,6 +1623,7 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
result = X11_XGrabPointer(display, data->xwindow, True, mask, GrabModeAsync,
|
||||
GrabModeAsync, data->xwindow, None, CurrentTime);
|
||||
if (result == GrabSuccess) {
|
||||
data->mouse_grabbed = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
SDL_Delay(50);
|
||||
|
||||
@@ -59,6 +59,7 @@ typedef struct
|
||||
int border_right;
|
||||
int border_top;
|
||||
int border_bottom;
|
||||
SDL_bool mouse_grabbed;
|
||||
Uint32 last_focus_event_time;
|
||||
PendingFocusEnum pending_focus;
|
||||
Uint32 pending_focus_time;
|
||||
|
||||
151
test/testgles2.c
151
test/testgles2.c
@@ -51,6 +51,13 @@ typedef struct shader_data
|
||||
GLuint color_buffer;
|
||||
} shader_data;
|
||||
|
||||
typedef struct thread_data
|
||||
{
|
||||
SDL_Thread *thread;
|
||||
int done;
|
||||
int index;
|
||||
} thread_data;
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
static SDL_GLContext *context = NULL;
|
||||
static int depth = 16;
|
||||
@@ -434,6 +441,7 @@ Render(unsigned int width, unsigned int height, shader_data* data)
|
||||
if(data->angle_z >= 360) data->angle_z -= 360;
|
||||
if(data->angle_z < 0) data->angle_z += 360;
|
||||
|
||||
GL_CHECK(ctx.glViewport(0, 0, width, height));
|
||||
GL_CHECK(ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT));
|
||||
GL_CHECK(ctx.glDrawArrays(GL_TRIANGLES, 0, 36));
|
||||
}
|
||||
@@ -441,56 +449,84 @@ Render(unsigned int width, unsigned int height, shader_data* data)
|
||||
int done;
|
||||
Uint32 frames;
|
||||
shader_data *datas;
|
||||
thread_data *threads;
|
||||
|
||||
void loop()
|
||||
static void
|
||||
render_window(int index)
|
||||
{
|
||||
int w, h, status;
|
||||
|
||||
if (!state->windows[index]) {
|
||||
return;
|
||||
}
|
||||
|
||||
status = SDL_GL_MakeCurrent(state->windows[index], context[index]);
|
||||
if (status) {
|
||||
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_GL_GetDrawableSize(state->windows[index], &w, &h);
|
||||
Render(w, h, &datas[index]);
|
||||
SDL_GL_SwapWindow(state->windows[index]);
|
||||
++frames;
|
||||
}
|
||||
|
||||
static int SDLCALL
|
||||
render_thread_fn(void* render_ctx)
|
||||
{
|
||||
thread_data *thread = render_ctx;
|
||||
|
||||
while (!done && !thread->done && state->windows[thread->index]) {
|
||||
render_window(thread->index);
|
||||
}
|
||||
|
||||
SDL_GL_MakeCurrent(state->windows[thread->index], NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
loop_threaded()
|
||||
{
|
||||
SDL_Event event;
|
||||
int i;
|
||||
int status;
|
||||
|
||||
/* Check for events */
|
||||
++frames;
|
||||
while (SDL_PollEvent(&event) && !done) {
|
||||
switch (event.type) {
|
||||
case SDL_WINDOWEVENT:
|
||||
switch (event.window.event) {
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
|
||||
int w, h;
|
||||
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
|
||||
if (status) {
|
||||
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
|
||||
break;
|
||||
}
|
||||
/* Change view port to the new window dimensions */
|
||||
SDL_GL_GetDrawableSize(state->windows[i], &w, &h);
|
||||
ctx.glViewport(0, 0, w, h);
|
||||
state->window_w = event.window.data1;
|
||||
state->window_h = event.window.data2;
|
||||
/* Update window content */
|
||||
Render(event.window.data1, event.window.data2, &datas[i]);
|
||||
SDL_GL_SwapWindow(state->windows[i]);
|
||||
break;
|
||||
/* Wait for events */
|
||||
while (SDL_WaitEvent(&event) && !done) {
|
||||
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE) {
|
||||
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
|
||||
if (window) {
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
if (window == state->windows[i]) {
|
||||
/* Stop the render thread when the window is closed */
|
||||
threads[i].done = 1;
|
||||
if (threads[i].thread) {
|
||||
SDL_WaitThread(threads[i].thread, NULL);
|
||||
threads[i].thread = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SDLTest_CommonEvent(state, &event, &done);
|
||||
}
|
||||
if (!done) {
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
|
||||
if (status) {
|
||||
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
|
||||
}
|
||||
|
||||
/* Continue for next window */
|
||||
continue;
|
||||
}
|
||||
Render(state->window_w, state->window_h, &datas[i]);
|
||||
SDL_GL_SwapWindow(state->windows[i]);
|
||||
}
|
||||
static void
|
||||
loop()
|
||||
{
|
||||
SDL_Event event;
|
||||
int i;
|
||||
|
||||
/* Check for events */
|
||||
while (SDL_PollEvent(&event) && !done) {
|
||||
SDLTest_CommonEvent(state, &event, &done);
|
||||
}
|
||||
if (!done) {
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
render_window(i);
|
||||
}
|
||||
}
|
||||
#ifdef __EMSCRIPTEN__
|
||||
else {
|
||||
@@ -502,7 +538,7 @@ void loop()
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int fsaa, accel;
|
||||
int fsaa, accel, threaded;
|
||||
int value;
|
||||
int i;
|
||||
SDL_DisplayMode mode;
|
||||
@@ -513,6 +549,7 @@ main(int argc, char *argv[])
|
||||
/* Initialize parameters */
|
||||
fsaa = 0;
|
||||
accel = 0;
|
||||
threaded = 0;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
@@ -530,6 +567,9 @@ main(int argc, char *argv[])
|
||||
} else if (SDL_strcasecmp(argv[i], "--accel") == 0) {
|
||||
++accel;
|
||||
consumed = 1;
|
||||
} else if (SDL_strcasecmp(argv[i], "--threaded") == 0) {
|
||||
++threaded;
|
||||
consumed = 1;
|
||||
} else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) {
|
||||
i++;
|
||||
if (!argv[i]) {
|
||||
@@ -543,7 +583,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
if (consumed < 0) {
|
||||
static const char *options[] = { "[--fsaa]", "[--accel]", "[--zdepth %d]", NULL };
|
||||
static const char *options[] = { "[--fsaa]", "[--accel]", "[--zdepth %d]", "[--threaded]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
quit(1);
|
||||
}
|
||||
@@ -551,7 +591,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Set OpenGL parameters */
|
||||
state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
|
||||
state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
|
||||
state->gl_red_size = 5;
|
||||
state->gl_green_size = 5;
|
||||
state->gl_blue_size = 5;
|
||||
@@ -603,6 +643,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
SDL_GetCurrentDisplayMode(0, &mode);
|
||||
SDL_Log("Threaded : %s\n", threaded ? "yes" : "no");
|
||||
SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
|
||||
SDL_Log("\n");
|
||||
SDL_Log("Vendor : %s\n", ctx.glGetString(GL_VENDOR));
|
||||
@@ -724,6 +765,8 @@ main(int argc, char *argv[])
|
||||
|
||||
GL_CHECK(ctx.glEnable(GL_CULL_FACE));
|
||||
GL_CHECK(ctx.glEnable(GL_DEPTH_TEST));
|
||||
|
||||
SDL_GL_MakeCurrent(state->windows[i], NULL);
|
||||
}
|
||||
|
||||
/* Main render loop */
|
||||
@@ -734,8 +777,30 @@ main(int argc, char *argv[])
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(loop, 0, 1);
|
||||
#else
|
||||
while (!done) {
|
||||
loop();
|
||||
if (threaded) {
|
||||
threads = (thread_data*)SDL_calloc(state->num_windows, sizeof(thread_data));
|
||||
|
||||
/* Start a render thread for each window */
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
threads[i].index = i;
|
||||
threads[i].thread = SDL_CreateThread(render_thread_fn, "RenderThread", &threads[i]);
|
||||
}
|
||||
|
||||
while (!done) {
|
||||
loop_threaded();
|
||||
}
|
||||
|
||||
/* Join the remaining render threads (if any) */
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
threads[i].done = 1;
|
||||
if (threads[i].thread) {
|
||||
SDL_WaitThread(threads[i].thread, NULL);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (!done) {
|
||||
loop();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user