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 - SDL_RenderCopy will not copy a zero-width or zero-height rectangle
Summary: SDL_RenderCopy will not copy a zero-width or zero-height rectangle
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86_64 Linux
: P2 trivial
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-11 22:07 UTC by Solra Bizna
Modified: 2017-09-11 22:07 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.