gl.glBindTexture(GL.GL_TEXTURE_CUBE_MAP, staticTextureIDs[CA_TEXTURE_CUBEMAP]); gl.glEnable(GL.GL_TEXTURE_2D);
cubemap.bind(); cubemap.enable();
  public void draw(GL gl, Rotf cameraOrientation) {    this.cameraOrientation.set(cameraOrientation);    if (skipCount >= skipInterval && renderMode != CA_DO_NOT_RENDER) {      skipCount = 0;      // Display the results of the rendering to texture      if (wireframe) {        gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);                   // chances are the texture will be all dark, so lets not use a texture        gl.glDisable(GL.GL_TEXTURE_2D);      } else {        gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);            			        gl.glActiveTexture(GL.GL_TEXTURE0);        gl.glEnable(GL.GL_TEXTURE_2D);      }      switch (renderMode) {        case CA_FULLSCREEN_REFLECT: {          // include bump scale...          Mat4f bscale = new Mat4f();          bscale.makeIdent();          bscale.set(0, 0, bumpScale);          bscale.set(1, 1, bumpScale);          Mat4f rot = new Mat4f();          rot.makeIdent();          rot.setRotation(cameraOrientation);          Mat4f matRot = rot.mul(bscale);          gl.glCallList(displayListIDs[CA_FRAGMENT_PROGRAM_REFLECT]);          // Draw quad over full display          gl.glActiveTexture(GL.GL_TEXTURE0);          gl.glBindTexture(GL.GL_TEXTURE_2D, dynamicTextureIDs[CA_TEXTURE_NORMAL_MAP]);          gl.glDisable(GL.GL_TEXTURE_2D);          gl.glActiveTexture(GL.GL_TEXTURE3);          gl.glBindTexture(GL.GL_TEXTURE_CUBE_MAP, staticTextureIDs[CA_TEXTURE_CUBEMAP]);          gl.glEnable(GL.GL_TEXTURE_2D);          gl.glColor4f(1, 1, 1, 1);          gl.glBegin(GL.GL_QUADS);                          gl.glMultiTexCoord2f(GL.GL_TEXTURE0, 0,0);          gl.glMultiTexCoord4f(GL.GL_TEXTURE1, matRot.get(0,0), matRot.get(0,1), matRot.get(0,2),  1);          gl.glMultiTexCoord4f(GL.GL_TEXTURE2, matRot.get(1,0), matRot.get(1,1), matRot.get(1,2),  1);          gl.glMultiTexCoord4f(GL.GL_TEXTURE3, matRot.get(2,0), matRot.get(2,1), matRot.get(2,2),  1);          gl.glVertex2f(-1,-1);                          gl.glMultiTexCoord2f(GL.GL_TEXTURE0, 1,0);          gl.glMultiTexCoord4f(GL.GL_TEXTURE1, matRot.get(0,0), matRot.get(0,1), matRot.get(0,2), -1);          gl.glMultiTexCoord4f(GL.GL_TEXTURE2, matRot.get(1,0), matRot.get(1,1), matRot.get(1,2),  1);          gl.glMultiTexCoord4f(GL.GL_TEXTURE3, matRot.get(2,0), matRot.get(2,1), matRot.get(2,2),  1);          gl.glVertex2f( 1,-1);                          gl.glMultiTexCoord2f(GL.GL_TEXTURE0, 1,1);          gl.glMultiTexCoord4f(GL.GL_TEXTURE1, matRot.get(0,0), matRot.get(0,1), matRot.get(0,2), -1);          gl.glMultiTexCoord4f(GL.GL_TEXTURE2, matRot.get(1,0), matRot.get(1,1), matRot.get(1,2), -1);          gl.glMultiTexCoord4f(GL.GL_TEXTURE3, matRot.get(2,0), matRot.get(2,1), matRot.get(2,2),  1);          gl.glVertex2f( 1, 1);                          gl.glMultiTexCoord2f(GL.GL_TEXTURE0, 0,1);          gl.glMultiTexCoord4f(GL.GL_TEXTURE1, matRot.get(0,0), matRot.get(0,1), matRot.get(0,2),  1);          gl.glMultiTexCoord4f(GL.GL_TEXTURE2, matRot.get(1,0), matRot.get(1,1), matRot.get(1,2), -1);          gl.glMultiTexCoord4f(GL.GL_TEXTURE3, matRot.get(2,0), matRot.get(2,1), matRot.get(2,2),  1);          gl.glVertex2f(-1, 1);                          gl.glEnd();              gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);                          break;        }        case CA_FULLSCREEN_NORMALMAP: {          // Draw quad over full display          gl.glActiveTexture(GL.GL_TEXTURE0);          gl.glBindTexture(GL.GL_TEXTURE_2D, dynamicTextureIDs[CA_TEXTURE_NORMAL_MAP]);                          gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]);          break;        }        case CA_FULLSCREEN_HEIGHT: {          // Draw quad over full display          gl.glActiveTexture(GL.GL_TEXTURE0);          gl.glBindTexture(GL.GL_TEXTURE_2D, texHeightOutput);                          gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]);          break;        }        case CA_FULLSCREEN_FORCE: {          // Draw quad over full display          gl.glActiveTexture(GL.GL_TEXTURE0);          gl.glBindTexture(GL.GL_TEXTURE_2D, dynamicTextureIDs[CA_TEXTURE_FORCE_TARGET]);			                           gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]);          break;        }        case CA_TILED_THREE_WINDOWS: {          // Draw quad over full display          // lower left          gl.glActiveTexture(GL.GL_TEXTURE0);          gl.glBindTexture(GL.GL_TEXTURE_2D, dynamicTextureIDs[CA_TEXTURE_FORCE_TARGET]);          gl.glMatrixMode(GL.GL_MODELVIEW);          gl.glPushMatrix();			                           gl.glTranslatef(-0.5f, -0.5f, 0);          gl.glScalef(0.5f, 0.5f, 1);          gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]);          gl.glPopMatrix();          // lower right          gl.glBindTexture(GL.GL_TEXTURE_2D, texVelocityOutput);          gl.glPushMatrix();			                           gl.glTranslatef(0.5f, -0.5f, 0);          gl.glScalef(0.5f, 0.5f, 1);          gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]);          gl.glPopMatrix();          // upper left          gl.glBindTexture(GL.GL_TEXTURE_2D, dynamicTextureIDs[CA_TEXTURE_NORMAL_MAP]);          gl.glMatrixMode(GL.GL_MODELVIEW);          gl.glPushMatrix();			                           gl.glTranslatef(-0.5f, 0.5f, 0);          gl.glScalef(0.5f, 0.5f, 1);          gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]);          gl.glPopMatrix();          // upper right          gl.glBindTexture(GL.GL_TEXTURE_2D, texHeightOutput);          gl.glMatrixMode(GL.GL_MODELVIEW);          gl.glPushMatrix();			                           gl.glTranslatef(0.5f, 0.5f, 0);          gl.glScalef(0.5f, 0.5f, 1);          gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]);          gl.glPopMatrix();			              break;        }      }    } else {      // skip rendering this frame      skipCount++;    }  }