Fix random flickering

This commit is contained in:
Simon Leistikow 2017-09-14 01:46:22 +02:00
parent 395c82f341
commit a8b4e0ecb2
2 changed files with 1 additions and 6 deletions

View File

@ -173,7 +173,7 @@ public class Renderer implements GLSurfaceView.Renderer {
glGenTextures(1, textureID, 0);
// Initialize matrices.
Matrix.setIdentityM(modlMatrix, 0);
Matrix.setRotateM(modlMatrix, 0, 90, 1.0f, 0.0f, 0.0f);
Matrix.setLookAtM(viewMatrix, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f);
}

View File

@ -23,14 +23,10 @@ public class SphereSurfaceView extends GLSurfaceView implements SensorEventListe
// The actual rotation matrix determined by user input.
private final float rotationMatrix [] = new float[16];
// This matrix is used to compensate sensor coordinate system rotation.
private final float offsetMatrix [] = new float[16];
public SphereSurfaceView(Context context) {
super(context);
Matrix.setIdentityM(rotationMatrix, 0);
Matrix.setRotateM(offsetMatrix, 0, 90.0f, 1.0f, 0.0f, 0.0f);
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
Sensor accelerometer = manager.getSensorList(Sensor.TYPE_ROTATION_VECTOR).get(0);
@ -83,7 +79,6 @@ public class SphereSurfaceView extends GLSurfaceView implements SensorEventListe
synchronized (rotationMatrix) {
SensorManager.getRotationMatrixFromVector(rotationMatrix, event.values);
Matrix.multiplyMM(rotationMatrix, 0, rotationMatrix, 0, offsetMatrix, 0);
}
}