android - Applying Orthographic projection or frustum effecting normalised coordinates? -


i know normalised coordinates should -1 (left) , +1 (right) , -1 (bottom) , +1 (top)

like this:

enter image description here

but after applying this:

from onsurfacechanged method

gles20.glviewport(0, 0, width, height); float ratio = (float) width / height; matrix.orthom(mprojmatrix, 0, -ratio, ratio, -1, 1, 3, 7);  //the above line can replaced with: //matrix.frustumm(mprojmatrix, 0, -ratio, ratio, -1, 1, 3, 7); //but same results either frustumm or otrhom 

and in ondrawframe method

matrix.setlookatm(mvmatrix, 0, 0, 0, 3, 0f, 0f, 0f, 0f, 1.0f, 0.0f); matrix.multiplymm(mmvpmatrix, 0, mprojmatrix, 0, mvmatrix, 0); 

(i pass mmvpmatrix custom class's draw method rotated , translated).

but, co-ordinates seem change - happens:

enter image description here

as can see, x co-ordinates altered somewhat, -1 , +1 no longer edges of screen (on device i'm using @ moment, outer edges become -1.7 , +1.7)

y coordinates remain unchanged.

would appreciate if point out i'm going wrong? need -1 through +1 should be.

thanks

to eyes appears correct. if screen not square, sure want x axis stretched behaves square screen? because if that, if tell opengl draw square, appear rectangle on screen instead if don't have x axis edges larger y axis edges when screen width wider screen height, suggested image. that's why pass ratio projection, knows how draw things properly.

what happening when draw regular square on screen? appearing square or rectangle?


Comments