We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3820

Summary: SDL_RenderCopy will not copy a zero-width or zero-height rectangle
Product: SDL Reporter: Solra Bizna <solrabizna>
Component: videoAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: trivial    
Priority: P2    
Version: HG 2.0   
Hardware: x86_64   
OS: Linux   

Description Solra Bizna 2017-09-11 22:07:53 UTC
Made-up example:

// renderer is a 300x200 renderer
// texture is a 64x64 button graphic or something
SDL_Rect src, dst;
// scale the left half of src up onto the left side of the screen
src.x = 0;
src.y = 0;
src.w = 32;
src.h = 64;
dst.x = 0;
dst.y = 0;
dst.w = 100;
dst.h = 200;
SDL_RenderCopy(renderer, texture, &src, &dst);
// scale the right half of src up onto the right side of the screen
src.x = 32;
src.y = 0;
src.w = 32;
src.h = 64;
dst.x = 200;
dst.y = 0;
dst.w = 100;
dst.h = 200;
SDL_RenderCopy(renderer, texture, &src, &dst);
// fill in the in-between space
src.x = 32;
src.y = 0;
src.w = 0;
src.h = 64;
dst.x = 100;
dst.y = 0;
dst.w = 100;
dst.h = 200;
SDL_RenderCopy(renderer, texture, &src, &dst);

The third SDL_RenderCopy does nothing. Ideally, it would fill the space between the left and right halves on the screen with the "column" directly between the left and right halves of the source image.

An easy workaround, that almost always works IN PRACTICE, is to use a one pixel width or height instead of a zero pixel one, and adjust the source image if needed. Hence me setting the severity to "trivial". In fact, I spent more time writing this report than I spent working around the problem in my actual code. Later, when I actually do *need* to display a zero-pixel-wide source region, I'll already be using OpenGL for other reasons, so it won't matter what SDL does.