Where am I clicking?

Problems with Canvas, OpenGL, etc...

Where am I clicking?

Postby rHalf » Thu Sep 09, 2010 2:50 am

Please can someone explain in layman's terms how this is determined. What is the algorithm used? I see people mention ray tracing. If thats applicable here can someone give a dumbed down explanation of it?

My situation is this. I'm looking down at a board with pieces on it. I want to place the next piece by using the touch input. I get the x, y coordinated from the touch input and I have my screen width and height.

I use a standard declaration for my perspective:
Code: Select all
float ratio = (float) width / height;
GLU.gluPerspective(gl, 45.0f, ratio, 1, 100f);

If it helps assume we are using a MotoDroid resolution [480 x 854]

Before drawing anything I pull my camera back by 30.0f
Code: Select all
gl.glTranslatef(0, 0, -30.0f);

Are there other numbers I need to make the calculation?

So, if I click 0,0 on my screen and my gameboard is 30f deep into the screen how do I get the x,y on my board?

Thanks so much
Junior Developer
Junior Developer
Posts: 16
Joined: Sun Dec 20, 2009 1:54 am


Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 1 guest