Can SDL_RenderSetLogicalSize overscan instead of letterbox? |
Eric Wing
Guest
|
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 http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
Can SDL_RenderSetLogicalSize overscan instead of letterbox? |
Pallav Nawani
|
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 overscan instead of letterbox? |
Eric Wing
Guest
|
On 12/1/14, Pallav Nawani wrote:
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 http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Can SDL_RenderSetLogicalSize overscan instead of letterbox? |
Pallav Nawani
|
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 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:
|
|||||||||||||||
|
Can SDL_RenderSetLogicalSize overscan instead of letterbox? |
Sam Lantinga
|
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:
|
|||||||||||||||||
|
Can SDL_RenderSetLogicalSize overscan instead of letterbox? |
Eric Wing
Guest
|
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: https://lh6.googleusercontent.com/-rtqElN4-CF0/VH8GADmxZZI/AAAAAAAAANQ/dgswJ5FgylM/w613-h460-no/Screen%2BShot%2B2014-12-03%2Bat%2B4.26.06%2BAM.png // Sample picture of Overscan: https://lh3.googleusercontent.com/-z3rO1IJ5Lus/VH8GErpA6iI/AAAAAAAAANY/8Si3goEYnYw/w613-h460-no/Screen%2BShot%2B2014-12-03%2Bat%2B4.22.40%2BAM.png The patch repository: https://bitbucket.org/ewing/sdl_overscan _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
Can SDL_RenderSetLogicalSize overscan instead of letterbox? |
i8degrees
|
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 _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
Can SDL_RenderSetLogicalSize overscan instead of letterbox? |
Eric Wing
Guest
|
On 12/3/14, Jeffrey Carpenter wrote:
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, Eric -- Beginning iPhone Games Development http://playcontrol.net/iphonegamebook/ _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|