Search code examples
javaandroidopengl-estouch-event

OpenGL: Convert on screen coordinate to OpenGL coordinates


I draw changing bar in OpenGL ES it has coords (x,y,z).
I would like to add some changes (example: colors in bar) on Action_Down. There is getX(), but this method returns the x coordinate in pixels, but not corresponding coords in OpenGL. Is there some class to convert OpenGL coords to pixels? Or is there any formula for it?


Solution

  • I think you're looking for this:

    http://www.opengl.org/sdk/docs/man2/xhtml/gluProject.xml

    It takes coordinates and maps them to window coordinates, with (0, 0) at the top left.