I have a problem with mapping the coordinates of the screen to the OpenGL Es world. I do the following:
- Code: Select all
mButton1.setPosition(75.0f, 120.0f);
mButton1.setScale(.3f, .3f, 0f);
mButton1 is a Button (custom class) instance. There is a method 'setPosition(x, y)' that sets mX and mY members like this:
- Code: Select all
public void setPosition(float x, float y) {
mPos = getTransformation(x, y);
mTransX = mPos.x;
mTransY = mPos.y;
}
Then, I have getTransformation(float, float) method that looks like this:
- Code: Select all
public static PointF getTransformation(float x, float y) {
float[] pos = new float[4];
float[] mModelView = new float[16];
float[] mProjection = new float[16];
int view[] = {0, 0, screenWidth, screenHeight};
getMatrix(mGL, GL10.GL_MODELVIEW, mModelView);
getMatrix(mGL, GL10.GL_PROJECTION, mProjection);
GLU.gluUnProject(x, y, 0, mModelView, 0, mProjection, 0, view, 0, pos, 0);
return (new PointF(pos[0], (-1)*pos[1]));
}
...
And getMatrix that is using MatrixTrackingGL from the Google Graphics API samples: http://is.gd/h7SQn
- Code: Select all
private static void getMatrix(GL10 gl, int mode, float[] mat) {
MatrixTrackingGL gl2 = (MatrixTrackingGL) gl;
gl2.glMatrixMode(mode);
gl2.getMatrix(mat, 0);
}
But getTransformation(x, y) returns incorrect values

Where do I make a mistake?
ANY help is appreciated.


