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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -