summaryrefslogtreecommitdiffstats
path: root/opengl/java/android/opengl/GLU.java
diff options
context:
space:
mode:
authorJack Palevich <jackpal@google.com>2009-11-27 19:59:05 +0800
committerJack Palevich <jackpal@google.com>2009-11-27 20:03:13 +0800
commit355c20cb9276148fd9b7074c5199aedeb497406e (patch)
treed4085aab602da9d15a7ff7bf492dc224d64bc854 /opengl/java/android/opengl/GLU.java
parentd2fa1ff139f23bf6e92495b916a4afb6a43bab3f (diff)
downloadframeworks_base-355c20cb9276148fd9b7074c5199aedeb497406e.zip
frameworks_base-355c20cb9276148fd9b7074c5199aedeb497406e.tar.gz
frameworks_base-355c20cb9276148fd9b7074c5199aedeb497406e.tar.bz2
Unhide the Android OpenGL ES 2.0 API
Add a Matrix.setLookAtM method for computing a look-at viewing transform. Change GLU.lookAt to use Matrix.setLook.
Diffstat (limited to 'opengl/java/android/opengl/GLU.java')
-rw-r--r--opengl/java/android/opengl/GLU.java52
1 files changed, 2 insertions, 50 deletions
diff --git a/opengl/java/android/opengl/GLU.java b/opengl/java/android/opengl/GLU.java
index 49a43d0..ed64556 100644
--- a/opengl/java/android/opengl/GLU.java
+++ b/opengl/java/android/opengl/GLU.java
@@ -72,60 +72,12 @@ public class GLU {
float centerX, float centerY, float centerZ, float upX, float upY,
float upZ) {
- // See the OpenGL GLUT documentation for gluLookAt for a description
- // of the algorithm. We implement it in a straightforward way:
-
- float fx = centerX - eyeX;
- float fy = centerY - eyeY;
- float fz = centerZ - eyeZ;
-
- // Normalize f
- float rlf = 1.0f / Matrix.length(fx, fy, fz);
- fx *= rlf;
- fy *= rlf;
- fz *= rlf;
-
- // compute s = f x up (x means "cross product")
- float sx = fy * upZ - fz * upY;
- float sy = fz * upX - fx * upZ;
- float sz = fx * upY - fy * upX;
-
- // and normalize s
- float rls = 1.0f / Matrix.length(sx, sy, sz);
- sx *= rls;
- sy *= rls;
- sz *= rls;
-
- // compute u = s x f
- float ux = sy * fz - sz * fy;
- float uy = sz * fx - sx * fz;
- float uz = sx * fy - sy * fx;
-
float[] scratch = sScratch;
synchronized(scratch) {
- scratch[0] = sx;
- scratch[1] = ux;
- scratch[2] = -fx;
- scratch[3] = 0.0f;
-
- scratch[4] = sy;
- scratch[5] = uy;
- scratch[6] = -fy;
- scratch[7] = 0.0f;
-
- scratch[8] = sz;
- scratch[9] = uz;
- scratch[10] = -fz;
- scratch[11] = 0.0f;
-
- scratch[12] = 0.0f;
- scratch[13] = 0.0f;
- scratch[14] = 0.0f;
- scratch[15] = 1.0f;
-
+ Matrix.setLookAtM(scratch, 0, eyeX, eyeY, eyeZ, centerX, centerY, centerZ,
+ upX, upY, upZ);
gl.glMultMatrixf(scratch, 0);
}
- gl.glTranslatef(-eyeX, -eyeY, -eyeZ);
}
/**