Commit graph

501 commits

Author SHA1 Message Date
Michael Fitzmayer
7ae64592c9
Restore support for the Nokia N-Gage (#12148) 2025-05-22 11:07:22 -07:00
Sam Lantinga
ec685e87fd Clarify logic in UpdateLogicalPresentation() 2025-05-14 10:12:41 -07:00
Frank Praznik
8aa5b97bb5 renderer: Always use the output size when updating the main view
Some checks are pending
Build (All) / Create test plan (push) Waiting to run
Build (All) / level1 (push) Blocked by required conditions
Build (All) / level2 (push) Blocked by required conditions
The main view always reflects the size of the output, so don't use the dimensions of the currently bound render target texture when updating it, or it will reflect an incorrect size when the render target texture is unbound.
2025-05-14 09:37:30 -07:00
Petar Popovic
27b256022b SDL_GetRectIntersectionFloat(): Allow rendering zero-sized srcrect 2025-04-23 16:14:52 -07:00
Topi-Matti Ritala
f7b7188837 Add SDL_CreateGPURenderer 2025-04-07 09:26:03 -07:00
Sam Lantinga
36fc1c2c9c Fixed texture colorspace when creating a texture from a surface
Fixes https://github.com/libsdl-org/SDL/issues/12691
2025-03-31 18:49:58 -07:00
Sam Lantinga
633b9f6fb1 Added SDL_SetRenderTextureAddressMode() and SDL_GetRenderTextureAddressMode()
Fixes https://github.com/libsdl-org/SDL/issues/4820
Fixes https://github.com/libsdl-org/SDL/issues/12610
2025-03-28 13:51:19 -07:00
Sam Lantinga
758eb256b9 Fixed DebugLogRenderCommands() output 2025-03-20 21:24:39 -07:00
Sam Lantinga
47b0c75470 Make sure we're getting called for the correct window
Fixes https://github.com/libsdl-org/SDL/issues/12525
2025-03-19 20:20:36 -07:00
JaimeHW
3e5664a5be Fix return type in SDL_CreateGPURenderState 2025-03-17 15:22:49 -07:00
Sam Lantinga
02faa8f75c Rename SDL_SetGPURenderStateFragmentUniformData() to SDL_SetGPURenderStateFragmentUniforms() 2025-03-14 09:26:30 -07:00
Sam Lantinga
2aee105b43 Added support for custom shaders with the GPU renderer
Added an example of MSDF font rendering with the SDL 2D renderer
2025-03-14 09:26:30 -07:00
Sam Lantinga
3e9e22f17d Added SDL_SCALEMODE_PIXELART
This is based on the algorithm presented by t3ssel8r:
https://www.youtube.com/watch?v=d6tp43wZqps
2025-03-13 09:48:37 -07:00
Sam Lantinga
b99ff00a95 Removed logic forcing vsync on if setting it off fails
The platforms that needed this (Windows Phone and Windows RT) are no longer supported, and if this is needed in the future it should be done at the renderer level, not here.

Fixes https://github.com/libsdl-org/SDL/issues/12475
2025-03-06 16:18:02 -08:00
Sam Lantinga
cb099ebd4f Make texture scale mode a part of the 2D renderer draw state
Also added texture addressing mode support to the PSP and Vita renderers (untested)

Fixes https://github.com/libsdl-org/SDL/issues/12461
2025-03-05 21:35:04 -08:00
Sam Lantinga
5d20bbf348 Presenting while drawing to a render target should fail.
People are adding present calls while rendering to render targets, not understanding that this doesn't make sense, and wondering why they get flicker on some systems. If there are programs that relied on the previous behavior we can add a hint to control this.

Fixes https://github.com/libsdl-org/SDL/issues/12432
2025-03-04 08:46:13 -08:00
Sam Lantinga
4bb46e93c8 Fixed clip rect when logical presentation is enabled
We don't need to include the logical offset, it's already included in the viewport.

Fixes https://github.com/libsdl-org/SDL/issues/12454
2025-03-04 08:24:18 -08:00
Arkadiusz Lach
67127afe3f Fix from #12118 2025-03-02 07:52:25 -08:00
Arkadiusz Lach
e25ee22469 Added tiled 9-grid texture rendering function
* New function SDL_RenderTexture9GridTiled, borders and center is tiled instead of stretched
2025-03-02 07:52:25 -08:00
Arkadiusz Lach
44bca81fdd Change default texture scale mode per renderer
* SDL_SetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode scale_mode)
* SDL_GetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode *scale_mode)
2025-03-02 07:51:17 -08:00
Ryan C. Gordon
35e8cf8ee6 render: allow render targets to use logical presentation.
Fixes https://github.com/libsdl-org/sdl2-compat/issues/279
2025-02-27 19:41:11 -05:00
Sam Lantinga
85a302550d Set an error message if the rect passed to SDL_RenderReadPixels() is entirely outside the viewport 2025-02-25 10:28:57 -08:00
Sam Lantinga
db4e6c1931 Cocoa metal layers need their size updated before renderer updates
Also refactored event watch code so it can be shared between internal window event dispatch and public event watchers.

Fixes https://github.com/libsdl-org/SDL/issues/12376
2025-02-24 15:37:13 -08:00
Sam Lantinga
2e89c53ebc Added support for decoding MJPG into NV12 textures 2025-02-20 12:16:26 -08:00
Sam Lantinga
a792434a37 Added initial MJPG support using stb_image 2025-02-20 12:16:26 -08:00
Sam Lantinga
1a38960eee Call SDL_DiscardAllCommands() for the software renderer as well 2025-02-20 09:53:11 -08:00
Sam Lantinga
8f4c5e15f1 Finish any drawing when destroying a software renderer
Fixes the SDL3 version of https://github.com/libsdl-org/sdl2-compat/issues/373
2025-02-20 08:49:47 -08:00
nightmareci
7500a758b8 Remove usages of restrict keyword in SDL_render.c
I ran into the usage of `restrict` breaking builds targeting Windows XP, as the v141 MSVC toolset doesn't support the keyword.
2025-02-18 11:40:43 -08:00
Sam Lantinga
fd4e6d2949 Don't render 0 sized texture rectangles
Fixes https://github.com/libsdl-org/sdl2-compat/issues/355
2025-02-15 07:07:56 -08:00
Petar Popovic
c16b7bcb7a SDL_Get*Driver() functions: Set error message on failure 2025-02-13 16:10:37 -08:00
Sam Lantinga
cf41ccc6ce Removed stb_image.h from SDL
This adds quite a bit of code size to SDL for a niche use-case. This is easily handled in the application instead.
2025-02-10 17:18:16 -08:00
Sam Lantinga
84b0c13c44 Added support for Motion JPEG camera capture
Fixes https://github.com/libsdl-org/SDL/issues/12183
2025-02-10 17:18:16 -08:00
Sam Lantinga
48c00bfe6c Fixed creating a window with both software and hardware renderer attached 2025-02-06 15:35:38 -08:00
Sam Lantinga
ad8429f1b0 Let the renderer always see window events
These are necessary for proper operation of the renderer and shouldn't be blocked by event filters, etc.
2025-02-06 14:38:20 -08:00
Em
c922762791 proposed fix: set curr_src.h is to bottom_height before drawing bottom edges / corners in SDL_RenderTexture9Grid, to avoid issue where inadvertently using top height if the npatch existed on a larger texture than the drawn edge would cause too many pixels to be included in the bottom part of the render. 2025-02-01 16:09:08 -08:00
Ryan C. Gordon
c45c4a5e51
render: SDL_HINT_RENDER_DRIVER now accepts a comma-separated list.
Fixes #11077.
2025-01-21 11:29:00 -05:00
Sam Lantinga
075c0337cd Removed debug print statement 2025-01-20 13:11:19 -08:00
Sam Lantinga
9b454a762c Revert "testautomation: don't validate alpha values on XRGB formats"
This reverts commit 759e01bd64.

It's better to return the expected format from SDL_RenderReadPixels() than skip alpha testing.
2025-01-20 12:57:48 -08:00
Ryan C. Gordon
dcadd23ba1 render: Prevent division by zero if logical presentation is 0 pixels. 2025-01-20 15:52:33 -05:00
Sam Lantinga
c698c61f03 renderer: initialize the surface colorspace correctly
Fixes https://github.com/libsdl-org/SDL/issues/12027
2025-01-20 10:48:13 -08:00
Ryan C. Gordon
4bb3c2a1c7
render: Some cleanups.
Mostly setting NULL pointers to a local struct instead of copying non-NULL
pointers' contents into the local struct.
2025-01-08 14:59:28 -05:00
Ryan C. Gordon
61bdbacdae
render: SDL_RenderTextureTiled shouldn't try to drop draw calls, either. 2025-01-08 14:59:28 -05:00
Ryan C. Gordon
f044a3d6ca
Revert "render: GetRenderViewportSize shouldn't use scale, just logical presentation."
This reverts commit ef758d05c1.

Turns out the bug in #11076 was that we were dropping texture draws
incorrectly, not that scale shouldn't be applied here. The dropped draw calls
were fixed in bf85320947, and this revert is
making the renderer consistent again.
2025-01-08 14:59:27 -05:00
Ryan C. Gordon
fa7a529912
render: GetRenderViewportSize shouldn't scale viewport dimensions.
These are already scaled for the logical presentation (unless using the pixel
dimensions instead; we still scale those here).

Fixes #11704.
2025-01-08 14:59:27 -05:00
Ryan C. Gordon
bf85320947
render: Don't try to drop draws outside of the viewport.
It didn't take scale into account, and the backends would need to do clipping
anyhow, so let the system figure that out for us at the lower level.

Fixes #11318.
2025-01-08 11:55:10 -05:00
Sam Lantinga
f2074d7af3 Updated copyright for 2025 2025-01-01 07:45:52 -08:00
Sam Lantinga
d4d5faedab Added SDL_EVENT_FINGER_CANCELED
Fixes https://github.com/libsdl-org/SDL/issues/10528
2024-12-30 19:13:02 -08:00
Sam Lantinga
f37eef948c Removed raw mouse events
It's too close the 3.2.0 release for an API change like this.

If/when we re-add these, some things for consideration:
* What use cases does this enable that aren't currently possible?
* What cross-platform API guarantees do we make about the availability of these events? e.g. do we try to simulate them where raw input isn't actually available?
* How is this different from the existing relative mode, and how do we clearly explain when you want these events vs wanting relative mode?

Notes from @expikr:
First observation: the reason I originally passed denominators instead of multipliers was because some rational values cannot be exactly represented by floats (e.g 1/120) so instead let the end-developer decide how to do the dividing themselves. It was the reason why it was using split values with an integer numerator to begin with, instead of having both as floats or even just normalize it in advance.

On the other hand, passing them as multipliers might have hypothetical uses for dynamically passing end-user controlled scaling in a transparent manner without coupling? (Though in that case why not just do that as additional fields appended to `motion` structs in an API-compatible layout?)

So it’s somewhat of a philosophical judgement of what this API of optional availability do we intend for it to present itself as:
- should it be a bit-perfect escape hatch with the absolute minimally-denominal abstraction over platform details just enough to be able to serve the full information (á la HIDPIAPI),
- or a renewed ergonomic API for splitting relative motion from cursor motion (in light of The Great Warping Purge) so that it is unburdened by legacy RelativeMode state machines, in which case it would be more appropriate to just call it `RELATIVE` instead of `RAW` and should be added alongside another new event purely for cursor events?

This alternate API stream was conceived in the context of preserving compatibility of the existing RelativeMode state machine by adding an escape hatch. So given the same context, my taste leans towards the former designation.

However, as The Great Warping Purge has made it potentially viable to do so, if I were allowed to break ABI by nuking the RelativeMode state machine entirely, I would prefer the latter designation unified as one of three separate components split from the old state machine, each independently controlled by platform-dependent availability without any state switching of a leaky melting pot:
- cursor visibility controls (if platform has cursor)
- cursor motion events (if platform has cursor)
- relative motion events (if the platform reports hardware motion)
2024-12-21 05:18:42 -08:00
Sam Lantinga
c44fa5bb07 Updated raw input events to match SDL style
Also added raw keyboard events, and implemented raw input events on iOS, OpenBSD console, Linux console, and X11
2024-12-21 05:18:42 -08:00
Marcin Serwin
35a9d156a6 render: convert tmotion vectors to render basis
When using `SDL_ConvertEventToRenderCoordinates` with
`SDL_EVENT_FINGER_MOTION` events it converts `x` and `y` coordinates but
does not convert the the `dx` and the `dy` unlike `xrel` and `yrel` of
mouse motion events. This is means that these are rather useless after
conversion. This change unifies this behavior between touch and mouse
motion events.
2024-12-18 17:17:14 -08:00