Commit graph

354 commits

Author SHA1 Message Date
Sylvain eea4711110 gendynapi.py: add option to check doc formating (eg \param \returns \since) 2023-02-12 20:43:30 +01:00
Sylvain a2f3711c80 SDL_AndroidGetExternalStorageState(): return 0 on success, and fills *state with flags 2023-02-10 09:30:31 +01:00
Sam Lantinga 5b77ad54c4 Fixed order and constness of parameters to SDL_ConvertAudioSamples() 2023-02-09 17:49:35 -08:00
Sam Lantinga e65e2c8ed7 SDL_CloseJoystick() should return void, not int 2023-02-09 17:26:16 -08:00
Ozkan Sezer ae91dcbcf4 fix dynapi after commit dc74a67a 2023-02-09 22:50:00 +03:00
Sylvain dc74a67a57 SDL_UnlockTexture: change from 'int' to 'void' 2023-02-09 20:17:27 +01:00
Sylvain cee245b6a9 SDL_*SceenSaver(): change return value to int. // add SDL_Unsupported() errors 2023-02-09 08:16:46 -08:00
Sylvain e2e5e670bf Remove returns int from Destroy/Close/Unlock functions 2023-02-09 07:57:14 -08:00
Linus Probert 3bd737d44c Add error returns to void functions that can fail/set errors.
This takes care of the last set of void functions that could
potentially be shifted to instead return an int indicating success and
setting an error in case of an error.
2023-02-09 07:23:21 -08:00
Sylvain b305d9e3c0 Change return type from void to int for audio function. Eventually set invalid parameter error. 2023-02-08 17:43:44 -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
Sylvain c5c94a6be6 Change return type from void to int, for functions that set an error
(SDL_SetError(), SDL_OutOfMemory(), SDL_Unsupported(), SDL_InvalidParam())

Update prototype to forward errors to generic layer, for the functions:
MoveCursor, WarpMouse, GL_DeleteContext, GetDisplayModes.

Check invalid parameter in SDL_SetTextInputRect() generic layer.
2023-02-07 13:51:45 -08:00
Linus Probert 375bde8a4f
[SDL3] Cleanup void functions (#7253)
Some functions that do call SDL_SetError but return void changed to instead return non-zero in case of errors.
2023-02-06 08:53:52 -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
Ozkan Sezer 9f21bed729 dynapi: cast GetProcAddress() result to void* 2023-02-03 17:40:40 +03: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
Sam Lantinga 22c69bccdf Displays are now referenced by instance ID instead of index 2023-01-29 19:25:15 -08:00
Sasha Szpakowski 90795291e4 Remove SDL_GL/Metal/Vulkan_GetDrawableSize().
SDL_GetWindowSizeInPixels supersedes those functions.
2023-01-29 11:20:33 -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 14eb8db152 Fixed build 2023-01-24 14:01:01 -08:00
Sam Lantinga a06a593aa6 Renamed SDL_GetGamepadNumTouchpads and SDL_GetGamepadNumTouchpadFingers to match the new convention 2023-01-24 13:47:30 -08:00
Sylvain 052b14eb65 Add SDL_ConvertAudioSamples() helper function 2023-01-24 08:26:09 -08:00
Sylvain 64bc0a1612 Remove AudioCVT interface in favor of SDL_AudioStream 2023-01-22 11:31:30 -05:00
Ozkan Sezer 2ec9a20204 SDL_dynapi.c: add extern "C" guards, just in case.. 2023-01-12 14:01:32 +03:00
Sam Lantinga 21a1508ceb Re-add JNI_OnLoad to the symbols list so Android symbols are resolved properly 2023-01-10 21:15:21 -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
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 5feebcdce0 SDL_AddHintCallback() now returns a standard int result instead of void
Fixes https://github.com/libsdl-org/SDL/issues/7035
2023-01-09 12:09:30 -08:00
Sam Lantinga fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08: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
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 c823f26f18 Revert "Removed public joystick locking API"
This reverts commit a515f51ac0.

We still need joystick locking to protect the gamepad mappings
2023-01-04 13:51:40 -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
Sylvain Becker 851b0e16be
Add SDL_GetRenderVSync (see #6495) (#6965) 2023-01-02 11:21:02 -08:00
Sylvain Becker 8a13533949
Handle error return value for SDL_GetSwapInterval 2023-01-01 08:20:41 -08:00
Sam Lantinga a515f51ac0 Removed public joystick locking API
All joystick functions are thread-safe and you can now get an atomic list of joysticks with SDL_GetJoysticks()

Fixes https://github.com/libsdl-org/SDL/issues/6956
2022-12-31 09:24:14 -08:00
Ozkan Sezer 929da2c28e SDL_dynapi.c: LoadLibraryA() returns HMODULE. 2022-12-30 11:11:10 +03: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 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 88630b85f5 SDL_GL_SwapWindow() returns an error code 2022-12-29 08:40:51 -08:00
Sam Lantinga abd051f89e Re-sorted SDL 3.0 API list 2022-12-28 19:55:19 -08:00
Sam Lantinga 80890f3aae SDL API renaming: SDL_render.h
Fixes https://github.com/libsdl-org/SDL/issues/6883
2022-12-28 19:40:25 -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 61232de1ab Sort the initial SDL 3.0 symbols 2022-12-28 14:29:03 -08:00
Sam Lantinga e4e7a8baff Reset the dynamic API for SDL 3.0 2022-12-28 13:53:06 -08:00