Commit Graph

42 Commits (6e1b11368d72aef6c412764a8b3d50bb22e936de)

Author SHA1 Message Date
Sam Lantinga 5b3ee51c6c Updated copyright for 2024 2024-01-01 13:15:26 -08:00
Anonymous Maarten 7484d02a2e testshape: use SDL_test to create multiple windows 2023-12-07 20:38:00 +01:00
Ryan C. Gordon 447b508a77
error: SDL's allocators now call SDL_OutOfMemory on error.
This means the allocator's caller doesn't need to use SDL_OutOfMemory directly
if the allocation fails.

This applies to the usual allocators: SDL_malloc, SDL_calloc, SDL_realloc
(all of these regardless of if the app supplied a custom allocator or we're
using system malloc() or an internal copy of dlmalloc under the hood),
SDL_aligned_alloc, SDL_small_alloc, SDL_strdup, SDL_asprintf, SDL_wcsdup...
probably others. If it returns something you can pass to SDL_free, it should
work.

The caller might still need to use SDL_OutOfMemory if something that wasn't
SDL allocated the memory: operator new in C++ code, Objective-C's alloc
message, win32 GlobalAlloc, etc.

Fixes #8642.
2023-11-30 00:14:27 -05:00
Sam Lantinga 81fc7ded78 Removed the window shape API for SDL 3.0
Fixes https://github.com/libsdl-org/SDL/issues/6654
Fixes https://github.com/libsdl-org/SDL/issues/6897
2023-11-22 14:11:10 -08:00
Sylvain d8600f717e Pointer as bool (libsdl-org#7214) 2023-11-09 14:18:36 -08:00
Simon McVittie 04edb38cdf shape: Use SDL[Test]_ReadSurfacePixel
This avoids assuming that the pixels are suitably aligned for direct
access, which there's no guarantee that they are; in particular,
3-bytes-per-pixel RGB images are likely to have 3 out of 4 pixels
misaligned. On x86, dereferencing a misaligned pointer does what you
would expect, but on other architectures it's undefined whether it will
work, crash with SIGBUS, or silently give a wrong answer.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-10-10 03:23:20 -07:00
Anonymous Maarten 2a01f9dcb5 tests: plug leaks when running with --trackmem
(using SDL_VIDEO_DRIVER=x11/wayland on Linux)
2023-09-19 17:58:25 +02:00
Anonymous Maarten b4291412a4 tests: build tests with C90 standard
C90 mode is disabled for:
- testautomation: use of isnan/isfinite
- testlock: use of kill
- testvulkan: use of c++ style strings in vulkan.h
2023-05-27 01:49:07 +02:00
Sam Lantinga c699f3d1d8 Updated SDL high DPI support
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
2023-05-17 12:58:00 -07:00
Anonymous Maarten 4a6528e3f0 testprograms: parse arguments using SDLTest_CommonState 2023-03-17 17:54:16 +01:00
Sylvain f1d9c36136 testshape: now uses SDL_WINDOW_TRANSPARENT instead of the shaped window API 2023-03-13 21:23:04 +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
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 7b50bae524 Renamed SDL events for clarity
Fixes https://github.com/libsdl-org/SDL/issues/6877
2023-01-24 07:26:48 -08:00
Sam Lantinga fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -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 cc0296c934 SDL API renaming: SDL_surface.h
Fixes https://github.com/libsdl-org/SDL/issues/6884
2022-12-27 06:36:39 -08:00
Sam Lantinga 0d54115235 SDL API renaming: SDL_render.h
Fixes https://github.com/libsdl-org/SDL/issues/6883
2022-12-27 06:21:13 -08:00
Sylvain Becker aa0053141b
Remove SDL_VideoInit / Quit. Prefer SDL_SubSytemInit / Quit (#6913) 2022-12-27 05:42:48 -08:00
Sam Lantinga 63724c113b Removed the vi format comments from the source
Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim) to automatically set tab spacing for the SDL coding style.

Fixes https://github.com/libsdl-org/SDL/issues/6903
2022-12-26 11:17:23 -08:00
Daniel Gibson 22e22ba196 Add SDL_main.h includes to tests
.. including cmake/test/*.c, whatever that does

(this is needed now because SDL.h doesn't include SDL_main.h anymore)
2022-12-15 08:01:01 -08:00
Ryan C. Gordon 5a2d0b69c8
render: Remove SDL_GetRenderDriverInfo and change SDL_CreateRenderer.
Fixes #6625.
2022-12-13 23:27:35 -05:00
Pierre Wendling 3c501b963d
Clang-Tidy fixes (#6725) 2022-12-01 13:07:03 -08:00
Sam Lantinga 5750bcb174
Update for SDL3 coding style (#6717)
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
2022-11-30 12:51:59 -08:00
Sylvain Becker 6a2200823c
Cleanup add brace (#6545)
* Add braces after if conditions

* More add braces after if conditions

* Add braces after while() conditions

* Fix compilation because of macro being modified

* Add braces to for loop

* Add braces after if/goto

* Move comments up

* Remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements after merge

* Fix inconsistent patterns are xxx == NULL vs !xxx

* More "{}" for "if() break;"  and "if() continue;"

* More "{}" after if() short statement

* More "{}" after "if () return;" statement

* More fix inconsistent patterns are xxx == NULL vs !xxx

* Revert some modificaion on SDL_RLEaccel.c

* SDL_RLEaccel: no short statement

* Cleanup 'if' where the bracket is in a new line

* Cleanup 'while' where the bracket is in a new line

* Cleanup 'for' where the bracket is in a new line

* Cleanup 'else' where the bracket is in a new line
2022-11-27 08:38:43 -08:00
Sam Lantinga 0a48abc860 Switch header convention from `#include "SDL.h"` to `#include <SDL3/SDLh>`
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
2022-11-26 22:15:18 -08:00
Sam Lantinga 63f307fe1f Remove SDL_config.h from the public headers
The SDL headers are no longer dependent on the build configuration.

Fixes https://github.com/libsdl-org/SDL/issues/6643 and https://github.com/libsdl-org/SDL/issues/6641
2022-11-26 04:48:36 -08:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sam Lantinga a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga 5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Sam Lantinga e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Philipp Wiesemann 705efc3532 Fixed handling only one event per frame in testshape program. 2017-06-24 23:45:19 +02:00
Philipp Wiesemann cb591ee611 Fixed ignoring first event in testshape program.
Found by Cppcheck.
2017-06-08 22:40:35 +02:00
Philipp Wiesemann 850185f401 Fixed crash if creating textures failed in testshape program. 2017-06-02 22:15:23 +02:00
Sam Lantinga 45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Philipp Wiesemann 73b63e5b57 Fixed crash in shape test program if memory allocation failed. 2016-05-10 21:13:58 +02:00
Sam Lantinga 42065e785d Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Philipp Wiesemann 11d98995da Replaced tabs with spaces in test programs. 2015-11-25 21:39:28 +01:00
Philipp Wiesemann 0e45984fa0 Fixed crash if initialization of EGL failed but was tried again later.
The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly
uninitialized data structure if loading the library first failed. A later try to
use EGL then skipped initialization and assumed it was previously successful
because the data structure now already existed. This led to at least one crash
in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was
dereferenced to make a call to eglBindAPI().
2015-06-21 17:33:46 +02:00