The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
sdl+windows phone set fixed aspect ratio
Meldryt


Joined: 22 Oct 2014
Posts: 36
Location: Munich
I want to set a fixed aspect ratio for my app (800x480) and prevent the windows phone from changing this size when i rotate it.
Re: sdl+windows phone set fixed aspect ratio
DLudwig


Joined: 09 Feb 2012
Posts: 179
Meldryt wrote:
I want to set a fixed aspect ratio for my app (800x480) and prevent the windows phone from changing this size when i rotate it.


If you just want to try locking the app in a landscape/non-portrait mode, try using SDL_SetHint in conjunction with SDL_HINT_ORIENTATIONS, preferably before creating the SDL_Window, setting its value to "LandscapeRight LandscapeLeft". For example:

Code:
SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeRight LandscapeLeft");


Do note that:


  1. the above option won't strictly lock the screen to 800x480 on devices that don't already have an 800x480 screen (such as those that, for example, have a 1920x1080 screen). For that, you could either ask the renderer to draw content at a virtual screen size (SDL's 2D rendering API has some functions that can help there, if you're using that API to draw, SDL_RenderSetLogicalSize being one), or you could render app content to an offscreen texture in the desired size, then render that to the screen, scaling it as needed.

  2. if you use SDL_HINT_ORIENTATIONS to set a portrait/non-landscape mode in a Windows Store (i.e. non-phone) app, and the device doesn't feature a portrait mode (say, if the computer is using a standalone, landscape-only monitor), WinRT will ignore the request to set the app as portrait, and will force the app to landscape. I haven't seen such a limitation on Windows Phone, but that might just be because all the Windows Phone hardware I've seen had integrated screens, and the devices were inherently rotate-able (as opposed to a Windows 8.x based computer with a potentially bulky monitor).


-- David L.