Commit graph

263 commits

Author SHA1 Message Date
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
Sam Lantinga 9d8f98c735 Don't change presentation modes when resizing the logical target
Fixes https://github.com/libsdl-org/SDL/issues/7251
2023-02-06 08:51:58 -08:00
Sylvain fbe0352764 SDL_DestroyRenderer: drop all commands first
and don't queue new command from SDL_DestroyTexture() (memory leak)
2023-02-05 13:35:08 -08:00
Sam Lantinga ec1b42557f Fixed memory leak at shutdown (thanks @1bsyl!)
Clean up the textures first, as destroying the current render target will queue viewport and clip rectangle commands
2023-02-05 09:10:21 -08:00
Sam Lantinga 2a83093b36 Use a reasonable upper bound on the number of pixels we'll try to draw when traversing a line
Fixes https://github.com/libsdl-org/SDL/issues/6116
2023-02-03 20:53:30 -08:00
Sam Lantinga 14a4ce8b59 Fixed SDL_ScaleMode values for consistency 2023-02-03 14:20:51 -08:00
Sam Lantinga e5edce8e75
Fixed permissions on src/render/SDL_render.c (#7232) 2023-02-03 13:14:48 -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
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
Anonymous Maarten 758c0dd6d8 Rename mouse BUTTON(DOWN|UP) event to BUTTON_(DOWN|UP) 2023-01-29 19:24:48 -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 7b50bae524 Renamed SDL events for clarity
Fixes https://github.com/libsdl-org/SDL/issues/6877
2023-01-24 07:26:48 -08:00
Francisco Javier Trujillo Mata 555183257d Remove dummy flag 2023-01-11 15:10:51 -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
Sylvain bf76fc6b05 Fixed bug #6816 - SDL_RenderSetVSync doesn't disable vsync for software renderer 2023-01-03 06:38:11 -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 851b0e16be
Add SDL_GetRenderVSync (see #6495) (#6965) 2023-01-02 11:21:02 -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 1b90107fdb Spell out "Float" in function names 2022-12-29 14:50:31 -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 36d4395c97 SDL API renaming: internal functions 2022-12-27 15:05:51 -08:00
Sam Lantinga 58aecf0a54 SDL API renaming: SDL_rect.h
Fixes https://github.com/libsdl-org/SDL/issues/6887
2022-12-27 11:01:11 -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
Sam Lantinga 083e436a1a SDL API renaming: SDL_pixels.h
Fixes https://github.com/libsdl-org/SDL/issues/6886
2022-12-27 06:08:31 -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
Sam Lantinga 00f05dcf49 render: only enable clipping when the rectangle is valid
Fixes https://github.com/libsdl-org/SDL/issues/6896
2022-12-26 10:24:25 -08:00
Sam Lantinga 909b513c33 Made SDL_WINDOWEVENT_* and SDL_DISPLAYEVENT_* first class event types
Fixes https://github.com/libsdl-org/SDL/issues/6772
2022-12-22 07:38:13 -08:00
Ryan C. Gordon 5a2d0b69c8
render: Remove SDL_GetRenderDriverInfo and change SDL_CreateRenderer.
Fixes #6625.
2022-12-13 23:27:35 -05:00
Sylvain af5bda5ef3 Fix warnings 'macro argument should be enclosed in parentheses' 2022-12-05 09:06:44 -08:00
Sam Lantinga f32cdfa096 Fixed presentation reset calculation (thanks @zturtleman!) 2022-12-04 09:28:03 -08:00
Sylvain 021d0b7300
Fix wrong clang-tidy modification. This is an integer division. Thanks @meyraud705 (see PR #6725) 2022-12-03 13:36:09 +01:00
Sam Lantinga 8121bbd083 Convert ticks to 64-bit, added nanosecond precision to the API
Fixes https://github.com/libsdl-org/SDL/issues/5512
Fixes https://github.com/libsdl-org/SDL/issues/6731
2022-12-02 12:37:41 -08:00
Pierre Wendling 3c501b963d
Clang-Tidy fixes (#6725) 2022-12-01 13:07:03 -08:00
Sylvain Becker 932f61348d
Remove mask versions of SDL_CreateRGBSurface* #6701 (#6711)
* Rename SDL_CreateRGBSurface{,From} to SDL_CreateSurface{,From}, which now takes a format parameter
2022-12-01 08:04:02 -08:00
Sam Lantinga 1e2dfdb019 Removed the OpenGL ES 1.0 2D render implementation
In SDL3 we plan to make more use of shaders in the 2D render API, and this minimizes the number of platforms we have to consider for new features. OpenGL ES 2.0 or newer is supported on all modern iOS and Android devices.
2022-11-30 13:39:37 -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
Sam Lantinga c5790359fd
Added precompiled header support for Visual Studio and Xcode (#6710)
Fixes https://github.com/libsdl-org/SDL/issues/6704
2022-11-29 18:34:15 -08:00
Sylvain Becker fc4fc5295f
Remove depth field from SDL_CreateRGBSurfaceWithFormat and SDL_Create… (#6685)
* Remove depth field from SDL_CreateRGBSurfaceWithFormat and SDL_CreateRGBSurfaceWithFormatFrom
* Removed unused 'flags' parameter from SDL_CreateRGBSurface and SDL_CreateRGBSurfaceWithFormat
* Removed unused 'flags' parameter from SDL_ConvertSurface and SDL_ConvertSurfaceFormat
2022-11-29 09:40:09 -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 cc1f9eb983 Use Apple's nomenclature for macOS and iOS
Fixes https://github.com/libsdl-org/SDL/issues/6621
2022-11-25 16:00:06 -08:00
Ozkan Sezer 0b8309da0c renamed SDL PI constants to SDL_PI_D and SDL_PI_F. 2022-11-25 22:35:24 +03:00
Sam Lantinga 670f1df469 Removed SDL_stdinc.h dependency on HAVE_M_PI, added SDL_M_PIl (double) and SDL_M_PIf (float) instead 2022-11-25 10:33:37 -08:00
Ozkan Sezer 34231f5ba0 reverted opengles removal. 2022-11-23 18:50:02 +03:00
Ozkan Sezer 30b1ab2add removed opengles. 2022-11-22 21:48:40 +03:00
Ozkan Sezer 3aea865cdf removed directfb support. 2022-11-22 20:45:45 +03:00