Commit Graph

1490 Commits

Author SHA1 Message Date
Sam Lantinga
294beceec7 Fixed error: 'srcpixel' may be used uninitialized 2025-11-07 11:11:31 -08:00
Sam Lantinga
0f21e46586 Added support for SDL_PIXELFORMAT_INDEX8 to SDL_BlitTriangle_Slow()
Fixes https://github.com/libsdl-org/SDL/issues/14419
2025-11-07 11:01:23 -08:00
Sam Lantinga
547b2a2e37 SDL_SetSurfaceRLE() has a boolean parameter 2025-11-07 11:01:23 -08:00
Sam Lantinga
e24eeefbd1 The default render texture format is SDL_PIXELFORMAT_ARGB8888
We do this for consistency across backends
2025-11-06 09:46:43 -08:00
Mathieu Eyraud
de5b8a1c45 Remove useless call to SetTextureAddressMode() 2025-11-06 08:25:00 -08:00
Mathieu Eyraud
7ad4911584 Remove incorrect and useless call to SetTextureScaleMode()
SetTextureScaleMode() is called a few lines below with correct arguments.
2025-11-06 08:25:00 -08:00
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
aafbf7183f Copy shader params instead of caching a pointer to them
It's possible for a new texture to be allocated with the same address as a previous one, so we can't just cache the pointer value.

Fixes https://github.com/libsdl-org/SDL/issues/14369
2025-11-01 11:24:14 -07:00
Kirill Andriiashin
a76fb7b2fb Add support for GPU RGB565 (B5G6R5_UNORM) textures with DX11 (#14358) 2025-10-29 10:39:58 -07:00
Sam Lantinga
933beeb18b Fixed warning: no previous extern declaration for non-static variable 2025-10-27 17:52:05 -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
Sam Lantinga
e18d63a4e2 Added SDL_RotateSurface()
Fixes https://github.com/libsdl-org/SDL/issues/14269
2025-10-22 17:55:02 -07:00
Sam Lantinga
a402af506c Removed SDL_FILE from source code 2025-10-22 10:52:18 -07:00
Sam Lantinga
e58648d592 Removed call to ID3D11DeviceContext1_DiscardView() (thanks @pipiwoaini!)
This is unnecessary and can cause issues after a resize or device removal.

Fixes https://github.com/libsdl-org/SDL/issues/14283
2025-10-21 13:01:30 -07:00
Eddy Jansson
aaee09d6ed Don't do NULL-checks before SDL_free()
Replaces the pattern

  if (ptr) {
    SDL_free(ptr);
  }

with

  SDL_free(ptr);
2025-10-20 00:13:09 -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
Peter0x44
705ced8cf5 Make D3D math functions static inline to reduce likelihood of linking conflicts
Convert SDL_d3dmath.c functions to static inline in SDL_d3dmath.h to make
it less likely to conflict when static linking SDL. raylib's SDL backend
does not work with a "normal" upstream binary static link. It has these
errors:

/usr/bin/ld: /usr/local/lib64/libSDL3.a(SDL_d3dmath.c.o): in function `MatrixIdentity':
SDL/src/render/SDL_d3dmath.c:35: multiple definition of `MatrixIdentity'; CMakeFiles/raylib.dir/rcore.c.o:rcore.c:(.text+0x18470): first defined here
/usr/bin/ld: /usr/local/lib64/libSDL3.a(SDL_d3dmath.c.o): in function `MatrixMultiply':
SDL/src/render/SDL_d3dmath.c:44: multiple definition of `MatrixMultiply'; CMakeFiles/raylib.dir/rcore.c.o:rcore.c:(.text+0x18540): first defined here
collect2: error: ld returned 1 exit status

It works if these functions aren't emitted, (i.e.
!SDL_VIDEO_RENDER_D3D(11|12|GPU|VULKAN)

Or, if SDL is not linked static. Which I know is preferred anyway.

In raylib's case, it doesn't use this code anyway so it's not a problem
to build it yourself with them disabled. But it's a minor hassle to be
incompatible with static linking libraries from upstream.

I can't see any good reason for these functions to not be static inline
already, so I just put them in the header and deleted the .c.

Raylib's conflicting case is a library with a public function exposed to
users. But SDL's case is not.

- Moved all matrix functions from SDL_d3dmath.c to SDL_d3dmath.h as static inline
- Removed SDL_d3dmath.c from all project files (Visual Studio and Xcode)
- Functions affected: MatrixIdentity, MatrixMultiply, MatrixScaling,
  MatrixTranslation, MatrixRotationX, MatrixRotationY, MatrixRotationZ
2025-10-14 16:56:41 -07:00
Sam Lantinga
015cc6aa6c Fixed accidentally using INDEX8 textures for RGB24 surfaces 2025-10-13 15:27:13 -07:00
Sam Lantinga
7a49ce71a1 Handle partial OpenGL shader availability
The pixelart shaders are not supported on OpenGL 2.1 (GLSL 130 isn't available)

Fixes the OpenGL renderer on macOS
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
1ed093ad8b Corrected texture colors on PS2 (thanks @Trinth!)
Fixes https://github.com/libsdl-org/SDL/issues/12395
2025-10-12 09:20:00 -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
Sylvain
2a96997e90 Fixed bug #14173 - Android / SDL_Renderer Vulkan : going background / foreground produces a black screen.
need to recreate the swap chain + send SDL_EVENT_RENDER_DEVICE_RESET event
2025-10-09 08:40:42 -07:00
Roman Fomin
c86cfb0156 Disable D3D feature levels below 11.0 for the D3D11 renderer 2025-10-08 21:10:08 -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
edf5f9ec5c Properly upgrade a window to Vulkan when creating a Vulkan renderer 2025-10-08 19:17:11 -07:00
ROllerozxa
f43577bbb5 Fix compiling Metal renderer with SDL_LEAN_AND_MEAN 2025-10-07 16:20:59 -07:00
Sam Lantinga
7877ed1802 Fixed permissions 2025-10-06 17:30:04 -07:00
Sam Lantinga
9f9be1425d Fixed permissions 2025-10-06 17:24:56 -07:00
Sam Lantinga
b92557c0b7 Made error message consistent between SDL_SetSurfacePalette() and SDL_SetTexturePalette() 2025-10-06 09:22:34 -07:00
Cameron Cawley
ab06784318 Check the availability of GL_BGRA before use 2025-10-06 08:58:45 -07:00
Cameron Cawley
12cee1cf46 Use the correct pixel formats for OpenGL on big endian 2025-10-06 08:58:45 -07:00
Sam Lantinga
941b0a8ea4 Added support for external GPU textures to the GPU renderer 2025-10-06 07:31:00 -07:00
definability
4d9295ef1e Fixed building with SDL_LEAN_AND_MEAN
Fixes https://github.com/libsdl-org/SDL/issues/14151
2025-10-05 17:36:11 -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
f3815ede24 Rebuilt GPU renderer shaders 2025-10-03 19:35:45 -07:00
Sam Lantinga
49d51a0d3c Removed TEXTURETYPE_PALETTE_PIXELART
This doesn't make any sense since the pixel art algorithm uses a box filter to get an average pixel value which isn't possible with indexed textures.
2025-10-03 18:54:07 -07:00
Sam Lantinga
ac2c834021 Fixed build 2025-10-03 16:04:45 -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
d333044462 Fixed destination coordinates when using scale with the software renderer
Fixes https://github.com/libsdl-org/SDL/issues/14051
2025-10-03 13:58:45 -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
8d7cd3c6c2 Fixed line endings 2025-10-01 14:01:59 -07:00
Sam Lantinga
9735c45db6 Added an advanced shader for the GPU renderer
This allows us to support YUV colorspaces and HDR in the GPU renderer.

Fixes https://github.com/libsdl-org/SDL/issues/11281
Fixes https://github.com/libsdl-org/SDL/issues/11282
2025-10-01 07:17:55 -07:00
Sam Lantinga
fe3b399b7e Added support for P010 pixel format in SDL_UpdateNVTexture() 2025-10-01 07:17:55 -07:00
Sam Lantinga
548063e578 Fixed pixel shader for palettized textures using pixelart scaling 2025-10-01 07:17:55 -07:00