SDL_RenderCopy() doesn't downscale textures when a srcrect is passed

Hi all,

I am using SDL_RenderCopy() in my game. The function prototype is this:

int SDL_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture,
const SDL_Rect* srcrect, const SDL_Rect* dstrect)

I use dstrect to downscale the texture. It works fine as long as I pass
NULL as srcrect, but as soon as I use a srcrect, then the downscaling is
not applied anymore, and the texture is simply truncated…

Is it a bug? Or some undocumented behavior of SDL? Any idea how could I
make it downscale textures when using a srcrect?

best regards,
Mateusz

Maybe I am missing something, and SDL_RenderCopy() isn’t supposed to
downscale at all?

In the SDL wiki I read:
“dstrect: the destination SDL_Rect structure or NULL for the entire
rendering target. The texture will be stretched to fill the given
rectangle.”

I always assumed that “stretched” implied that if dstrect is smaller,
then the texture will be scaled down. And that’s what I get as long as I
pass NULL to srcrect.

But when I use a non-NULL srcrect, then the texture is only stretched
when the dstrect is larger than the texture. If dstrect is smaller than
the texture, then the texture is truncated instead of being scaled down.

I’d say this smells like a bug, because I think the scaling behavior
should be consistent with and without srcrect… but again, maybe I
missed something obvious?

Any hints would be welcome :slight_smile:

regards,
MateuszOn 04/26/2014 06:40 PM, Mateusz Viste wrote:

Hi all,

I am using SDL_RenderCopy() in my game. The function prototype is this:

int SDL_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture,
const SDL_Rect* srcrect, const SDL_Rect* dstrect)

I use dstrect to downscale the texture. It works fine as long as I pass
NULL as srcrect, but as soon as I use a srcrect, then the downscaling is
not applied anymore, and the texture is simply truncated…

Is it a bug? Or some undocumented behavior of SDL? Any idea how could I
make it downscale textures when using a srcrect?

best regards,
Mateusz


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

It sounds like a bug. Can you report it on bugzilla with a minimal test
case?
http://bugzilla.libsdl.org/

Thanks!On Sat, Apr 26, 2014 at 9:40 AM, Mateusz Viste wrote:

Hi all,

I am using SDL_RenderCopy() in my game. The function prototype is this:

int SDL_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture, const
SDL_Rect* srcrect, const SDL_Rect* dstrect)

I use dstrect to downscale the texture. It works fine as long as I pass
NULL as srcrect, but as soon as I use a srcrect, then the downscaling is
not applied anymore, and the texture is simply truncated…

Is it a bug? Or some undocumented behavior of SDL? Any idea how could I
make it downscale textures when using a srcrect?

best regards,
Mateusz


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

1 Like

Hi,

When doing a minimal test case I found it was all caused by a bug in my
game :confused: I’m sorry for this false alarm - I should have tested it on a
simple test case in the first place. SDL_RenderCopy() is downscaling
textures correctly.

best regards,
MateuszOn 04/26/2014 09:22 PM, Sam Lantinga wrote:

It sounds like a bug. Can you report it on bugzilla with a minimal test
case?
http://bugzilla.libsdl.org/

Thanks!

On Sat, Apr 26, 2014 at 9:40 AM, Mateusz Viste <mateusz at viste-family.net <mailto:mateusz at viste-family.net>> wrote:

Hi all,

I am using SDL_RenderCopy() in my game. The function prototype is this:

   int SDL_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture,
const SDL_Rect* srcrect, const SDL_Rect* dstrect)

I use dstrect to downscale the texture. It works fine as long as I
pass NULL as srcrect, but as soon as I use a srcrect, then the
downscaling is not applied anymore, and the texture is simply
truncated...

Is it a bug? Or some undocumented behavior of SDL? Any idea how
could I make it downscale textures when using a srcrect?

best regards,
Mateusz