Original Post
Hi all!
Im having doubts on how to work with different screen sizes. Im giving the left top corner to (0,0), and for the right bottom corner i give (screen_width, screen_height). In this way i always know the size of the screen, and keep the aspect ratio of the objects i draw. But what happens when it try it on a smaller/higher screen? well, i keep having the aspect ratio, but have a look to this example:
Screen 1 (landscape):
width = 800
height = 400
I draw an object in (780,380), just in the right bottom corner. See screen 2 example:
Screen 2 (landscape)
width = 600
height = 300
They have same aspect ratio, but if in my code i draw something on (780,380), i some screens it would be visible, and in others it wont. Im thinking in converting coordinates, for example (600*780)/800 = 585, so i have the corresponding coordinates for both screens. But i dont know if this keep the acpect ratio, and i should apply it just not to coordinates, also for object dimensions.
Here is how i setup ortho view:
Maybe this is a stupid question, but i dont know what is the way to work with it.
Thanks in advance!
Regards
Im having doubts on how to work with different screen sizes. Im giving the left top corner to (0,0), and for the right bottom corner i give (screen_width, screen_height). In this way i always know the size of the screen, and keep the aspect ratio of the objects i draw. But what happens when it try it on a smaller/higher screen? well, i keep having the aspect ratio, but have a look to this example:
Screen 1 (landscape):
width = 800
height = 400
I draw an object in (780,380), just in the right bottom corner. See screen 2 example:
Screen 2 (landscape)
width = 600
height = 300
They have same aspect ratio, but if in my code i draw something on (780,380), i some screens it would be visible, and in others it wont. Im thinking in converting coordinates, for example (600*780)/800 = 585, so i have the corresponding coordinates for both screens. But i dont know if this keep the acpect ratio, and i should apply it just not to coordinates, also for object dimensions.
Here is how i setup ortho view:
public void seUpOrthoProjection(int w, int h)
{
float[] c_matrix = new float[16];
float[] p_matrix = new float[16];
engine.setScreenWidth(w);
engine.setScreenHeight(h);
setUpViewPort(w,h);
Matrix.orthoM(p_matrix, 0, 0, w, h, 0, -1.0f, 1.0f);
Matrix.setLookAtM(c_matrix, 0, 0, 0, 1, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
engine.setProjectionMatrix(p_matrix);
engine.setCameraMatrix(c_matrix);
}
Maybe this is a stupid question, but i dont know what is the way to work with it.
Thanks in advance!
Regards