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 4901

Summary: BUG: in SDL_SetRenderTarget(SDL_TEXTUREACCESS_TARGET)
Product: SDL Reporter: Marcel Bakker <mna.bakker>
Component: renderAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sylvain.becker
Version: 2.0.10   
Hardware: All   
OS: All   
Attachments: test-case to dump value

Description Marcel Bakker 2019-12-17 14:33:15 UTC
logical_w/h not being set to it's default value

    if (texture) {
        ...
-        renderer->logical_w = texture->w;
-        renderer->logical_h = texture->h;
+        renderer->logical_w = 0;
+        renderer->logical_h = 0;
    } else {
        ...
    }
Comment 1 Sylvain 2019-12-18 06:24:04 UTC
https://hg.libsdl.org/SDL/rev/2d2fd56db9b7
Comment 2 Sylvain 2019-12-18 06:31:57 UTC
and before that, this was added here:
https://hg.libsdl.org/SDL/rev/008057dcc079
Comment 3 Marcel Bakker 2019-12-18 13:10:30 UTC
patch: https://hg.libsdl.org/SDL/rev/2d2fd56db9b7
says: The SDL_RenderGetLogicalSize function should always return the amount of pixels that are currently available for rendering to.

This is wrong imo, we have SDL_GetRendererOutputSize to return the amount of pixels that are currently available.

SDL_RenderGetLogicalSize should only return some value, if a logical size has been set by the user.
Also, the default-target renderer does set its logical_w/h to 0 by default.
Comment 4 Sylvain 2019-12-18 15:03:13 UTC
I agree, it also seems to me logical_w/h could be set to 0.

In fact, logical_w/h seems has no purpose with texture target.
logical_w/h is used for scaling events, with the real target.
Comment 5 Marcel Bakker 2019-12-18 20:22:09 UTC
I also see that mouse and finger events are only being corrected by SDL when a logical size has been set on the default target.
But draw and copy functions will still use the logical size set on a texture target. [combination of viewport + scale]

I am looking at this from a 3rd party library POV
that wants to preserve user made settings for a texture target [logical,viewport,scale,clip]
before using SDL on a different texture target internally

you make it sound like there is no use-case for having set a logical-size on a texture-target.
As a 3rd party, i must assume there is, because SDL has the option to set it on either the default or texture target.
But if this is not suppose to happen in SDL, then maybe remove the option from the texture and force it on the default target?
Comment 6 Sylvain 2019-12-19 10:49:27 UTC
Created attachment 4118 [details]
test-case to dump value

Just adding a test-case to help dumping the values.

I think the first version was ok. (eg setting logical_w/h to 0,0).
because as you said, normal renderer also has logical_w/h set to 0,0 at creation.
It shouldn't have been reverted back in 2013.

But by dumping the value: it seems setting the texture w/h is also coherent with the scale of (1,1) and with the viewport values. It's also no affected by using overscan/letterbox. So this seems also fine to me: when using a target texture, the logical size is set to the texture w/h. 
Changing it would can also break existing users ?


Moreover, maybe we should update the renderer to have a valid logical w/h ?
(but that would make the renderer also do a dummy re-scaling for events)

Maybe other maintainers has an idea about it ?