This uses the same `SDL_VerbNoun` format as the rest of SDL3, and also
adds stronger effort to invalidate cached state in the backend, so cooperation
improves with apps that are using lowlevel rendering APIs directly.
Fixes#367.
Fully committing to it...!
This left SDL_wave.* alone for now, since there's a ton of comments in there
and this code hasn't changed much from SDL2 so far. But as SDL2 ages out a
little more, I'll likely switch this over, too.
The following objects now have properties that can be user modified:
* SDL_AudioStream
* SDL_Gamepad
* SDL_Joystick
* SDL_RWops
* SDL_Renderer
* SDL_Sensor
* SDL_Surface
* SDL_Texture
* SDL_Window
This insert files to the Xcode and Visual Studio projects, so you can add
sources to the build without having to find a Mac or Windows machine with
the appropriate tools installed, and manually update four different sets of
projects across them.
This doesn't touch CMake, but you can add files to that with a text editor
(hopefully) without drama.
This, like all Perl code, is fragile. Report bugs and don't push it too hard.
Otherwise they appear in random order, which isn't ideal in general, but
also this breaks the wiki/header bridge because it can't produce identical
conversions per-run.
The sequence order of the four paddles is not obvious, with SDL and Xbox
controllers swapping the order of P2 and P3 relative to each other.
If we group them into left and right, then it becomes more obvious.
Signed-off-by: Simon McVittie <smcv@collabora.com>
The current status is stored in the SDL_rwops 'status' field to be able to determine whether a 0 return value is caused by end of file, an error, or a non-blocking source not being ready.
The functions to read sized datatypes now return SDL_bool so you can detect read errors.
Fixes https://github.com/libsdl-org/SDL/issues/6729
Also renamed SDL_GetDisplayOrientation() SDL_GetDisplayCurrentOrientation()
The natural orientation of the primary display is the frame of reference for accelerometer and gyro sensor readings.
We have gotten feedback that abstracting the coordinate system based on the display scale is unexpected and it is difficult to adapt existing applications to the proposed API.
The new approach is to provide the coordinate systems that people expect, but provide additional information that will help applications properly handle high DPI situations.
The concepts needed for high DPI support are documented in README-highdpi.md. An example of automatically adapting the content to display scale changes can be found in SDL_test_common.c, where auto_scale_content is checked.
Also, the SDL_WINDOW_ALLOW_HIGHDPI window flag has been replaced by the SDL_HINT_VIDEO_ENABLE_HIGH_PIXEL_DENSITY hint.
Fixes https://github.com/libsdl-org/SDL/issues/7709
- SDL_AudioCVT is gone, even internally.
- libsamplerate is gone (I suspect our resampler is finally Good Enough).
- Cleanups and improvements to audio conversion interfaces.
- SDL_AudioStream can change its input/output format/rate/channels on the fly!
It turns out there's a race condition on X11 where the window could be placed by the window manager while being placed by the application, so we need to have the initial position available at window creation.
This script relies on string indexes in parameter expansions, which
aren't suppored by /bin/sh (e.g. dash).
Based on a patch by Roflcopter4:
https://github.com/joncampbell123/dosbox-x/pull/3850
Signed-off-by: Stephen Kitt <steve@sk2.org>
This adds a means to mass-convert the whole wiki to Markdown as a one-time
operation, and then some fixes to make --copy-to-headers correctly deal with
Markdown-formatted wiki pages.
This makes it clear what the new versions are, and in the case of SDL_RenderDrawPoint() and SDL_RenderDrawLine(), the coccinelle script actually does the (float) casts for you.
This fixes rounding errors with coordinate scaling and gives more flexibility in the presentation, as well as making it easy to maintain device independent resolution as windows move between different pixel density displays.
By default when a renderer is created, it will match the window size so window coordinates and render coordinates are 1-1.
Mouse and touch events are no longer filtered to change their coordinates, instead you can call SDL_ConvertEventToRenderCoordinates() to explicitly map event coordinates into the rendering viewport.
SDL_RenderWindowToLogical() and SDL_RenderLogicalToWindow() have been renamed SDL_RenderCoordinatesFromWindow() and SDL_RenderCoordinatesToWindow() and take floating point coordinates in both directions.
The viewport, clipping state, and scale for render targets are now persistent and will remain set whenever they are active.
Rather than iterating over display modes using an index, there is a new function SDL_GetFullscreenDisplayModes() to get the list of available fullscreen modes on a display.
{
SDL_DisplayID display = SDL_GetPrimaryDisplay();
int num_modes = 0;
SDL_DisplayMode **modes = SDL_GetFullscreenDisplayModes(display, &num_modes);
if (modes) {
for (i = 0; i < num_modes; ++i) {
SDL_DisplayMode *mode = modes[i];
SDL_Log("Display %" SDL_PRIu32 " mode %d: %dx%d@%gHz, %d%% scale\n",
display, i, mode->pixel_w, mode->pixel_h, mode->refresh_rate, (int)(mode->display_scale * 100.0f));
}
SDL_free(modes);
}
}
SDL_GetDesktopDisplayMode() and SDL_GetCurrentDisplayMode() return pointers to display modes rather than filling in application memory.
Windows now have an explicit fullscreen mode that is set, using SDL_SetWindowFullscreenMode(). The fullscreen mode for a window can be queried with SDL_GetWindowFullscreenMode(), which returns a pointer to the mode, or NULL if the window will be fullscreen desktop. SDL_SetWindowFullscreen() just takes a boolean value, setting the correct fullscreen state based on the selected mode.
You can rename APIs using rename.py and all the code and documentation will be updated, and entries will be added to WhatsNew.txt and docs/README-migration.md.
e.g.
rename.py SDL_foo.h function SDL_CreateFoo SDL_FooCreate
SDL_oldnames.h is included in the SDL header, and if you define SDL_ENABLE_OLD_NAMES, will redefine the old API functions to call the new ones, and if not, will define them as a symbol letting you what the new API function is.
makes the SDL_main code shorter
Also added a generic SDL_RunApp() implementation for platforms that
don't really need it.
Some platforms (that use SDL_main but haven't been ported yet) are
still missing, but are added in the following commits.
and update README-visualc.md and README-gdk.md accordingly
Also moved src/main/windows/version.rc to src/core/windows/
and adjusted VS solutions, CMakeLists.txt and versioning scripts
in build-scripts/ accordingly.
This will eventually allow us to remove all of src/main/
# Conflicts:
# VisualC/tests/testgesture/testgesture.vcxproj
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.
In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.
The script I ran for the src directory is added as build-scripts/clang-format-src.sh
This fixes:
#6592#6593#6594
I ran this script in the include directory:
```sh
sed -i '' -e 's,#include "\(SDL.*\)",#include <SDL3/\1>,' *.h
```
I ran this script in the src directory:
```sh
for i in ../include/SDL3/SDL*.h
do hdr=$(basename $i)
if [ x"$(echo $hdr | egrep 'SDL_main|SDL_name|SDL_test|SDL_syswm|SDL_opengl|SDL_egl|SDL_vulkan')" != x ]; then
find . -type f -exec sed -i '' -e 's,#include "\('$hdr'\)",#include <SDL3/\1>,' {} \;
else
find . -type f -exec sed -i '' -e '/#include "'$hdr'"/d' {} \;
fi
done
```
Fixes https://github.com/libsdl-org/SDL/issues/6575
- TODO: update INSTALL.txt to replace the autotools configure
instructions with cmake.
- TODO: update make build system to provide an equivalent to
autotools' `make dist` ?
- TODO: update / revise github actions, replace autotools-only
ones with cmake (e.g.: vmactions.yml for FreeBSD.)
Reference issue: https://github.com/libsdl-org/SDL/issues/6571
This ignores 2.x.1 (etc) releases, which prevents it from thinking
the next official non-point-release version is 2.26.1, when it
should be 2.26.0, because it saw the "latest" release is 2.24.1.
This fixes the wiki ending up with imaginary version numbers for
the "this function is available since SDL 2.x.y" sections.
Fixes#6343.
Downstream distributors can use this to mark a version with their
preferred version information, like a Linux distribution package version
or the Steam revision it was built to be bundled into, or just to mark
it with the vendor it was built by or the environment it's intended to
be used in.
For instance, in Debian I'd use this by configuring with:
--enable-vendor-info="${DEB_VENDOR} ${DEB_VERSION}"
to get a SDL_REVISION like:
release-2.24.1-0-ga1d1946dc (Debian 2.24.1+dfsg-2)
which gives a Debian user enough information to track down the patches
and build-time configuration that were used for package revision 2.
In Autotools and CMake, this is a configure-time option like any other,
and will go into both SDL_REVISION (via SDL_revision.h) and
SDL_GetRevision().
In other build systems (MSVC, Xcode, etc.), defining the
SDL_VENDOR_INFO macro will get it into the output of SDL_GetRevision(),
although not SDL_REVISION.
Resolves: https://github.com/libsdl-org/SDL/issues/6418
Signed-off-by: Simon McVittie <smcv@collabora.com>
Instead of using a URL and git sha1, this uses `git describe` to
describe the version relative to the nearest previous git tag, which
gives a better indication of whether this is a release, a prerelease,
a slightly patched prerelease, or a long way after the last release
during active development.
This serves two purposes: it makes those APIs more informative, and it
also puts this information into the binary in a form that is easy to
screen-scrape using strings(1). For instance, if the bundled version of
SDL in a game has this, we can see at a glance what version it is.
It's also shorter than using the web address of the origin git
repository and the full git commit sha1.
Also write the computed version into a file ./VERSION in `make dist`
tarballs, so that when we build from a tarball on a system that doesn't
have git available, we still get the version details.
For the Perforce code path in showrev.sh, output the version number
followed by the Perforce revision, in a format reminiscent of
`git describe` (with p instead of g to indicate Perforce).
For the code path with no VCS available at all, put a suffix on the
version number to indicate that this is just a guess (we can't know
whether this SDL version is actually a git snapshot or has been
patched locally or similar).
Resolves: https://github.com/libsdl-org/SDL/issues/6418
Signed-off-by: Simon McVittie <smcv@collabora.com>
Make sure the SDL java and C code match when updating SDL in a game.
Right now we're assuming that we only have to make sure release versions match. We can extend the version string with an interface version if we need more fine grained sanity checking.
Fixes https://github.com/libsdl-org/SDL/issues/1540
For stable releases, this gives us the ability to make bugfix-only point
releases such as 2.24.1 if we want to, and distinguish between them
programmatically. For example, this ability could have been useful after
2.0.16 to fix Xwayland regressions, and after 2.0.18 to fix event loop
regressions.
For development releases, this gives us the ability to make multiple
prereleases during the same feature cycle, and distinguish between them
programmatically. For example, this would have been useful during 2.0.22
development, which went through three prereleases before reaching the
final release.
Signed-off-by: Simon McVittie <smcv@collabora.com>
GitHub Actions is a 64-bit Ubuntu instance. It was only using the 32-bit
binaries because our buildbot put this on the 32-bit Linux host to spread
the CPU load around more evenly.
This keep documentation future-accurate and more importantly: it will
produce correct results before we tag the official release in git, so
they'll be correct in the tag and the release tarball.
This will let us automate this so it's managed for us, and as things go
from development to official releases, the documentation will automatically
update!
Otherwise a formula like `x = y * 2;` would treat that '*' as the start of
an italicized section when converting to MediaWiki format, and match any
other '*' in the content as the end marker.
Details:
Currently doing 4 system calls per WM_INPUT message, which can cause the thread handling the message loop to be swapped out several times:
* GetProp - to get window data from the window handle
* GetRawInputData - to retrieve the raw input data
* 2 calls to GetMessageExtraInfo - to ignore synthetic mouse events generated for touchscreens
In this change:
* Replaced GetProp by iterating the list of windows maintained by SDL (with a fallback to GetProp). Note that this will affect all messages and not just WM_INPUT
* only calling GetMessageExtraInfo if a touchscreen has been detected
Fix for https://jira.valve.org/browse/CSGO-4855
@saml
This is a work-in-progress, but the idea is it can convert between our
wiki and the SDL header's doxygen comments, so we can attempt to keep them
in sync.
This might be a fool's errand, but I'm optimistic it'll work enough that we
can clean up little issues as we go, as long as we have some discipline
about how we write documentation. If nothing else, it's going to result in
a solid spring-cleaning of both the wiki and the headers!