Can SDL_RenderSetLogicalSize overscan instead of letterbox?

Can SDL_RenderSetLogicalSize be set to overscan (expand to fill the
entire screen, even if some parts draw off the screen) instead of
letterbox?

My use case is that I’ve designed for a wide-screen aspect ratio (e.g.
16:9), but now I would like to improve the experience on
non-widescreens like the iPad (4:3). The game is already designed to
have non-playable areas on the edges, so it won’t be a problem if some
of the edges are drawn off the edge of the screen. I don’t like losing
so much real-estate to letterboxing. (Also, I don’t remember what
Apple’s rules were about approving iPad apps that letterbox).

Thanks,
Eric–
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

No need for SDL_RenderSetLogicalSize at all. Your scene can be drawn to a
rendertarget & scaled & blit with X&Y offsets. Calculate the values of
those offsets depending on the screen size.On Tue Dec 02 2014 at 11:31:02 AM Eric Wing wrote:

Can SDL_RenderSetLogicalSize be set to overscan (expand to fill the
entire screen, even if some parts draw off the screen) instead of
letterbox?

My use case is that I’ve designed for a wide-screen aspect ratio (e.g.
16:9), but now I would like to improve the experience on
non-widescreens like the iPad (4:3). The game is already designed to
have non-playable areas on the edges, so it won’t be a problem if some
of the edges are drawn off the edge of the screen. I don’t like losing
so much real-estate to letterboxing. (Also, I don’t remember what
Apple’s rules were about approving iPad apps that letterbox).

Thanks,
Eric

Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/


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

But SDL_RenderSetLogicalSize is soo nice and convenient…it seems to
always do the right thing (sans overscan) including with window
resizes and fullscreen toggle without any fuss.

So instead of me doing this work in each of my own apps, what would be
involved in enhancing SDL to do this for everybody?

I’m glancing at the source code. I’m thinking I just need to modify
UpdateLogicalSize() in SDL_render.c.

And to select this alternative behavior, I should add a new Hint. SDL
already has:
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, “linear”);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, “nearest”);

How about:
SDL_SetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE, “letterbox”); // default
SDL_SetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE, “overscan”);

Thanks,
EricOn 12/1/14, Pallav Nawani wrote:

No need for SDL_RenderSetLogicalSize at all. Your scene can be drawn to a
rendertarget & scaled & blit with X&Y offsets. Calculate the values of
those offsets depending on the screen size.


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

I am sure that could be done, however there are 2 reasons I prefer render
target approach:

  1. If you use SDL_RenderSetLogicalSize(), each texture is scaled while
    blitting (linear or nearest). That can cause white or black bands to occur
    in the textures.
  2. If you are already rendering your scene to a render target, then you can
    zoom the scene easily, and you can blend between two scenes.
    So it is a trade off: You use extra VRAM for render texture, and you get a
    lot of convenience :slight_smile:

Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768On Wed, Dec 3, 2014 at 7:31 AM, Eric Wing wrote:

On 12/1/14, Pallav Nawani <@Pallav_Nawani> wrote:

No need for SDL_RenderSetLogicalSize at all. Your scene can be drawn to
a
rendertarget & scaled & blit with X&Y offsets. Calculate the values of
those offsets depending on the screen size.

But SDL_RenderSetLogicalSize is soo nice and convenient…it seems to
always do the right thing (sans overscan) including with window
resizes and fullscreen toggle without any fuss.

So instead of me doing this work in each of my own apps, what would be
involved in enhancing SDL to do this for everybody?

I’m glancing at the source code. I’m thinking I just need to modify
UpdateLogicalSize() in SDL_render.c.

And to select this alternative behavior, I should add a new Hint. SDL
already has:
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, “linear”);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, “nearest”);

How about:
SDL_SetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE, “letterbox”); // default
SDL_SetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE, “overscan”);

Thanks,
Eric

Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/


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

FYI, I want to reimplement the logical size functionality with a render
target in SDL 2.1.On Tue, Dec 2, 2014 at 6:37 PM, Pallav Nawani wrote:

I am sure that could be done, however there are 2 reasons I prefer render
target approach:

  1. If you use SDL_RenderSetLogicalSize(), each texture is scaled while
    blitting (linear or nearest). That can cause white or black bands to occur
    in the textures.
  2. If you are already rendering your scene to a render target, then you
    can zoom the scene easily, and you can blend between two scenes.
    So it is a trade off: You use extra VRAM for render texture, and you get a
    lot of convenience :slight_smile:

Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768

On Wed, Dec 3, 2014 at 7:31 AM, Eric Wing wrote:

On 12/1/14, Pallav Nawani wrote:

No need for SDL_RenderSetLogicalSize at all. Your scene can be drawn
to a
rendertarget & scaled & blit with X&Y offsets. Calculate the values of
those offsets depending on the screen size.

But SDL_RenderSetLogicalSize is soo nice and convenient…it seems to
always do the right thing (sans overscan) including with window
resizes and fullscreen toggle without any fuss.

So instead of me doing this work in each of my own apps, what would be
involved in enhancing SDL to do this for everybody?

I’m glancing at the source code. I’m thinking I just need to modify
UpdateLogicalSize() in SDL_render.c.

And to select this alternative behavior, I should add a new Hint. SDL
already has:
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, “linear”);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, “nearest”);

How about:
SDL_SetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE, “letterbox”); // default
SDL_SetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE, “overscan”);

Thanks,
Eric

Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/


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


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

Okay, I made a patch for this, posted the repo, and submitted a bug:
https://bugzilla.libsdl.org/show_bug.cgi?id=2799

Submission body copied below.

Thanks,
Eric========

Adds support to control the scaling policy/mode of
SDL_RenderSetLogicalSize for both letterbox (current behavior) and a
new overscan mode (expan
d to fill the entire screen, even if some parts draw off the screen).

The expected use case is for games that are designed with multiple
aspect ratios already in mind and leave optional margins on the edges
of the game which won’t hurt if they are cut off.

An example use case is a game is designed for wide-screen/16:9, but
then wants to deploy on an iPad which is 4:3. Normally, SDL will
letterbox, which will shrink things and result in wasted space. But
the designer already thought about 4:3 and designed the edges of the
game so they could
be cut off without any functional loss. So rather than wasting space
with letterboxing, “overscan” mode will zoom the rendering to fill up
the
entire screen. Parts on the edges will be drawn offscreen, but since
the game was already designed with this in mind, it is fine. The end
result
is the iPad (4:3) experience is much better since it feels like a
game designed for that screen aspect ratio.

This patch introduces a new SDL_hint: SDL_HINT_RENDER_LOGICAL_SIZE_MODE.
Valid values are “letterbox” or “0” for letterboxing and “overscan” or
"1" for overscan.
The default mode is letterbox to preserve existing behavior.

// Example usage:
SDL_SetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE, “overscan”);
SDL_RenderSetLogicalSize(renderer, SCREEN_WIDTH, SCREEN_HEIGHT);

// Sample picture of Letterbox:

// Sample picture of Overscan:

The patch repository:

Good work, very nice! I look forward to giving this new feature a try in the future. I have a game that utilizes the logical viewport and may be able to benefit from overscan on iOS, if I ever port over to it.

Cheers,
Jeffrey Carpenter <@Jeffrey_Carpenter>

-------------- next part --------------
A non-text attachment was scrubbed…
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1572 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20141203/c2b2e019/attachment-0001.bin

Thanks! I hope many others will benefit.

It also works well for desktop windowed mode when you allow users to
resize their windows. (And also if you have monitors with different
aspect ratios. And possibly if you test in a VM that allows desktop
resizing.)

Thanks,
EricOn 12/3/14, Jeffrey Carpenter wrote:

Good work, very nice! I look forward to giving this new feature a try in the
future. I have a game that utilizes the logical viewport and may be able to
benefit from overscan on iOS, if I ever port over to it.

Cheers,
Jeffrey Carpenter


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

Eric, you did a good job with this feature.

How easy would it be to add another value that sizes to fit? “scale” or “sizetofit”. I have need of it and the only way I can achieve what I want is to instead use SDL_RenderSetScale(renderer, (float)pixelW / logicalW, (float)pixelH / logicalH); which works, but using SDL_HINT_RENDER_LOGICAL_SIZE_MODE would make more sense?

Thanks :slight_smile: