-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
This bug report was migrated from our old Bugzilla tracker.
Reported in version: 2.0.3
Reported for operating system, platform: Windows 7, x86_64
Comments on the original bug report:
On 2015-02-18 17:15:43 +0000, MikeyPro wrote:
Animated sprite frame rectangles will sometimes "bleed" or "overlap" into other frames due to the open gl renderer's RenderCopy function using floats instead of integers to calculate source rectangles for textures. Since no users can actually send floats to RenderCopy (on the outside, programmers can only use SDL_Rect which is int only) I would suggest to lock in using integers only and use the integer forms of the opengl functions to draw the texture. I'm not sure how the other renderers work, some of them may also need fixing.
I checked the latest online sources and this is where the problem is coded in:
Source file: SDL_render_gl.c
Starting around line: 1209NOTE: For my testing, this only affects me in windowed mode on windows 7. In fullscreen, there is no bleed, but there is still potential for it to happen with the right settings. This comes down to the pixel ratio being a perfect fit in fullscreen, but not windowed. I tested windowed in an 800x600 window on a 1768x996 desktop and always use desktop resolution in fullscreen with logical resolution of 320x240 for both modes.
This is also discussed in the forum topic https://forums.libsdl.org/viewtopic.php?t=10945
On 2015-02-19 15:53:24 +0000, MikeyPro wrote:
I did some more testing, when I use SDL_Hint to set linear quality, almost all textures end up bleeding in both windowed mode and fullscreen mode using the opengl renderer.
On 2015-02-19 17:44:54 +0000, Alex Szpakowski wrote:
This isn't really something that's caused by SDL's code. Rotating a sprite will still cause texture bleeding if the texels next to the sprite in the texture atlas are different, due to the way GPUs rasterize geometry and sample from textures.
The best way to prevent sprite bleeding in texture atlases is to add a 1px extrusion to each sprite in the texture atlas (i.e. duplicate the pixels at the edges of each sprite.)
Sprite packing tools such as TexturePacker and ShoeBox can do this for you automatically.
http://www.matim-dev.com/texture-packer---get-rid-of-sprite-artefacts.html
https://www.codeandweb.com/texturepacker/documentation#spritesIf you use raw OpenGL and you target OpenGL 3+ or OpenGL ES 3+, you could use Array Textures instead of texture atlases. SDL_Render wouldn't be able to do that internally because you feed individual sprites as layers to Array Textures, rather than using a large atlas texture.
On 2015-02-19 18:59:03 +0000, MikeyPro wrote:
I want to argue, but I wont because I'm wrong. I am really pissed this is how it must be done due to inaccuracies in underlying systems. I am setting this bug as resolved invalid. Thank you for the reply, Alex.