Hi!

Two friends and myself are working on a project, simulating terrain in 3D with possibilities of 'flying' around in the terrain.

I am trying to implement frustum culling into our engine, but I am having some problems with getting my hands on the Modelview- and Projection matrix.

Code :
// Get The Current PROJECTION Matrix From OpenGL
   glGetFloatv( GL_PROJECTION_MATRIX, proj );
 
// Get The Current MODELVIEW Matrix From OpenGL
   glGetFloatv( GL_MODELVIEW_MATRIX, modl );

As far as I have heard, "glGetFloatv" haven't been implemented yet. Though, I have found a 'work-around', using "MatrixStack.java" and "MatrixTrackingGL" to get a hand on the modelview- and projectionmatrix, but I still don't get it to work properly. It seems everytime i call 'extractFrustum()' the view seems to change drastically. It looks like it moves "into" the terrain, as the whole screen turns green/brown/blue depending where in the terrain I am looking. It looks like it happens when i use the following calls:

Code :
/* Get the current PROJECTION matrix from OpenGL */   
	    getMatrix(gl, GL10.GL_MODELVIEW, modl);
 
	   /* Get the current MODELVIEW matrix from OpenGL */
	    getMatrix(gl, GL10.GL_PROJECTION, proj);

This method looks like this:

Code :
private void getMatrix(GL10 gl, int mode, float[] mat) {
        MatrixTrackingGL gl2 = (MatrixTrackingGL) gl;
        gl2.glMatrixMode(mode);
        gl2.getMatrix(mat, 0);      
    }

I would really appreciate some help with this.
Many thanks in advance.