494 Commits

Author SHA1 Message Date
Ivan Epifanov
79ec8986d3 Vita: refactor gxm texture render and add SDL_RenderGeometry support 2021-09-16 09:03:17 -07:00
Misa
4a9947336c SDL_RenderSetVSync(): Restrict vsync to 0 or 1
In the future, we might want to support special swap intervals. To
prevent applications from expecting nonzero values of vsync to be the
same as "on", fail with SDL_Unsupported() if the value passed is neither
0 nor 1.
2021-09-14 16:18:02 -07:00
Misa
4549769d7d Add SDL_RenderSetVSync()
Currently, if an application wants to toggle VSync, they'd have to tear
down the renderer and recreate it. This patch fixes that by letting
applications call SDL_RenderSetVSync().

This is the same as the patch in #3673, except it applies to all
renderers (including PSP, even thought it seems that the VSync flag is
disabled for that renderer). Furthermore, the renderer flags also change
as well, which #3673 didn't do. It is also an API instead of using hint
callbacks (which could be potentially dangerous).

Closes #3673.
2021-09-14 09:56:29 -07:00
Ivan Epifanov
10d3df44f1 Vita: fix copyright dates 2021-09-09 07:22:01 -07:00
Ryan C. Gordon
d49d955d73
render: SDL_RenderGeometry should still render when hidden, in most cases.
(otherwise render targets may fail, etc...the check is a legacy helper for
iOS apps that crash if you try to use OpenGL while in the background.)
2021-09-08 11:44:17 -04:00
Sylvain
183eb0673b
Fixed bug #4711: prevent opengl SDL_renderer from crashing if GL_ARB_multitexture isn't supported 2021-09-01 15:46:32 +02:00
Sylvain
be6bee0b5a
SW_RenderGeometry: add a redundant check to clear static analysis (see bug #4600) 2021-08-27 07:47:28 +02:00
Sylvain
54ca1d190e
SW_RenderGeometry: add a redundant check to clear static analysis (see bug #4600) 2021-08-27 07:44:03 +02:00
Sylvain
b17aa5d080
SW_RenderGeometry: remove a few static analysis false positives (see bug #4600) 2021-08-27 07:16:40 +02:00
Sylvain
e426bb80cb
Fixed bug #4671 - D3D_QueueGeometry: use "count / 3" (Thanks alittlesail!) 2021-08-20 07:50:30 +02:00
Sylvain
ae5336a3d2
Fixed bug #4669: D3D_QueueGeometry: -0.5f offset position of vertexs
This similar to D3D_QueueCopy positions
2021-08-19 14:03:10 +02:00
Ozkan Sezer
8270172e74 fix -Wshorten-64-to-32 warnings in android builds.
see: https://github.com/libsdl-org/SDL/pull/4195#issuecomment-901506386
2021-08-19 12:11:10 +03:00
Sylvain
154384a776 Add (uintptr_t) casts 2021-08-19 00:10:59 +02:00
Sylvain
1670104ad8 Change 'size_indice' to 'size_indices' 2021-08-19 00:10:59 +02:00
Sylvain
a8f89a01aa Change 'size_indice' to 'size_indices' 2021-08-19 00:10:59 +02:00
Sylvain
47db47c1cc Add SDL_HAVE_RENDER_GEOMETRY to compile or not with RenderGeometry support 2021-08-19 00:10:59 +02:00
Sylvain
b9bd9da78f OpenGLES2: transfert color as 4 bytes, instead of 4 floats 2021-08-19 00:10:59 +02:00
Sylvain Becker
c6ceaaeb4b METAL: use Uchar4Normalized format to transfert color as 4 bytes, instead of 4 floats 2021-08-19 00:10:59 +02:00
Sylvain
eff840bb9b Add OpenGLES implementation 2021-08-19 00:10:59 +02:00
Sylvain
32e7910135 Fix warnings 2021-08-19 00:10:59 +02:00
Sylvain
6e47f53869 Fix warnings 2021-08-19 00:10:59 +02:00
Sylvain
4869a3d294 Add Direct3D9 implementation (not tested) 2021-08-19 00:10:59 +02:00
Sylvain
4ba3763897 Save and restore SDL renderer state after transforming triangles to rect 2021-08-19 00:10:59 +02:00
Sylvain
cd0663e053 Fix declaration-after-statement and remove tabs 2021-08-19 00:10:59 +02:00
Sylvain Becker
cd4663dfcb Update D3D11 for SDL_RenderGeometryRaw 2021-08-19 00:10:59 +02:00
Sylvain Becker
9f59170743 Update METAL backend for SDL_RenderGeometryRaw 2021-08-19 00:10:59 +02:00
Sylvain
61d9e9164f For the software renderer, try to reinterpret triangles as SDL_Rect
With Dear ImGui + software renderer, it draws:
- by default at 250 fps
- drops to 70 fps if you show the color picker
- drops to 10 fps if put the color picker fullscreen
2021-08-19 00:10:59 +02:00
Sylvain
cc37c38e30 Add SDL_RenderGeometry based on SDL_RenderGeometryRaw 2021-08-19 00:10:59 +02:00
Sylvain
e481261173 Move to SDL_RenderGeometryRaw prototype with separate xy/uv/color pointer parameters 2021-08-19 00:10:59 +02:00
Sylvain
111c70e141 Use 64 bits precision to prevent overflow when interpolating color / texture with wide triangles 2021-08-19 00:10:59 +02:00
Sylvain
f73c1eff10 Use normalized texture coordinates 2021-08-19 00:10:59 +02:00
Sylvain
5828cc415a Update METAL backend: fix a typo in drawline 2021-08-19 00:10:59 +02:00
Sylvain Becker
9a8a8e65b8 Update SDL_render_d3d11.c
Fix D3D11 compilation
2021-08-19 00:10:59 +02:00
Sylvain Becker
121114d061 Update METAL compiled shaders 2021-08-19 00:10:59 +02:00
Sylvain Becker
2d01573bb9 Add METAL shaders 2021-08-19 00:10:59 +02:00
Sylvain Becker
1e77dae7b7 Add METAL implementation 2021-08-19 00:10:59 +02:00
Sylvain
1ebef0732a Add D3D11 implementation (not yet tested) 2021-08-19 00:10:59 +02:00
Sylvain
3ee511d71c Add software renderer implementation 2021-08-19 00:10:59 +02:00
Sylvain
37f78fc1cc Add OpenGL implementation 2021-08-19 00:10:59 +02:00
Sylvain
faded41ab1 Add OpenGLES2 implementation 2021-08-19 00:10:59 +02:00
Sylvain
6e26d320c6 Add sysrender interface 2021-08-19 00:10:59 +02:00
Sylvain
53a2608bd2 Renderer opengles2: turn color Uniform into Attribute.
all attributes are copied interleaved (based on rmg-nik initial patch+
+ minor clean up of data structure
+ add check for colorswap
2021-08-19 00:10:59 +02:00
Sam Lantinga
f5794f9eeb Added SDL_SetTextureUserData() and SDL_GetTextureUserData() to associate a user-specified pointer with an SDL texture 2021-08-10 15:17:59 -07:00
Sam Lantinga
fcfd19db86 Added support for SDL_RENDERER_PRESENTVSYNC to the software renderer
This fixes https://github.com/libsdl-org/SDL/issues/4612
2021-08-10 12:02:59 -07:00
Sam Lantinga
a91ab883e9 Fixed building on Windows with cmake, ninja, and clang 2021-08-06 12:28:24 -07:00
Ryan C. Gordon
5fc13fcb21 direct3d: Commit viewport state before clearing, attempt 2.
This reintroduces the fix from 0e16ee8330606603, but just marks
the viewport state as dirty after a clear that needs to expand the
viewport to fill the render target, as we'll need to also reset
the orthographic projection state elsewhere, and that won't
happen if we clear the dirty flag here.

Fixes #4210.
(again.)
(...sorry...!)
2021-08-04 07:00:17 -04:00
David Gow
4077f7a2d9 Update the Renderer dpi_scale on SIZE_CHANGED event (fix #4580)
The Renderer logical scaling code scales mouse coordinates, and needs to
take the window DPI into account on HIGHDPI windows. However, the
variable which tracks this, renderer->dpi_scale, is set once when the
renderer is created, and then not updated. In the event that the window
is moved to another screen, or the screen DPI otherwise changes, this
will be outdates, and potentially the coordinates will be all wrong.

So let's update the dpi_scale on the SIZE_CHANGED event: it's at least a
possibility that this will be issued on some OSes when DPI changes, and
it's otherwise already handled by SDL_Renderer's event filter.
2021-08-03 09:30:43 -07:00
Sam Lantinga
9d64e6b442 Revert "direct3d: Commit dirty viewport state before clearing."
This reverts commit 0e16ee833060660318cc324cf99c9736f4d48499.
2021-08-03 00:29:33 -07:00
Ryan C. Gordon
0e16ee8330 direct3d: Commit dirty viewport state before clearing.
Otherwise you might have set the viewport to the full size of
the render target in SDL's API but this change hasn't been
transmitted to Direct3D yet by the time we attempt to clear.

Fixes #4210.
2021-08-03 02:32:56 -04:00
David Gow
8f06a629aa render: Fix -Wmaybe-uninitialized warning in RenderDrawLinesWithRects{,F}
The RenderDrawLinesWithRects and RenderDrawLinesWithRectsF functions can
sometimes call QueueCmdFillRects() with the data pointed to by frects
uninitialised. This can occur if none of the lines can be replaced with
rects, in which case the frects array is empty, and nrects is 0.

gcc 10.3.0 will detect this possibility, and print a warning like:
/home/david/Development/SDL/src/render/SDL_render.c: In function 'RenderDrawLinesWithRectsF':
/home/david/Development/SDL/src/render/SDL_render.c:2725:15: warning: '<unknown>' may be used uninitialized [-Wmaybe-uninitialized]
 2725 |     retval += QueueCmdFillRects(renderer, frects, nrects);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/david/Development/SDL/src/render/SDL_render.c:499:1: note: by argument 2 of type 'const SDL_FRect *' to 'QueueCmdFillRects' declared here
  499 | QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int count)
      | ^~~~~~~~~~~~~~~~~

This is harmless, because when this is uninitialised, nrects is always
0, so QueueCmdFillRects() does nothing anyway. We therefore can work
around this by only calling QueueCmdFillRects() when nrects is nonzero.
Somewhat impressively, gcc recognises that this is now safe.
2021-07-30 10:53:49 -04:00