Commit Graph

539 Commits

Author SHA1 Message Date
Sam Lantinga
524739900a Fixed potential double-free when creating a renderer (thanks @Sackzement!)
Closes https://github.com/libsdl-org/SDL/pull/14371
2025-11-01 11:24:14 -07:00
Sam Lantinga
0ea20a5f86 Fix NULL pointer dereference in SDL_RenderGeometryRaw with NPOT textures (thanks @bleeqer!)
Fixes https://github.com/libsdl-org/SDL/issues/14329
Closes https://github.com/libsdl-org/SDL/pull/14331
2025-10-26 08:10:52 -07:00
nmlgc
2ffabb5150 render: Fix texture format selection for color-keyed indexed surfaces
015cc6a broke texture format selection for this kind of surface if the
renderer's first texture format doesn't happen to have an alpha
channel. This happens for on-screen software renderers on Windows,
whose preferred format is the window's own `SDL_PIXELFORMAT_XRGB8888`.
This fixed check also cover the intent behind 015cc6a, assuming that
indexed and alpha formats are mutually exclusive.
2025-10-14 21:23:09 -07:00
Sam Lantinga
015cc6aa6c Fixed accidentally using INDEX8 textures for RGB24 surfaces 2025-10-13 15:27:13 -07:00
Sam Lantinga
d7ad47e2ca Added SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN
Fixes https://github.com/libsdl-org/SDL/issues/13908
2025-10-12 11:15:47 -07:00
Sam Lantinga
513de0f0ec Don't allow SDL_TEXTURE_ADDRESS_WRAP if it's not supported
Fixes https://github.com/libsdl-org/SDL/issues/13908
2025-10-12 10:46:48 -07:00
Sam Lantinga
480f069cec Copy the palette instead of referencing it when creating a texture
Fixes https://github.com/libsdl-org/SDL/issues/14213
2025-10-11 11:01:15 -07:00
Sam Lantinga
9d635fe641 Flush rendering if a texture palette is in use when destroyed 2025-10-10 17:42:27 -07:00
Sam Lantinga
84b0565096 Fixed potential memory leak 2025-10-08 19:44:03 -07:00
Sam Lantinga
3316dde0c2 Improved error information when renderer creation fails
On Android, if you create a window with SDL_WINDOW_OPENGL, you can't create a Vulkan surface. The error message has been improved to reflect this, and the error is propagated back up to the application.

Also added warn level logging if the renderer couldn't be created.
2025-10-08 19:36:19 -07:00
Sam Lantinga
b92557c0b7 Made error message consistent between SDL_SetSurfacePalette() and SDL_SetTexturePalette() 2025-10-06 09:22:34 -07:00
Sam Lantinga
134b47730b Added support for linear and pixel art scaling for palettized textures 2025-10-04 15:12:08 -07:00
Sam Lantinga
1cda789a37 render: Default to primary display in SDL_CalculateSimulatedVSyncInterval if window is not set
- Fixes previous change to SDL_CreateRendererWithProperties which skipped SDL_CalculateSimulatedVSyncInterval if window was not set.
2025-10-03 16:00:44 -07:00
Sam Lantinga
0cab3521f1 render: Fix asserts from null window usage in SDL_CreateRendererWithProperties 2025-10-03 16:00:41 -07:00
Sam Lantinga
32668c4ddd Palettized textures will always use SDL_SCALEMODE_NEAREST.
Our algorithm for pixel art doesn't work on 8-bit images, needs further investigation.

Fixes https://github.com/libsdl-org/SDL/issues/14129
2025-10-03 14:29:47 -07:00
Sam Lantinga
a864dcac25 Added support for using the GPU renderer as an offscreen renderer
SDL_CreateGPURenderer() now allows passing in an existing GPU device and passing in a NULL window to create an offscreen renderer.

Also renamed SDL_SetRenderGPUState() to SDL_SetGPURenderState().
2025-10-01 23:32:18 -07:00
Sam Lantinga
fe3b399b7e Added support for P010 pixel format in SDL_UpdateNVTexture() 2025-10-01 07:17:55 -07:00
Sam Lantinga
b65590159b Each application palette corresponds to one hardware palette
When the application modifies the palette, any textures that use it will automatically be updated.
2025-09-28 22:10:06 -07:00
Sam Lantinga
5622eef5a8 Fixed memory leak if requested renderer isn't available 2025-09-28 22:10:06 -07:00
Sam Lantinga
2a01e12d34 Simplify palette code
Each texture gets its own palette, the palette is updated when it is rendered if necessary, rendering is flushed if a texture render is already queued up.

Trying to share palettes and handle the different cases of queued rendering and changing palettes in the middle of the frame ends up being very complicated, so we'll keep it simple for now.
2025-09-28 22:10:06 -07:00
Sam Lantinga
7dcc09986d Test changing the palette for a single texture 2025-09-28 22:10:06 -07:00
Sam Lantinga
264b436dba Fixed changing palettes while rendering is in flight 2025-09-28 22:10:06 -07:00
Sam Lantinga
0b4b254a53 Added support for textures with palettes
Closes https://github.com/libsdl-org/SDL/pull/6192
2025-09-28 22:10:06 -07:00
Sam Lantinga
25b2d2c821 Use new parameter validation macro 2025-09-18 20:58:32 -07:00
Sam Lantinga
ee1c90a358 Improved handling of function parameter validation
SDL supports the following use cases:
 * Normal operation with fast parameter checks (default):
    SDL_SetHint(SDL_HINT_INVALID_PARAM_CHECKS, "1");
 * Object parameters are checked for use-after-free issues:
    SDL_SetHint(SDL_HINT_INVALID_PARAM_CHECKS, "2");
 * Enable full validation, plus assert on invalid parameters:
    #define SDL_ASSERT_INVALID_PARAMS
 * Disable all parameter validation:
    #define SDL_DISABLE_INVALID_PARAMS
2025-09-18 20:58:32 -07:00
Ryan C. Gordon
3ee29f2e7a render: Don't default to vsync=0 on Emscripten.
Fixes #12805.
2025-09-16 12:30:22 -04:00
Ryan C. Gordon
11411bb5ef renderer: Don't use wrapping on NPOT textures if the renderer can't handle it.
Fixes #13887.
2025-09-08 17:09:41 -04:00
Sam Lantinga
fb2daa2f5f Updated the documentation for SDL_GetRenderLogicalPresentation()
Fixes https://github.com/libsdl-org/SDL/issues/13791
2025-09-06 11:21:36 -07:00
Sam Lantinga
5605f85d84 Check the return value of SDL_SW_CopyYUVToRGB() 2025-09-06 10:07:09 -07:00
Sam Lantinga
fbbc29159a Leave letterbox borders set to the frame clear color
Fixes https://github.com/libsdl-org/sdl2-compat/issues/483
2025-09-02 20:14:34 -07:00
Sam Lantinga
285df94623 Renamed SDL_GPURenderStateDesc to SDL_GPURenderStateCreateInfo for consistency with GPU API conventions
Fixes https://github.com/libsdl-org/SDL/issues/12817
2025-08-27 09:14:19 -07:00
Petar Popovic
b63c32e790 SDL_SetRenderDrawBlendMode(): Remove redundant param check 2025-08-08 14:05:33 -04:00
Brenton Bostick
f361034ac3 fix typos 2025-07-27 08:10:03 -07:00
Ryan C. Gordon
07ef532681 hints: Renamed SDL_HINT_LOG_BACKENDS to SDL_DEBUG_LOGGING.
This still logs backend choices, but we might use it for other things. For
example, what Android device is being used, or all the devices we enumerated,
etc.

Ideally this eventually logs all the stuff we often have to ask followup
questions about.
2025-07-22 13:19:30 -04:00
Sam Lantinga
86200d1203 Fixed clamp texture address mode in software renderer 2025-07-21 10:20:16 -07:00
Sam Lantinga
7510a67159 Fixed typo
Fixes https://github.com/libsdl-org/SDL/issues/13373
2025-07-16 19:31:10 -07:00
Ryan C. Gordon
10004ab0ea hints: Added SDL_HINT_LOG_BACKENDS.
Fixes #13354.
2025-07-14 19:49:38 -04:00
Sam Lantinga
727b4924c8 Update the viewport when logical presentation changes
Fixes https://github.com/libsdl-org/SDL/issues/13256
2025-06-25 09:58:30 -07:00
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
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