Sensor Orientiation -> GLRotation doesn't work properly
===

I know that is a bit more complex question but you are my last hope.
My aim is simple: I want to use the Android orientation sensor data for my GLES camera - giving it the rotation matrix.
I found a very good example here:

[http://stackoverflow.com/questions/2881128/how-to-use-onsensorchanged-sensor-data-in-combination-with-opengl][1]

but this is only working with GL1.0. So I need to work on it for GLES2.0

That was so far easy, using my own shaders. Everything works. Moving the camera manuall is fine. But the moment I use the rotation matrix like in the example, it doesn't really work.

I generate (like in his example) the rotation matrix with:

    SensorManager.getRotationMatrix(rotationMatrix, null, bufferedAccelGData, bufferedMagnetData);

	
My application is running in LANDSCAPe so I use that methode after (like in the example code):
	
    float[] result = new float[16];
    SensorManager.remapCoordinateSystem(rotationMatrix, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, result);
    return result;

It worked fine on my phone in his code but not in mine. My screen looks like that:

[screenshot][2]

The rotation matrix seems to be rotated 90° to the right (almost as if I have forgotten to switch to landscape for my activity).
I was thinking of using the remap() methode in a wrong way but in his example it makes sense and I don't see any other way. After all, the camera movement works now. If I rotate to the left, the screen rotates to the left as well, even though, since everything is turned, it rotates "up" (compared to the ground, which is not on the bottom but on the right). So it just looks like I made a wall instead of a ground but I'm sure my coordinates are right for the vertices.

I took a look ath the draw methode for the GLSurface and I don't see what I might have done wrong here:

        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    MatrixStack.glLoadMatrix(sensorManager.getRotationMatrix());  // Schreibt die MVMatrix mit der ogn. Rotationsmatrix
    GameRenderer.setPerspMatrix(); // Schreibt die Perspektivmatrix Uniform für GLES. Daran sollte es nicht liegen.
    MatrixStack.mvPushMatrix();
      drawGround();    
    MatrixStack.mvPopMatrix();

	
As I said, when moving my camera manually everything works perfect. So what is wrong with the rotation matrix I get? Or is there anything else wrong?

I know its hard to tell but you are my last hope!
Thank you very much,

 Tobias


  [1]: http://stackoverflow.com/questions/2881128/how-to-use-onsensorchanged-sensor-data-in-combination-with-opengl
  [2]: https://dl.dropbox.com/u/13527005/GLScreenshot.png