opengl es - Screen co-ordinates to Normalised device co-ordinates -
i have screen co-ordinates x=216,y=726,w=504,h=284 , need convert these normalized device co-ordinates [-1,1] before drawing using gldraw in opengles. please appreciated. relatively new opengles.
thanks in advance.
generally, when mapping coordinates 1 coordinate system another, here's procedure:
targetposition.x = targetleftmost + (sourceposition.x / sourcewidth) * targetwidth targetposition.y = targettopmost + (sourceposition.y / sourceheight) * targetheight
so you, should be:
targetposition.x = -1 + (sourceposition.x / 504) * targetwidth //(targetwidth = 2?)
this should started.
Comments
Post a Comment