Commit Graph

795 Commits (d135daad5b2a4b0a02d479457c6ceaf5da7fc164)

Author SHA1 Message Date
Sylvain 4053876bf6 Fix warning drop const qualifier 2023-03-08 22:22:34 +01:00
Sam Lantinga 91b328c2c6 Fixed emscripten build 2023-03-08 08:58:26 -08:00
Sylvain d78817703e Fix build 2023-03-08 16:42:10 +01:00
Sylvain c963f02571 More fix warnings about static function and prototype 2023-03-08 16:14:09 +01:00
Sylvain 16bb6a0b3d Fix warnings about static function and prototype 2023-03-08 11:41:18 +01:00
Sam Lantinga 698dbd8464 SDL_CreateWindow() has been simplified and no longer takes a window position. 2023-03-06 09:50:12 -08:00
Sylvain a946a34452 Add Drag and drop position, for x11, wayland and MACOSX 2023-03-06 08:44:05 -08:00
Sam Lantinga 3bba33932f Fixed testshape on high DPI displays
Since the shape is set based on the pixels in the image, we want the window to have the same number of pixels.
2023-03-02 10:15:14 -08:00
Sam Lantinga 59ca0c8b22 Simplified the testshape example 2023-03-02 10:00:15 -08:00
Sam Lantinga bd2e2ee7aa SDL_RenderTexture() and SDL_RenderTextureRotated() take floating point source coordinates
See the discussion at https://discourse.libsdl.org/t/sdl-rendercopyf-uses-ints/36732/8
2023-03-02 09:42:32 -08:00
Sam Lantinga 9e14559e80 Print the mapping used for a gamepad in testgamepad 2023-03-01 16:37:56 -08:00
Anonymous Maarten 790612f4f8 cmake: make sdltests_utils static library 2023-03-01 23:41:22 +01:00
Sylvain ac3fd00018 testautomation_pixels/audio: use SDL_arraysize and fix warnings 2023-03-01 22:15:45 +01:00
Ozkan Sezer 6fc32491c7 testautomation_audio.c: use SDL_arraysize for g_numAudioFormats. 2023-03-01 22:56:56 +03:00
Sam Lantinga d5775f6708 The gamepad event structures caxis, cbutton, cdevice, ctouchpad, and csensor have been renamed gaxis, gbutton, gdevice, gtouchpad, and gsensor.
Fixes https://github.com/libsdl-org/SDL/issues/7375
2023-03-01 09:48:28 -08:00
Ozkan Sezer 8d8b3d3a9a fix testautomation_audio.c after commit f48d0cc 2023-03-01 18:37:56 +03:00
Ryan C. Gordon f48d0cc164
audio: Remove AUDIO_U16* support.
It wasn't heavily used, and you can't use memset to silence a U16 buffer.

Fixes #7380.
2023-03-01 10:26:01 -05:00
Sam Lantinga 05ac1f8d5a Print the full information for all joysticks that are connected 2023-02-23 11:58:14 -08:00
Anonymous Maarten dc138ee3d4 cmake: SDL3-shared target will always be a shared target 2023-02-17 23:42:03 +01:00
Anonymous Maarten 4d8a50912b cmake: no shared SDL libraries for riscos 2023-02-16 13:59:23 -08:00
Anonymous Maarten e203046a5c cmake+ci: build shared and static libraries on ci 2023-02-16 13:59:23 -08:00
Eric Wasylishen 1f46986d33
testwm.c: show all modes of all displays in the on-screen list (#7323)
* testwm.c: show all modes of all displays in the on-screen list

To allow testing https://github.com/libsdl-org/SDL/pull/7317
2023-02-14 21:05:00 -08:00
Sam Lantinga 5b77ad54c4 Fixed order and constness of parameters to SDL_ConvertAudioSamples() 2023-02-09 17:49:35 -08:00
Sam Lantinga 824b9b0a58 Removed SDL_GetDisplayDPI()
This function wasn't consistently correct across platforms and devices.

If you want the UI scale factor, you can use display_scale in the structure returned by SDL_GetDesktopDisplayMode(). If you need an approximate DPI, you can multiply this value times 160 on iPhone and Android, and 96 on other platforms.
2023-02-08 17:35:54 -08:00
Ozkan Sezer e1d79b418c fix build error due to -Wshadow 2023-02-05 20:45:02 +03:00
Sam Lantinga 653f2c4ba3 Made the render tests less verbose in the successful case 2023-02-05 09:11:00 -08:00
Sam Lantinga 14a4ce8b59 Fixed SDL_ScaleMode values for consistency 2023-02-03 14:20:51 -08:00
Sylvain Becker cb6b8b0132
Simplify flags testing (#7220) 2023-02-03 13:08:42 -08:00
Sam Lantinga dcd17f5473 Renderer logical size is now implemented as a render target
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.
2023-02-03 12:57:37 -08:00
Anonymous Maarten 78be9eaf38 Revert "Add testcpuinfo.c"
This reverts commit 5888b008b1.
2023-02-02 00:49:09 +01:00
Anonymous Maarten 69aede6c9e Add missing _ in SDL_EVENT_LOCALECHANGED and SSDL_EVENT_TEXTEDITING_EXT 2023-02-02 00:49:09 +01:00
Anonymous Maarten 08bcee8570 test: don't use wiki urls for documentation comments
Also make consistent use of \ as documentation escape character.
2023-02-02 00:49:09 +01:00
Anonymous Maarten bff449eb24 testcpuinfo.c needs SDL3/SDL_main.h 2023-02-01 23:49:27 +01:00
Anonymous Maarten 5888b008b1 Add testcpuinfo.c 2023-02-01 23:34:37 +01:00
Sam Lantinga 177a6f38e0 Only minimize the window for an assert if it's in exclusive fullscreen mode 2023-02-01 12:05:25 -08:00
Sam Lantinga ac75fe9324 Folded SDL_WINDOW_FULLSCREEN_EXCLUSIVE and SDL_WINDOW_FULLSCREEN_DESKTOP into a single SDL_WINDOW_FULLSCREEN flag
The fullscreen video mode used by the window can be used to determine whether it's in exclusive fullscreen or fullscreen desktop mode.
2023-02-01 12:05:25 -08:00
Sam Lantinga 9ff1055489 Workaround for Visual Studio 2019 const warning
Visual Studio 2022, gcc, and clang all agree that "const SDL_DisplayMode **" is a non-const pointer to const data, but Visual Studio 2019 warns about this, so we'll just add a cast to the SDL_free() call for now.

Apparently this was a legitimate bug that has been recently fixed:
https://stackoverflow.com/questions/10403713/why-does-visual-c-warn-on-implicit-cast-from-const-void-to-void-in-c-but
2023-02-01 12:05:25 -08:00
Sam Lantinga 6b137579ea Windows default to fullscreen desktop mode if they don't pick an explicit video mode
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.
2023-02-01 12:05:25 -08:00
Anonymous Maarten 32e7921f98 cmake: by default, link tests to SDL3.dll on Windows 2023-01-31 01:59:21 +01:00
Anonymous Maarten 9cf34908a1 cmake: pass VERSION to project() + don't use SDL_VERSION 2023-01-31 01:59:21 +01:00
Sam Lantinga 22c69bccdf Displays are now referenced by instance ID instead of index 2023-01-29 19:25:15 -08:00
Anonymous Maarten 758c0dd6d8 Rename mouse BUTTON(DOWN|UP) event to BUTTON_(DOWN|UP) 2023-01-29 19:24:48 -08:00
Sasha Szpakowski 90795291e4 Remove SDL_GL/Metal/Vulkan_GetDrawableSize().
SDL_GetWindowSizeInPixels supersedes those functions.
2023-01-29 11:20:33 -08:00
Sam Lantinga bf4095359c Removed duplicated window size events, and added SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED 2023-01-28 15:56:02 -08:00
Sam Lantinga e83c54f271 SDL_WINDOW_FULLSCREEN and SDL_WINDOW_FULLSCREEN_DESKTOP are now distinct flags 2023-01-28 10:56:38 -08:00
Sam Lantinga 24fec13ac1 Add full high DPI information to SDL_DisplayMode
SDL_DisplayMode now includes the pixel size, the screen size and the relationship between the two. For example, a 4K display at 200% scale could have a pixel size of 3840x2160, a screen size of 1920x1080, and a display scale of 2.0.
2023-01-27 12:38:46 -08:00
Sam Lantinga c2d79cb411 Verify that clear ignores the viewport and test a logical size that isn't the same aspect ratio as the window 2023-01-26 16:10:13 -08:00
Sam Lantinga d9b53399fe Added an SDL render logical size test 2023-01-26 14:49:23 -08:00
Sam Lantinga c708ddd66f Added a SDL render viewport test 2023-01-26 13:58:59 -08:00
Sam Lantinga 1c83c1fadd Fixed build warnings in Xcode 2023-01-26 13:58:59 -08:00
Sam Lantinga 364db52ca3 Moved testautomation data out of SDL_test library 2023-01-26 10:25:44 -08:00
Ozkan Sezer 742e356180 test/loopwavequeue.c: minor warning fix (SDL_AudioDeviceID is unsigned) 2023-01-26 18:15:20 +03:00
Sam Lantinga 4696c9556b
SDL 3.0 is going to be high DPI aware and officially separates screen… (#7145)
* SDL 3.0 is going to be high DPI aware and officially separates screen coordinates from client pixel area

The public APIs to disable high DPI support have been removed

Work in progress on https://github.com/libsdl-org/SDL/issues/7134
2023-01-25 01:23:17 -08:00
Sylvain 724d92fd65 Rename SDL_GetDisplayDPI to SDL_GetDisplayPhysicalDPI
to avoid confusion with logical DPI
2023-01-25 00:04:00 -08:00
Sam Lantinga d496d187c5 Document that the pitch value may be zero for surfaces that will be filled in by the application later.
Also verify that the pitch isn't zero for surfaces with valid pixels

Fixes https://github.com/libsdl-org/SDL/issues/7143
2023-01-24 22:51:16 -08:00
Sylvain 052b14eb65 Add SDL_ConvertAudioSamples() helper function 2023-01-24 08:26:09 -08:00
Sam Lantinga 7b50bae524 Renamed SDL events for clarity
Fixes https://github.com/libsdl-org/SDL/issues/6877
2023-01-24 07:26:48 -08:00
Sylvain cb01b35c4e testresample.c: use SDL_DestroyAudioStream() 2023-01-22 22:22:50 +01:00
Sylvain bd793b6d75 Update testresample.c 2023-01-22 11:31:30 -05:00
Sylvain 6ad51558d4 Update testaudiostream_audio.c 2023-01-22 11:31:30 -05:00
Sylvain 80f51eeb1f testautomation: add an option to list all test suites and tests 2023-01-16 11:07:09 +01:00
Eric Wasylishen 08963dc183 testdrawchessboard.c: draw a diagonal line for visually checking highdpi functionality
Also enable dpi awareness
2023-01-15 12:57:42 -08:00
Sam Lantinga 2aa9569b3e Replaced SDL_SIMDAlloc(), SDL_SIMDRealloc(), and SDL_SIMDFree() with SDL_aligned_alloc() and SDL_aligned_free()
Fixes https://github.com/libsdl-org/SDL/issues/5641
2023-01-09 18:01:59 -08:00
Anonymous Maarten 0ab99ffb2a cmake: add SDL_TESTS_TIMEOUT_MULTIPLIER to account for slower machines 2023-01-10 02:39:09 +01:00
Sam Lantinga e9b86eebf3 Functions which return function pointers now return SDL_FunctionPointer instead of void*
This fixes the clang warning "Cast between pointer-to-function and pointer-to-object is an extension"

You can define SDL_FUNCTION_POINTER_IS_VOID_POINTER in your project to restore the previous behavior.

Fixes https://github.com/libsdl-org/SDL/issues/2866
2023-01-09 15:46:21 -08:00
Sam Lantinga fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08:00
Sam Lantinga 504bce5187 Set SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS for the virtual joystick test 2023-01-09 09:16:10 -08:00
Sylvain a486eeccf4 Remove one test that contains call of SDL_Quit() / SDL_Init() because it
conficts with the initializaion of test common.
(before it used SDL_VideoInit SDL_VideoQuit which weren't perturbated by SDL_Quit())
2023-01-08 12:39:23 -08:00
Anonymous Maarten f53d797cca cmake: generate git hash using GetRevisionDescription CMake module
This allows the build system (ninja/make/VS) to detect whether the current
checkout git commit has changed. If so, SDL_revision.h will be updated.
2023-01-08 18:20:56 +01:00
Hunter Kvalevog 0953367967 SDL_Vulkan_GetInstanceExtensions: Remove window
Remove the unused `window` parameter from
SDL_Vulkan_GetInstanceExtensions, which is never used by any of the
backends.
2023-01-08 07:55:34 -08:00
Anonymous Maarten c8286fc9a2 testevdev: cannot test evdev capabilities without linux input
Configure with "-DSDL_LIBC=OFF" to get this configuration.
2023-01-08 07:29:40 -08:00
Anonymous Maarten 1d60030e84 cmake: add -Wformat when checking -Wformat-extra-args
The need for -Wformat when using -Wformat-extra-args was observed for
the msys2 mingw64 gcc toolchain.
2023-01-08 15:57:51 +01:00
Anonymous Maarten 373a6464c8 cmake: collect cflags in sdl-build-options and sdl-global-options 2023-01-08 15:57:51 +01:00
Sylvain 51ae7cc35c
Fix testautomation_mouse:
FLT_MIN is positive and very small. we want -FLT_MAX here.
2023-01-08 13:28:10 +01:00
Sylvain cbe01319e0 Fix testautomation_pixels using really invalid pixel format 2023-01-07 10:11:02 -08:00
Sylvain 76e1c7c509 Fix testautomation_pixels:
we can create all pixel format, including SDL_PIXELFORMAT_UNKNOWN (as before).
2023-01-07 09:46:41 -08:00
Sylvain 93e2903ac5 Add SDL_PlayAudioDevice() to play audio. Remove pause_on param from SDL_PauseAudioDevice() 2023-01-06 09:15:39 -08:00
Sylvain 2d7f8d7d51 Remove legacy SDL_Audio functions that acts on device id == 1 2023-01-05 09:40:06 -05:00
Sam Lantinga 0bbf6cc379 Test text rendering APIs take floating point coordinates 2023-01-04 16:45:02 -08:00
Sam Lantinga 5fab64f862 Fixed documentation errors in testautomation_render.c 2023-01-03 16:44:00 -08:00
Sam Lantinga 6cfe4f2ba8 Fixed documentation errors in testautomation_math.c 2023-01-03 16:44:00 -08:00
Sam Lantinga 71f3bf90ed Improved handling of binding buttons and axes 2023-01-03 12:47:40 -08:00
Sam Lantinga 1d956c2817 Rename SDL2 tests for SDL3 2023-01-03 11:54:35 -08:00
Sam Lantinga 9c1a9ecb4b Removed non-float versions of SDL render API drawing functions
This simplifies the API and removes a level of API translation between the int variants of the functions and the float implementation

Fixes https://github.com/libsdl-org/SDL/issues/6656
2023-01-03 08:16:58 -08:00
Sam Lantinga 38b138cd0a Fixed rounding of floating point values in snprintf 2023-01-03 06:35:25 -08:00
Sam Lantinga b06e310c08 Fixed spinning rendering too fast 2023-01-03 06:35:25 -08:00
Sam Lantinga e3c1749f5b The refresh rate in SDL_DisplayMode is now a float 2023-01-03 06:35:25 -08:00
Sylvain Becker 8a13533949
Handle error return value for SDL_GetSwapInterval 2023-01-01 08:20:41 -08:00
Sam Lantinga 324c0b76a0 Removed SDL_HasGamepads(), SDL_HasJoysticks(), and SDL_HasSensors()
Also cleaned up logic for whether we need to poll for events:
- We need to periodically poll for joysticks to handle hotplug.
- We need to frequently poll for joysticks and sensors when they're open so their state can be updated
2022-12-29 23:20:26 -08:00
Sam Lantinga 7f23d71b6a Added SDL_modf() and SDL_modff()
This function is useful for accumulating relative mouse motion if you want to only handle whole pixel movement.
e.g.
static float dx_frac, dy_frac;
float dx, dy;

/* Accumulate new motion with previous sub-pixel motion */
dx = event.motion.xrel + dx_frac;
dy = event.motion.yrel + dy_frac;

/* Split the integral and fractional motion, dx and dy will contain whole pixel deltas */
dx_frac = SDL_modff(dx, &dx);
dy_frac = SDL_modff(dy, &dy);
if (dx != 0.0f || dy != 0.0f) {
    ...
}
2022-12-29 23:12:19 -08:00
Sam Lantinga ead4f122e4 Added basic support for %g snprintf format specifier 2022-12-29 23:12:19 -08:00
Sam Lantinga cefbeb582f Mouse coordinates are floating point
You can get sub-pixel mouse coordinates and motion depending on the platform and display scaling.

Fixes https://github.com/libsdl-org/SDL/issues/2999
2022-12-29 23:12:19 -08:00
Sam Lantinga 98678b5d8d SDL API renaming: SDL_Alloc*/SDL_Free* -> SDL_Create*/SDL_Destroy*
Fixes https://github.com/libsdl-org/SDL/issues/6945
2022-12-29 15:07:15 -08:00
Sam Lantinga 1b90107fdb Spell out "Float" in function names 2022-12-29 14:50:31 -08:00
Sylvain Becker d7d3c22dbf
Remove more reserved identifiers (#6925) 2022-12-29 13:58:16 -08:00
Sam Lantinga ea0c2f55be SDL API renaming: *Is* functions
Feedback from @icculus:
"IsTablet" uses "is" as a form of "to be" ...like, the actual question is of its nature.

The rest is just a superfluous word in the question and it flows as better English with if (RectEmpty) than if (IsRectEmpty)

Fixes https://github.com/libsdl-org/SDL/issues/6932
2022-12-28 19:40:25 -08:00
Sam Lantinga 66351fd4ba Replace tri-state functions SDL_EventState(), SDL_GetJoystickEventState(), SDL_GetGamepadEventState(), SDL_ShowCursor()
`SDL_QUERY`, `SDL_IGNORE`, `SDL_ENABLE`, and `SDL_DISABLE` have been removed.

SDL_EventState() has been replaced with SDL_SetEventEnabled()
SDL_GetEventState() has been replaced with SDL_EventEnabled()
SDL_GameControllerEventState has been replaced with SDL_SetGamepadEventsEnabled() and SDL_GamepadEventsEnabled()
SDL_JoystickEventState has been replaced with SDL_SetJoystickEventsEnabled() and SDL_JoystickEventsEnabled()

SDL_ShowCursor() has been split into three functions: SDL_ShowCursor(), SDL_HideCursor(), and SDL_CursorVisible()

Fixes https://github.com/libsdl-org/SDL/issues/6929
2022-12-28 17:49:34 -08:00
Sam Lantinga 16092f58bb Updated gamepad, joystick, sensor APIs, removing device indices
Instead of indexing into an internal list of devices which requires locking, we return a list of device IDs which can then be queried individually.

Reference: https://github.com/libsdl-org/SDL/issues/6889
2022-12-28 13:10:27 -08:00
Sylvain aa46ff8f4b Remove SDL_WINDOW_SHOW flag, as redundant with SDL_WINDOW_HIDDEN 2022-12-28 12:16:57 -08:00
Sam Lantinga ab2d007982 More gamepad renaming 2022-12-27 11:31:54 -08:00