Code example for GL10

Methods: glClear, glLoadIdentity, glMatrixMode, glRotatef, glTranslatef

0
   } 
     
   public void onDrawFrame(GL10 gl) {
       
      // Clear the screen to black 
   gl.glClear(GL10.GL_COLOR_BUFFER_BIT
            | GL10.GL_DEPTH_BUFFER_BIT);
      
    
      // Position model so we can see it 
      gl.glMatrixMode(GL10.GL_MODELVIEW);
      gl.glLoadIdentity();
      gl.glTranslatef(0, 0, -3.0f);
 
       
      // Set rotation angle based on the time 
      long elapsed = System.currentTimeMillis() - startTime;
      gl.glRotatef(elapsed * (30f / 1000f), 0, 1, 0);
      gl.glRotatef(elapsed * (15f / 1000f), 1, 0, 0);
 
       
      // Draw the model 
      cube.draw(gl);
       
      // Keep track of number of frames drawn 
      numFrames++;
      long fpsElapsed = System.currentTimeMillis() - fpsStartTime;
      if (fpsElapsed > 5 * 1000) { // every 5 seconds