Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the matrix generated by Android's frustumM differ from the Redbook's?

Something seems funny about the way that Android's frustumM works. If I check the OpenGL red book, the matrix generated looks like this:

(source: glprogramming.com)

Songho.ca seems to agree with this:

(source: songho.ca)

However, one component is multiplied by 2 with Android's frustumM, and not in the other example matrices. Here's what it seems to be doing:

Everything seems to functionally match up, except the first row, third column. Why is that being multiplied by two? Here's the lines of code from android.opengl.Matrix's frustumM method that generate the first three elements of the third column:

final float A = 2.0f * ((right + left) * r_width);
final float B = (top + bottom) * r_height;
final float C = (far + near) * r_depth;

With r_width, r_height, r_depth defined as:

final float r_width  = 1.0f / (right - left);
final float r_height = 1.0f / (top - bottom);
final float r_depth  = 1.0f / (near - far);

The line starting with "final float A" appears to be mistakenly multiplying by 2.

Is this a mistake in Android's code, or am I just missing something? I know that the term cancels out if the frustum is symmetrical. When running the code with an asymmetrical frustum, the generated matrices actually are different and so are the resulting vectors when the same vector is multiplied with those differing matrices.

like image 797
Learn OpenGL ES Avatar asked Jul 28 '12 02:07

Learn OpenGL ES


1 Answers

It's a bug with Android. Please see http://code.google.com/p/android/issues/detail?id=35646

like image 58
Learn OpenGL ES Avatar answered Oct 21 '22 13:10

Learn OpenGL ES