• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Aspect Ration and FOV Y correspondence

Joe Staff

Newbie
I'm coding a game in which I'm trying to modify the screen position to have the option to alternate between Stretched and Centered (because the game is designed for an aspect ratio not similar to the phone).

I'm using these formulas to determine how much to zoom out based on the wanted Field of View:

Code:
gameWidth=400;
gameHeight=800;
aspectRatio=(float)width/(float)height;
    		
FOVY=(float) ( 90 );
    		
minAdjustment = ((float)gameHeight/ (( (float) Math.tan(FOVY/(180/Math.PI)/2f) )*2f)); //This will zoom out so that the height is visible
if( gameWidth / aspectRatio > gameHeight )minAdjustment= (float)(gameWidth / aspectRatio)/ (( (float) Math.tan(FOVY/(180/Math.PI)/2f) )*2f); //This will zoom out to verify that the width is visible (if necessary)

This code works perfectly, but when I modify the FOV to be smaller a few things happen:
-To perspective, the game gets taller
-The game zooms out more to compensate
-The game SHOULD get skinnier due to the height increase and zoom out

Unfortunately, it does NOT get skinnier, it seems that the aspect ratio is being effected by the FOVY in the GLU.gluPerspective code line.


I have found a way to stretch the way I want, by simply using gl.glOrthof, but it seems like the previous code should work just fine.

Any ideas?
 
Back
Top Bottom