Because OpenGL is stateful, how do you target a specific matrix especially in OpenGL ES 1.x (a fixed function pipeline)? For example we know that when we call glFrustum() it sets up the projection matrix, but the documentation suggests that if takes the current matrix and multiplies with the projection matrix? But there are more than one matrix: many matrices that are model, and at least one more that is a view matrix?
satya - Sat Sep 01 2012 08:17:23 GMT-0400 (Eastern Daylight Time)
The answer lies in the following code sequence to set a projection matrix
//Indicate we are going to target the projection matrix
//There other constants to indicate other matrices
//as targets for subsequent methods that manipulate and set matrices.
gl.glMatrixMode(GL10.GL_PROJECTION);
// Set that matrix to the identity matrix
gl.glLoadIdentity();
//This multiples the previous matrix with the projection matrix
gl.glFrustumf(-ratio, ratio, -1, 1, 3, 7);
satya - Sat Sep 01 2012 08:17:51 GMT-0400 (Eastern Daylight Time)
See the docs for glMatrixMode
satya - Sat Sep 01 2012 08:18:44 GMT-0400 (Eastern Daylight Time)
This is not necessary in ES 2.0 as it is not a fixed function pipeline
and you have the ability to explicitly control the matrix variables and hence the state doesn't matter and you work more like a local variable and not a global variable.
satya - Sat Sep 01 2012 08:48:37 GMT-0400 (Eastern Daylight Time)
Similarly here is how you work with the view matrix
//See how similarly we are working with and setting the model/view matrix
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);