Sylvain
1d7966df15
Remove un-needed check for NULL pointer. They were previously checked just before.
2022-11-16 21:27:16 +01: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
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
Sylvain
485bb3565b
Fixed bug #6401 - change the order of triangles when using RenderCopy, RenderCopyEx and RenderFillRect
2022-10-17 13:30:30 +02: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
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
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
Daniel Santos
147a71b976
Finish dummy driver
2022-08-02 11:40:31 -07:00
Daniel Santos
2660449c6c
Add dummy driver
2022-08-02 11:40:31 -07:00
Sylvain
314bb5a1ed
Fixed bug #5850 : Android EGL_BAD_ACCESS because of viewport command while turning the screen off/on.
2022-06-27 14:45:14 +02:00
Sam Lantinga
adc6875870
Added SDL_copyp to avoid size mismatch when copying values (thanks @1bsyl!)
...
Closes https://github.com/libsdl-org/SDL/pull/5811
2022-06-17 10:22:28 -07:00
Ryan C. Gordon
ded6c22efb
render: Corrected wrong SDL_memcpy() sizes for viewport, cliprect.
...
Fixes #5786 .
2022-06-14 14:10:14 -04:00
Sylvain
2cc2260435
Fixed bug #5768 - SDL_RenderGeometry's software backend failed to render when texture coordinates are reversed
...
handle flip vertical/horizontal when reconstructing rects from triangles
2022-06-07 16:30:01 +02:00
chalonverse
4082821822
DirectX 12 Renderer ( #5761 )
...
* DirectX 12 Renderer (27 squashed commits)
* Add missing SDL_hidapi.h of merge of SDL.vcxproj.filters
* Fixed OpenWatcom build failure
* Dynapi fix
Co-authored-by: Ryan C. Gordon <icculus@icculus.org>
2022-06-06 17:42:30 -07:00
Eddy Jansson
9e5cbf034a
Disallow non-positive allocation.
...
Ensure that we're not trying to call SDL_small_alloc()
with a count of zero.
Transforming the code like this fixes a
-Wmaybe-uninitialized warning from GCC 12.0.1
2022-04-29 18:34:13 -07:00
Sam Lantinga
b9fe6ba0e7
Fixed compile warnings
2022-04-18 13:09:08 -07:00
Sylvain
1ede941f5c
SDL_render.c: internally change viewport/cliprect type from SDL_FRect to SDL_DRect (double precision). (see bug #5547 )
2022-04-18 12:26:32 -07:00
pionere
0adb67017b
avoid NullPointer in SDL_GetRenderTarget
2022-04-15 15:47:35 -04:00
Ethan Lee
cb81630816
render: Update the size/scale/viewport on moves, in addition to resizes.
...
For OpenGL this means resetting the viewport state shadowing flag too.
Fixes #1504
2022-04-07 23:38:33 -07:00
Cameron Cawley
57118fb7de
render: Fix setting the scale mode for non-native textures
2022-04-02 09:51:28 -07:00
Mathieu Eyraud
1db47d468a
Fix potential memory leak in QueueCmdFillRects
2022-03-28 08:34:32 -07:00
Ryan C. Gordon
4fe7b2cbd1
static analysis: Fixed several complaints from codechecker.
...
There are still some pending Objective-C specific issues.
Reference issue #4600 .
2022-03-24 11:00:43 -04:00
Sylvain Becker
c23a7ad38a
Add SDL_RenderGetWindow() API to get the window associated with a renderer ( #5440 )
...
Add SDL_RenderGetWindow() API to get the window associated with a renderer
2022-03-23 17:07:56 +01:00
Sylvain
83df4a354e
SDL_render.c: remove unsused case, since renderer target has been forced to NULL previously (see bug #4213 )
2022-03-22 15:25:01 +01:00
Sylvain
9dc201d448
Fixed bug #2962 - when SDL_RenderReadPixels format = 0, used format of the target texture
...
include/SDL_render.h, format:
"0 to use the format of the rendering target "
2022-03-21 10:41:14 +01:00
Ryan C. Gordon
d81fee7623
SDL_Rect: Added floating point versions of all the rectangle APIs.
...
Fixes #5110 .
2022-03-19 10:35:24 -04:00
Sylvain
18b76fcc5d
Fixed bug #3070 - SDL_RenderCopyEx rotation and global scaling around the wrong way (software renderer)
2022-02-15 11:33:56 +01:00
pionere
6d5592a201
minor cleanup of SDL_CreateRenderer
2022-02-05 10:05:25 -05:00
pionere
ebdd536676
use SDL_InvalidParamError or SDL_assert instead of custom SDL_SetError
2022-01-28 20:40:19 -05:00
Sam Lantinga
a29d3acc9e
Updated Bresenham line drawing to match software renderer output
2022-01-09 11:12:13 -08:00
Sam Lantinga
1f32dd8edc
Fixed overdraw with duplicate points, fixed not drawing single point lines
2022-01-09 06:36:18 -08:00
Sam Lantinga
3b083b9911
Fixed compile warning
2022-01-08 14:07:42 -08:00
Sam Lantinga
4ef2529bf9
More efficient calculation of render_count
2022-01-08 12:37:57 -08:00
Sam Lantinga
5346c93b62
Fixed assertion on number of points rendered
2022-01-08 12:28:43 -08:00
Sam Lantinga
4b71962031
Prevent overdraw with connected line segments
2022-01-08 12:02:30 -08:00
Sam Lantinga
09ece861d1
Added the hint SDL_HINT_RENDER_LINE_METHOD to select the line rendering method
2022-01-08 11:36:52 -08:00
Sam Lantinga
c1e6079836
As an optimization, draw horizontal and vertical lines using rectangles
2022-01-08 11:09:11 -08:00
Sam Lantinga
3da7c6305a
Assert that we have drawn the expected number of points
2022-01-08 11:07:03 -08:00
Sam Lantinga
9f56faeedc
Added line drawing using Bresenham's line algorithm (thanks @rtrussell!)
2022-01-08 10:59:31 -08:00
Sam Lantinga
fe3a33a092
Use RenderGeometry for drawing lines at all scales
2022-01-08 10:10:18 -08:00
Sam Lantinga
1694782b2a
Remove redundant work when render scale is 1.0
2022-01-08 09:32:23 -08:00
Sam Lantinga
2026a78dc2
Don't flush in RenderDraw*WithRects()
...
This allows these functions to be reused in the future for other primitives
2022-01-08 09:23:58 -08:00
Ryan C. Gordon
cc2013378d
render: Fixed some compiler warnings.
...
Fixes #5197 .
2022-01-07 20:22:51 -05:00
Sylvain
8ea8b2e697
Use QueueDrawLine if provided, otherwise use RenderGeometry
2022-01-07 14:10:23 -08:00
Sylvain Becker
c498727471
render: Use RenderGeometry to draw lines
...
This patch is from @1bsyl
Fixes #5061 .
2022-01-07 16:14:28 -05:00
Sam Lantinga
120c76c84b
Updated copyright for 2022
2022-01-03 09:40:21 -08:00
Sylvain
3d5fcb5da6
Fix warning
2021-12-16 09:19:53 -08:00
Sylvain
4342e6bd21
SDL_render.c: lighten the cast syntax
2021-12-16 09:19:53 -08:00
Alex Szpakowski
3a5e148b13
Renderer backends use SDL_Color instead of int for geometry colors.
2021-12-14 12:19:16 -08:00
Sylvain
b7885abc44
Fixed bug #5087 : SDL_RenderGeometryRaw() passes colors as int* instead of SDL_Color*
2021-12-14 10:31:55 +01:00
Sylvain
8927d73b1c
RenderGeometry: simplify casting (Thanks Daniel Gibson)
2021-12-12 09:55:23 +01:00
Sylvain
3e43d6e34b
SDL_RenderGeometry: remove some warning "dereferencing type-punned pointer might break strict-aliasing"
2021-12-11 17:19:00 +01:00
Sylvain
d09f80ef18
SDL_DrawPointsF: fix error message typo
2021-12-07 11:31:57 +01:00
Sylvain
6dafc85017
SDL_DrawLines: minor simpification:
...
- scale is 1.0f, don't need to multiply
- typo in error message
- remap SDL_DrawLines to SDL_DrawLinesF
2021-12-07 10:44:12 +01:00
Sylvain
a0818a63e3
Fixed bug #5071 - Float conversion warnings in SDL_render.c (see also #5003 )
2021-12-07 10:07:15 +01:00
Sylvain
e14d10263c
Change viewport and cliprect to float version: from SDL_Rect to SDL_FRect
2021-12-02 10:01:50 +01:00
Ozkan Sezer
e18be04bc6
Fixed undefined behavior in QueueCmdSetDrawColor()
...
Fixes https://github.com/libsdl-org/SDL/issues/4995
Patch from Andrew Kelley
2021-11-23 08:01:02 +03:00
Sylvain
161dd83c9a
Don´t use "trunc" as var name, since it's also a function
2021-11-22 08:38:46 -08:00
Sylvain
49369142bd
Fixed bug #4625 : with integer scale, viewport (as reported by SDL_RenderGetViewport) becomes -2147483648x-2147483648
...
0 isn't valid scale. Min integer scale is 1.0f
2021-11-21 17:40:48 +01:00
Sylvain
70c8d20a46
Revert previous commit a50ca98e2b
(see bug #4625 )
2021-11-13 15:04:19 +01:00
Sylvain
a50ca98e2b
Fixed bug #4625 - SDL_RenderSetLogicalSize issues
...
viewport becomes -2147483648x-2147483648 when logical_w/h is greater than window size.
division should be done with floats
2021-11-13 14:48:36 +01:00
Sam Lantinga
6c4b4ee7a6
Don't assert on API parameters
...
This causes lots of spam in test automation and it's not clear it's useful to developers. If we need this level of validation, we should add a log category for it.
2021-11-10 09:41:43 -08:00
Eric Wasylishen
0d98793693
testwm2: Fix video modes menu hit detection when highdpi or logical size used ( #4936 )
...
* SDLTest_CommonDrawWindowInfo: log SDL_RenderGetScale, SDL_RenderGetLogicalSize
* testwm2: fix video modes menu hit detection in High DPI cases
- also when logical size is specified, e.g.
`--logical 640x480 --resizable --allow-highdpi`
* add function to determine logical coordinates of renderer point when given window point
* change since to the targeted milestone
* fix typo
* rename for consistency
* Change logical coordinate type to float, since we can render with floating point precision.
* add function to convert logical to window coordinates
* testwm2: use new SDL_RenderWindowToLogical
* SDL_render.c: alternate SDL_RenderWindowToLogical/SDL_RenderLogicalToWindow
Co-authored-by: John Blat <johnblat64@protonmail.com>
Co-authored-by: John Blat <47202511+johnblat64@users.noreply.github.com>
2021-11-09 21:03:42 -08:00
Sylvain
4960cc3dcb
Fixed a few warnings
2021-10-25 16:18:40 +02:00
Sylvain
b793394590
SDL_Renderer: make clear that we use render geometry for fillrect/copy/copyex when there is no specific back-end implementation (currently software, PSP, directfb)
2021-10-25 13:46:40 +02:00
Sylvain
502e9c3b45
SDL_Renderer simplifications:
...
- Factorize PrepQueueCmdDraw{,DrawTexture,Solid) into one single function
- Change SDL_Texture/Renderer r,g,b,a Uint8 into an SDL_Color, so that it can be passed directly to RenderGeometry
- Don't automatically queue a SET_DRAW_COLOR cmd for RenderGeometry (and update GLES2 renderer)
2021-10-24 22:27:56 -04:00
Sylvain
70b10c753d
Use correct indices when using RenderGeometry / FillRects
2021-10-24 22:27:56 -04:00
Sylvain
16beed9aeb
Less code since color is constant when done with triangles
2021-10-24 22:27:56 -04:00
Sylvain
37c39d5cb4
Use geometry to implement FillRects
2021-10-24 22:27:56 -04:00
Sylvain
76f9fb96d9
Use RenderGeometry to implement RenderCopy and RenderCopyEx at higher level
2021-10-24 22:27:56 -04:00
Sylvain
77acd44f28
DirectFB: fixed creation of palette textures
2021-10-01 22:30:51 +02:00
Ryan C. Gordon
857cc7c0c9
render: constified some local variables in SDL_AllocateRenderVertices.
2021-09-19 00:38:06 -04: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
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
be6bee0b5a
SW_RenderGeometry: add a redundant check to clear static analysis (see bug #4600 )
2021-08-27 07:47:28 +02:00
Sylvain
b17aa5d080
SW_RenderGeometry: remove a few static analysis false positives (see bug #4600 )
2021-08-27 07:16:40 +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
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
6e47f53869
Fix warnings
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
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
f73c1eff10
Use normalized texture coordinates
2021-08-19 00:10:59 +02:00
Sylvain
6e26d320c6
Add sysrender interface
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
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