PDA

View Full Version : Android: Support all aspect ratios



gintasdx
22-03-2014, 04:30 PM
I wonder is there any easy way to support all common Android resolutions with 4:3 and 16:9 aspect ratios? Something like in provided solution for another Android game engine.a
http://blog.gemserk.com/2013/01/22/our-solution-to-handle-multiple-screen-sizes-in-android-part-one/ (http://blog.gemserk.com/2013/01/22/our-solution-to-handle-multiple-screen-sizes-in-android-part-one/)

Carver413
22-03-2014, 05:35 PM
you should check out ZenGl, it has Android support and possibly the answers you seek
http://www.zengl.org/

laggyluk
22-03-2014, 08:58 PM
you should check out ZenGl, it has Android support and possibly the answers you seek
http://www.zengl.org/
wasn't it discontinued?

gintasdx
24-03-2014, 10:07 PM
ZenGL is discontinued,but stable enough for rapid Android games development using Pascal programming language. There is a function scr_CorrectResolution which keeps aspect ratio on all DPIs,but leaves empty black borders. There should be some tricks for adjusting game screen perfectly.

Carver413
25-03-2014, 12:03 AM
Vector graphics is the best way to go but I don't really know what sort of game your planning. with opengl you can change the viewport/aspect but I don't know what that would really look like.
google would be your best source.
http://developer.android.com/guide/practices/screens_support.html

Andru
08-05-2014, 07:22 AM
There is one method, but you need to modify the code of ZenGL and do some calculation :) E.g. you have real resolution 1280x720. This is a 16:9 aspect. Take any demo, there is resolution 800x600. For aspect 16:9 you need only 800x450. So, you call in your Init this:


zgl_Enable( CORRECT_RESOLUTION );
scr_CorrectResolution( 800, 450 );

But as a result you won't see the bottom of scene. E.g. you need to see center of it, so open scr_CorrectResolution and add there this line(before SetCurrentMode):


scrAddCY := Round( -75 * scrResCY );

-75 - this is ( 600 - 450 ) / 2. So, if idea is clear then you can modify the code a bit an extend it for your needs :)

gintasdx
09-05-2014, 08:55 AM
Thanks for the answer. I will try to center all the UI in safe area and leave some pixels around for the background.
Mystic Diary - Hidden Object has good stretching on all resolutions with status bar and without it.

Andru
09-05-2014, 09:14 AM
Mystic Diary has been made without saving the aspect(this is a default practice of published on BFG games), but because of content it's not so clear :)