src/render/SDL_render.c


Log

Author Commit Date CI Message
pionere 6d5592a2 2022-02-05T12:02:54 minor cleanup of SDL_CreateRenderer
pionere ebdd5366 2022-01-17T16:26:02 use SDL_InvalidParamError or SDL_assert instead of custom SDL_SetError
Sam Lantinga a29d3acc 2022-01-09T11:11:34 Updated Bresenham line drawing to match software renderer output
Sam Lantinga 1f32dd8e 2022-01-09T06:36:18 Fixed overdraw with duplicate points, fixed not drawing single point lines
Sam Lantinga 3b083b99 2022-01-08T14:07:42 Fixed compile warning
Sam Lantinga 4ef2529b 2022-01-08T12:37:57 More efficient calculation of render_count
Sam Lantinga 5346c93b 2022-01-08T12:28:43 Fixed assertion on number of points rendered
Sam Lantinga 4b719620 2022-01-08T12:02:08 Prevent overdraw with connected line segments
Sam Lantinga 09ece861 2022-01-08T11:36:29 Added the hint SDL_HINT_RENDER_LINE_METHOD to select the line rendering method
Sam Lantinga c1e60798 2022-01-08T11:09:11 As an optimization, draw horizontal and vertical lines using rectangles
Sam Lantinga 3da7c630 2022-01-08T11:07:03 Assert that we have drawn the expected number of points
Sam Lantinga 9f56faee 2022-01-08T10:59:31 Added line drawing using Bresenham's line algorithm (thanks @rtrussell!)
Sam Lantinga fe3a33a0 2022-01-08T10:10:18 Use RenderGeometry for drawing lines at all scales
Sam Lantinga 1694782b 2022-01-08T09:32:23 Remove redundant work when render scale is 1.0
Sam Lantinga 2026a78d 2022-01-08T09:23:58 Don't flush in RenderDraw*WithRects() This allows these functions to be reused in the future for other primitives
Ryan C. Gordon cc201337 2022-01-07T20:20:57 render: Fixed some compiler warnings. Fixes #5197.
Sylvain 8ea8b2e6 2022-01-07T22:42:13 Use QueueDrawLine if provided, otherwise use RenderGeometry
Sylvain Becker c4987274 2022-01-07T22:14:28 render: Use RenderGeometry to draw lines This patch is from @1bsyl Fixes #5061.
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Sylvain 3d5fcb5d 2021-12-16T11:10:07 Fix warning
Sylvain 4342e6bd 2021-12-16T10:53:27 SDL_render.c: lighten the cast syntax
Alex Szpakowski 3a5e148b 2021-12-14T11:02:07 Renderer backends use SDL_Color instead of int for geometry colors.
Sylvain b7885abc 2021-12-14T10:31:55 Fixed bug #5087: SDL_RenderGeometryRaw() passes colors as int* instead of SDL_Color*
Sylvain 8927d73b 2021-12-12T09:55:23 RenderGeometry: simplify casting (Thanks Daniel Gibson)
Sylvain 3e43d6e3 2021-12-11T17:19:00 SDL_RenderGeometry: remove some warning "dereferencing type-punned pointer might break strict-aliasing"
Sylvain d09f80ef 2021-12-07T11:31:57 SDL_DrawPointsF: fix error message typo
Sylvain 6dafc850 2021-12-07T10:44:12 SDL_DrawLines: minor simpification: - scale is 1.0f, don't need to multiply - typo in error message - remap SDL_DrawLines to SDL_DrawLinesF
Sylvain a0818a63 2021-12-07T10:07:15 Fixed bug #5071 - Float conversion warnings in SDL_render.c (see also #5003)
Sylvain e14d1026 2021-11-26T13:12:22 Change viewport and cliprect to float version: from SDL_Rect to SDL_FRect
Ozkan Sezer e18be04b 2021-11-23T08:01:02 Fixed undefined behavior in QueueCmdSetDrawColor() Fixes https://github.com/libsdl-org/SDL/issues/4995 Patch from Andrew Kelley
Sylvain 161dd83c 2021-11-22T11:15:23 DonĀ“t use "trunc" as var name, since it's also a function
Sylvain 49369142 2021-11-21T17:40:48 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
Sylvain 70c8d20a 2021-11-13T15:04:19 Revert previous commit a50ca98e2b9ca10368b62e93b6a0977dc68fd584 (see bug #4625)
Sylvain a50ca98e 2021-11-13T14:48:36 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
Sam Lantinga 6c4b4ee7 2021-11-10T09:41:43 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.
Eric Wasylishen 0d987936 2021-11-09T22:03:42 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>
Sylvain 4960cc3d 2021-10-25T16:18:40 Fixed a few warnings
Sylvain b7933945 2021-10-25T13:46:40 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)
Sylvain 502e9c3b 2021-10-24T17:16:49 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)
Sylvain 70b10c75 2021-09-24T22:39:49 Use correct indices when using RenderGeometry / FillRects
Sylvain 16beed9a 2021-09-24T17:09:04 Less code since color is constant when done with triangles
Sylvain 37c39d5c 2021-09-23T22:45:45 Use geometry to implement FillRects
Sylvain 76f9fb96 2021-09-20T16:32:08 Use RenderGeometry to implement RenderCopy and RenderCopyEx at higher level
Sylvain 77acd44f 2021-10-01T22:30:51 DirectFB: fixed creation of palette textures
Ryan C. Gordon 857cc7c0 2021-09-19T00:05:21 render: constified some local variables in SDL_AllocateRenderVertices.
Misa 4a994733 2021-09-14T15:51:17 `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.
Misa 4549769d 2021-03-07T15:20:45 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.
Ryan C. Gordon d49d955d 2021-09-08T11:44:17 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.)
Sylvain be6bee0b 2021-08-27T07:47:28 SW_RenderGeometry: add a redundant check to clear static analysis (see bug #4600)
Sylvain b17aa5d0 2021-08-27T07:16:40 SW_RenderGeometry: remove a few static analysis false positives (see bug #4600)
Ozkan Sezer 8270172e 2021-08-19T12:11:10 fix -Wshorten-64-to-32 warnings in android builds. see: https://github.com/libsdl-org/SDL/pull/4195#issuecomment-901506386
Sylvain 1670104a 2021-04-23T12:27:35 Change 'size_indice' to 'size_indices'
Sylvain a8f89a01 2021-04-23T12:00:14 Change 'size_indice' to 'size_indices'
Sylvain 47db47c1 2021-04-06T21:32:02 Add SDL_HAVE_RENDER_GEOMETRY to compile or not with RenderGeometry support
Sylvain 6e47f538 2021-04-01T20:18:05 Fix warnings
Sylvain 4ba37638 2021-04-01T12:43:39 Save and restore SDL renderer state after transforming triangles to rect
Sylvain cd0663e0 2021-04-01T11:47:45 Fix declaration-after-statement and remove tabs
Sylvain 61d9e916 2021-04-01T10:16:27 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
Sylvain cc37c38e 2021-04-01T09:55:00 Add SDL_RenderGeometry based on SDL_RenderGeometryRaw
Sylvain e4812611 2021-04-01T09:49:16 Move to SDL_RenderGeometryRaw prototype with separate xy/uv/color pointer parameters
Sylvain f73c1eff 2021-03-17T09:58:49 Use normalized texture coordinates
Sylvain 6e26d320 2021-03-16T15:09:34 Add sysrender interface
Sam Lantinga f5794f9e 2021-08-10T15:17:59 Added SDL_SetTextureUserData() and SDL_GetTextureUserData() to associate a user-specified pointer with an SDL texture
Sam Lantinga fcfd19db 2021-08-10T12:02:17 Added support for SDL_RENDERER_PRESENTVSYNC to the software renderer This fixes https://github.com/libsdl-org/SDL/issues/4612
David Gow 4077f7a2 2021-08-03T20:55:45 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.
David Gow 8f06a629 2021-07-30T22:31:17 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.
Ivan Epifanov dd2a2858 2021-06-10T12:00:56 Remove leftovers
Sylvain e87c7940 2021-04-13T14:42:38 Fixed bug 3829 - Don't FOURCC format for target textures FOURCC isn't supported by renderer back-ends for target access So use a correct format and fallback to with native/yuv path
Ryan C. Gordon 57c2a456 2021-04-02T14:01:41 render: draw when hidden, except on iOS and Android. Fixes #2979.
Vanfanel e14fb54e 2021-03-16T10:47:57 [KMSDRM] Undo SDL_CreateRenderer() modifications aimed at create opengles2 when KMSDRM is in use because it's a harmful solution.
Vanfanel 108bb5aa 2021-03-16T00:51:17 [KMSDRM] Modify SDL_CreateRenderer() to create an opengles2 renderer when the KMSDRM backend is being used and no renderer name has been specified.
Ivan Epifanov 6c3bf565 2020-11-23T12:44:54 Unified build with both renderers
Ivan Epifanov 6ba84975 2020-11-21T23:04:27 Remove vita2d render, add raw gxm render
Ivan Epifanov ef0bbfd6 2020-11-16T20:40:22 Include anf fix vita2d renderer
Ivan Epifanov dbb730d3 2020-11-14T23:37:26 Separate vita piglet renderer. Add proper render initialization and window re-creation.
Sylvain Becker 70b353d1 2021-01-27T10:54:49 SDL_Update{YUV,NV}Texture: also intersect rect with texture dimension
Sylvain Becker 13626c36 2021-01-27T10:20:13 SDL_UpdateTexture: intersect update rect with texture dimension - fix crash with software renderer - fix non texture update with opengl/gles2
Sylvain Becker be4cfd51 2021-01-05T11:56:22 Add SDL_UpdateNVTexture() to update NV12/21 Texture (bug #5430) for renderer software, opengl, and opengles2
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sylvain Becker 3edf337d 2021-01-02T17:29:34 Simplify RenderGetViewportSize
Sylvain Becker 2af765da 2021-01-02T17:18:13 SDL_RenderGetViewportF: only need the size of viewport (see bug #5424)
Sylvain Becker 41597249 2021-01-02T16:15:22 SDL_RenderGetViewportF: remove debug messages
Sylvain Becker 8c48c423 2021-01-02T16:12:30 Add SDL_RenderGetViewportF: fix lost of precision while scaling (see bug #5424)
Sylvain Becker 590a5469 2020-12-30T16:12:14 Fixed bug 5424 - Renderer doesn't use entirely the viewport when scaling is used Viewport/Clip dimensions are calculated usingg SDL_ceil whereas all renders use SDL_floor
Sylvain Becker 5dabc4d7 2020-12-28T18:17:25 Revert changeset 14590 544ac819e8b3 , does not fully fix
Sylvain Becker 9efdafd4 2020-12-28T18:07:03 SDL_RenderCopy: scale before doing intersection this prevents drawing 1 pixel outside the screen, in letterbox mode
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Sam Lantinga 88cb4962 2020-12-09T06:42:31 Fixed bug 5291 - SDL_SetRenderTarget unnecessarily changes target when current target is the native texture of the passed in texture
Ryan C. Gordon a720d1a2 2020-08-09T00:55:39 render: fixes to how we convert touch events for logical scaling. We now handle HiDPI correctly, and touches are clamped to the viewport. So if you are rendering to a logical 640x480 in a 720p window, and touch the letterboxing at point (640,700), it will report the touch at (0.5,1.0) instead of outside the documented range.
Sylvain Becker 39690a04 2020-05-15T21:33:47 Fix static analysis warning in SDL_render.c
Ryan C. Gordon a96d8a43 2020-04-13T22:05:36 render: Fixed compiler warning about implicit cast.
hmk aa188048 2020-04-10T12:23:08 render: Scale relative mouse motion better for logical sizing From hmk: "When scaling is enabled (e.g. via SDL_RenderSetLogicalSize, size not equal to window size), mouse motion events are also scaled. Small motions are rounded up (SDL_max() when the value after scaling is less than 1), while larger motions are truncated by the floating point -> integer conversion. https://hg.libsdl.org/SDL/file/b18197f9bf9d/src/render/SDL_render.c#l658 The end result feels something like mouse reverse mouse acceleration + angle snapping at low speeds, but less consistent (amount of truncation & rounding depends on how fast the mouse is moved) and potentially much worse if the scaling factor is large. This pretty much makes it useless for anything where you need precise mouse aiming (think of games). I suspect this is why aiming gets so terrible in some games that let you use scaling to reduce the render resolution (e.g. Ion Fury). With 4x4 scaling, I can reproduce a situation where it takes three fast flicks of the mouse across the pad to undo one slow sweep across the pad. In other words, extreme reverse acceleration. This does not happen when scaling is disabled. Furthermore, any game that uses relative mouse motion events for 3D camera rotation probably wants the raw mouse deltas and not a value that depends on scaling and resolution and rounding and truncation. Ideal camera rotation just takes mouse input, multiplies it by sensitivity, and adds it to the angle-in-radians or whatever measure is used for yaw & pitch. Pixels and screen resolution or window dimensions should not be a part of the equation at all, even if it could be implemented without rounding errors. [...] This [patch] completely eliminates angle snapping for me, and makes sensitivity consistent. In other words, it's completely usable for, say, aiming in a first person shooter." Partially fixes Bugzilla #4811.
Sam Lantinga b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
Sylvain Becker e6189f40 2020-03-17T15:47:30 Fix warnining implicit declaration of SDL_DetectPalette (Thanks meyraud705)
Sylvain Becker 838bbf1f 2020-03-17T09:35:42 Fixed bug 5037 - Regression 2.0.12 Alpha value of 0 on palette may become opaque (see also bug 3827)
Sylvain Becker 9a7c2b22 2020-02-23T09:59:52 Fixed bug 4999 - Palette surface always promoted to alpha (Thanks Cameron Gutman!) MSVC Static analysis: Incorrect alpha_value check in SDL_render.c (see also bug 4425)
Sam Lantinga b5e3d264 2020-01-23T01:00:52 Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds Protected more code with #ifdefs to reduce the size of minimal shared library builds
Sylvain Becker 7df22cf2 2020-01-21T21:33:40 A few #defines to reduce SDL2 footprint. Only applied when library is statically linked
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 981e0d36 2020-01-16T08:52:59 Fixed bug 4903 - Lack of color multiply with alpha (SDL_BLENDMODE_MOD + SDL_BLENDMODE_BLEND) blending mode for all renderers Konrad This kind of blending is rather quite useful and in my opinion should be available for all renderers. I do need it myself, but since I didn't want to use a custom blending mode which is supported only by certain renderers (e.g. not in software which is quite important for me) I did write implementation of SDL_BLENDMODE_MUL for all renderers altogether. SDL_BLENDMODE_MUL implements following equation: dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)) dstA = (srcA * dstA) + (dstA * (1-srcA)) Background: https://i.imgur.com/UsYhydP.png Blended texture: https://i.imgur.com/0juXQcV.png Result for SDL_BLENDMODE_MOD: https://i.imgur.com/wgNSgUl.png Result for SDL_BLENDMODE_MUL: https://i.imgur.com/Veokzim.png I think I did cover all possibilities within included patch, but I didn't write any tests for SDL_BLENDMODE_MUL, so it would be lovely if someone could do it.