Commit Graph

890 Commits (38219e08d95ecc298fe476e90e802cd288dc72f6)

Author SHA1 Message Date
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 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 Becker 4ffa7f868d
Fixed bug libsdl-org#6745 - Check for overflow in SDL_CalculateYUVSize (#6747)
Fixed bug #6745 - Check for overflow in SDL_CalculateYUVSize
2022-12-03 21:22:14 +01: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
Sylvain Becker 92cd2c0a74
Enable creation of yuv SDL_Surfaces (#6735) 2022-12-02 12:53:48 -08:00
Sam Lantinga 0a3262e819 Pass the OS event timestamp for keyboard, mouse, and touch events where possible
Currently implemented for Windows and Apple platforms
2022-12-02 12:37:41 -08: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 b6b29fd071 Updated Metal shaders 2022-11-25 16:07:09 -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
Sam Lantinga b0840eb32e Updated SDL_syswm.h for SDL 3.0
* The header is no longer dependent on SDL build configuration
* The structures are versioned separately from the rest of SDL
* SDL_GetWindowWMInfo() now returns a standard result code and is passed the version expected by the application
* Updated WhatsNew.txt and docs/README-migration.md with the first API changes in SDL 3.0
2022-11-23 14:05:59 -08:00
Cameron Cawley 4ee4e49e49 Select the best pixel formats for use in the software renderer 2022-11-23 11:08:40 -08:00
Sam Lantinga a635a485bc Re-added WinRT support until we're sure that it's no longer being used 2022-11-23 10:41:43 -08:00
Ozkan Sezer 34231f5ba0 reverted opengles removal. 2022-11-23 18:50:02 +03:00
Ozkan Sezer dc2a3e06e9 removed WinRT support. 2022-11-22 23:36:24 +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
Ozkan Sezer e89a1f9157 removed NaCL support. 2022-11-22 20:10:47 +03:00
Ozkan Sezer 63243eb3a5 removed pandora support 2022-11-22 18:50:00 +03:00
Sylvain ddad901c0d
Remove unneeded semicolon 2022-11-17 10:43:45 +01:00
Sylvain ce5da5d579
Don't compare pointer against '0', but NULL 2022-11-16 21:47:43 +01:00
Sylvain 1d7966df15
Remove un-needed check for NULL pointer. They were previously checked just before. 2022-11-16 21:27:16 +01:00
ulatekh ec58a817ef Fixes made in response to running a static code analyzer under MS Windows.
Most of these are probably harmless, but the changes to SDL_immdevice.c and SDL_pixels.c appear to have fixed genuine bugs.

SDL_audiocvt.c: By separating the calculation of the divisor, I got rid of the suspicion that dividing a double by an integer led to loss of precision.
SDL_immdevice.c: Added a missing test, one that could have otherwise led to dereferencing a null pointer.
SDL_events.c, SDL_gamecontroller.c, SDL_joystick.c, SDL_malloc.c, SDL_video.c: Made it clear the return values weren't used.
SDL_hidapi_shield.c: The size is zero, so nothing bad would have happened, but the SDL_memset() was still being given an address outside of the array's range.
SDL_dinputjoystick.c: Initialize local data, just in case IDirectInputDevice8_GetProperty() isn't guaranteed to write to it.
SDL_render_sw.c: drawstate.viewport could be null (as seen on line 691).
SDL.c: SDL_MostSignificantBitIndex32() could return -1, though I don't know if you want to cope with that (what I did) or SDL_assert() that it can't happen.
SDL_hints.c: Replaced boolean tests on pointer values with comparisons to NULL.
SDL_pixels.c: Looks like the switch is genuinely missing a break!
SDL_rect_impl.h: The MacOS static checker pointed out issues with the X comparisons that were handled by assertions; I added assertions for the Y comparisons.
SDL_yuv.c, SDL_windowskeyboard.c, SDL_windowswindow.c: Checked error-result returns.
2022-11-16 12:43:20 -05:00
Sam Lantinga 70656b133c Don't recreate the window when creating a Metal renderer on an OpenGL window.
It turns out that we can safely create a Metal view on an existing window, and that avoids issues with the window being recreated with the wrong orientation in iOS 16.

Fixes https://github.com/libsdl-org/SDL/issues/6289
2022-11-15 10:21:07 -08:00
Hubert Maier 5dc93451d2
JANITORIAL : Correct some more spelling mistakes (#6489) 2022-11-06 11:49:37 -08:00
Hubert Maier 8b9c82e140 SDL_RENDER_PSP.C: Correct spelling mistakes
wether -> whether
2022-10-30 11:24:42 -04:00
Francisco Javier Trujillo Mata a8f019b1f0 Using ST and removing warnings 2022-10-28 11:42:44 -07:00
Francisco Javier Trujillo Mata f2ebedae92 adding texture function 2022-10-28 11:42:44 -07:00
Francisco Javier Trujillo Mata 5de01eb0aa Make render to use new functions 2022-10-28 11:42:44 -07:00
Sam Lantinga dd72f3f03d Added comment for #endif 2022-10-24 10:37:43 -07:00
Steven Noonan 3d35c08585 fix a few 'unused but set variable' and 'unused function' warnings 2022-10-24 10:36:56 -07:00
Sam Lantinga aefc6b5bb5 Renamed variables, index is the singular of indices 2022-10-18 08:40:03 -07:00
Sylvain dfbb93dd0c
SDL_Renderer / GLES2: add specific list of indice to render rect (see #6401) 2022-10-18 11:31:30 +02:00
Sylvain e8a4c23ce5
Revert commit 790fa3156c.
SDL_BLENDMODE_INVALID case is probably used for custom blendmode
2022-10-18 10:45:01 +02:00
Sylvain 790fa3156c
Fix warning: enumeration value 'SDL_BLENDMODE_INVALID' not explicitly handled in switch 2022-10-18 10:41:10 +02:00
Sylvain 3d99d31026
Fixed bug #6401 - back-end can choose the order the triangles when rendering rects, attempt to fix small glitch rendering. 2022-10-18 10:34:56 +02:00
Sylvain 285cbf6fdd
Revert commit 485bb3565b.
"Fixed bug #6401 - change the order of triangles when using RenderCopy, RenderCopyEx and RenderFillRect"
because the glitch reappears on other backend
2022-10-18 10:04:06 +02:00
Wouter Wijsman 3903f4c88a PSP: Use vramalloc instead of conflicting valloc function
The libpspvram library was offering a function with conflicted with valloc. This has been renamed now, so SDL2 had to be updated for it.
2022-10-17 21:59:38 +02:00
Sylvain 485bb3565b
Fixed bug #6401 - change the order of triangles when using RenderCopy, RenderCopyEx and RenderFillRect 2022-10-17 13:30:30 +02:00
Pierre Wendling 5b9608e08c Remove D3D9 workarounds for Watcom.
The linked PRs have been merged since May.
2022-10-12 17:55:37 +03:00
Sam Lantinga df1bd07dee d3d12: actually execute the pending commands before processing resize
This makes sure all the resources are in the expected state

Fix the D3D12 case in https://github.com/libsdl-org/SDL/issues/6376
2022-10-11 07:25:27 -07:00
zhailiangliang 41c718edca Fix memory leak in PSP_CreateTexture 2022-10-10 22:36:55 -07:00
Pierre Wendling 8117bfe5d1 PS2: Ignore warnings from toolchain headers.
The `gsInline.h` header creates `Wdeclaration-after-statement` warnings.
2022-10-10 22:31:16 -07:00
Sam Lantinga f99fc3268e d3d12: fixed window resize handling
Fixes https://github.com/libsdl-org/SDL/issues/6355
2022-10-09 11:42:39 -07:00
Sam Lantinga 490c20f93f d3d12: reset the vertex buffer size when it is released 2022-10-09 09:57:55 -07:00
Anonymous Maarten 01498d3acf SDL_render_psp.c: fix -Wshadow
Emitted by PSP's gcc
2022-10-08 23:41:07 +02:00
Anonymous Maarten 85fd40fafd Fix -Wunused-const-variable warning when using clang-cl 2022-10-08 23:41:07 +02:00
Ryan C. Gordon 321ca1091d
opengles2: Texture names are GLuint, not GLenum. 2022-10-03 12:00:38 -04:00
Ryan C. Gordon 01c5554f0e
opengles2: SDL_GL_BindTexture() should bind all YUV textures.
This matches what the non-GLES OpenGL renderer does.

Fixes #6070.
2022-10-03 11:57:10 -04:00
zll 69bbe4ce7d Fix memory leak in VITA_GXM_CreateRenderer 2022-09-29 14:32:56 +03:00
zhailiangliang 00b67f5572 Fix potential memory leak in GLES_CreateTexture 2022-09-20 20:14:01 -07:00
Sam Lantinga 82b40f097b Fixed runaway CPU usage in the metal renderer when the window is minimized 2022-09-16 09:55:20 -07:00
Sam Lantinga e2753e19e8 Calculate simulated vsync interval based on display refresh rate 2022-09-16 07:44:40 -07:00
Sam Lantinga 208964f038 Reset the simulated vsync presentation timeline if it's been too long since the last present 2022-09-16 07:44:40 -07:00
Sam Lantinga 1663cb4196 Reset simulated presentation timeline when vsync status changes 2022-09-16 07:44:40 -07:00
Sam Lantinga d744aafb05 Added support for simulated vsync in the renderer
This kicks in if the platform doesn't support vsync directly, or if the present fails for some reason (e.g. minimized on some platforms)

Fixes https://github.com/libsdl-org/SDL/issues/5134
2022-09-16 07:44:40 -07:00
Ozkan Sezer c23fb235c8 SDL_render_d3d12.c: Fix uninitialized warning for CreateEventExFunc 2022-09-16 17:20:56 +03:00
Sam Lantinga 5bc85d6788 Only advertise the SDL_PIXELFORMAT_EXTERNAL_OES format if we can build the shader for it 2022-09-16 06:15:45 -07:00
Sam Lantinga 2970710b5d Pretty print shaders for debugging purposes 2022-09-15 07:41:29 -07:00
Sam Lantinga bc57d3e35c Fixed OpenGL ES shader compilation on Linux 2022-09-15 06:57:41 -07:00
Sam Lantinga 8a15a738f3 Fixed uninitialized variable warning 2022-09-15 06:21:19 -07:00
Sam Lantinga b5102a551b Fixed OpenGLES shaders failing after renderer has been created
Cache all the shaders up front, so we can verify that they won't silently fail at runtime.

If compiling the fragment shaders with the precision hint fails, try again without specifying precision.

Fixes https://github.com/libsdl-org/SDL/issues/6166
Fixes https://github.com/libsdl-org/SDL/issues/6174
2022-09-14 08:03:46 -07:00
Amir 7f415ce587 android: fix some compiler warnings 2022-09-12 10:06:08 -07:00
Sylvain 90a480a100
Fixed bug #6199 - Broken clip behaviour on a render target (metal) 2022-09-08 05:44:39 +02:00
Sam Lantinga 29f4a5ba0e Add GLES2 shader prologue infrastructure. (by @eloj)
There is supposedly an OpenGL ES2 target that does not support precision specifiers. However, the existing logic to detect this is currently broken in two ways:

1) There's a typo of the `#ifdef` as `#if`.
2) Checking for `GL_FRAGMENT_PRECISION_HIGH` can not be the correct way to detect this platform. Other targets, including some desktops, will also not have this defined (for various reasons).

Because some of the shader code is missing precision specifiers, and because a default is ONLY provided if `GL_FRAGMENT_PRECISION_HIGH` is set, these other targets break.

Instead of 'hard-coding' the prologue string into shaders in the C source, use our ability to provide a list of strings to `glShaderSource` instead, leaving the determination to run-time.

This commit closes https://github.com/libsdl-org/SDL/pull/6182
2022-09-06 15:55:27 -07:00
Sam Lantinga 4fd6bba257 Refactored for similarity to surrounding code 2022-09-06 12:29:42 -07:00
Cameron Cawley 10e1ef00e2 Fix compatibility with Windows XP 2022-09-06 08:55:35 -04:00
Francisco Javier Trujillo Mata f1e4685806 Adding specific SDL_Hint for the dynamic VSYNC 2022-08-30 07:20:36 -04:00
Noel Berry 00452e47fa
Adding SDL_GetWindowSizeInPixels for window size in pixels (#6112) 2022-08-24 11:25:13 -07:00
Sam Lantinga 50c5d23f7d Round coordinates so very small floating point values don't turn into 0x80000000
e.g. SDL_RenderDrawLineF(renderer, -1e20, -1e20, 10, 10);

Fixes https://github.com/libsdl-org/SDL/issues/6116
2022-08-23 07:42:48 -07:00
Cameron Cawley 09b6956dcc opengl: Support NV12 textures on GPUs with only 2 texture units 2022-08-16 07:30:13 -07:00
Francisco Javier Trujillo Mata 7d5ccae22d Fix memory leak when destroying texture 2022-08-14 08:13:37 -04:00
Sam Lantinga cb46e1b3f0 Removed unused variable 2022-08-12 20:51:44 -07:00
Ethan Lee a28f426acb render: Only update size/scale/viewport when moving to a new display, rather than all window movement.
We really only care about DPI changes here, so this both reduces work and also avoids weird cases where viewport state can be corrupted by trivial window events. This doesn't _completely_ get rid of the issue but this is somewhat intentional, since apps will definitely want to do a full reset when changing displays anyhow (otherwise DPI/adapter changes will screw things up, and that's out of our control as long as both window size and drawable size are exposed at the same time.

Note that OpenGL still captures window events because of weird platform-specific issues like macOS and viewport stretching!

Fixes #5949
2022-08-12 16:13:24 -04:00
Francisco Javier Trujillo Mata 20f9a1b8a4 Implement SetTextureScaleMode 2022-08-08 09:34:08 -07:00
Francisco Javier Trujillo Mata fbb440d167 Invalidate texture in the UnlockTextureMethod 2022-08-06 12:11:34 -07:00
Sam Lantinga 5858c7dfce Fixed OpenGL ES Shaders for systems that don't understand precision keywords 2022-08-05 16:17:10 -07:00
Francisco Javier Trujillo Mata 944111dbcf Cleaning up video driver 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata 83c1179744 Adding SetViewPortCommand 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata a9f4cda3f9 Adding setcliprect command 2022-08-02 11:40:31 -07:00