Esempio n. 1
0
 public void setViewport(int i, int j, int width, int height) {
   SLog.d(did, String.format("Viewport set: %d/%d", width, height));
   viewport[0] = i;
   viewport[1] = j;
   viewport[2] = width;
   viewport[3] = height;
 }
Esempio n. 2
0
  @Override
  public void onSurfaceChanged(GL10 gl, int width, int height) {
    gl.glViewport(0, 0, width, height);

    camera.setViewport(0, 0, width, height);
    camera.changePerspective(gl, Projection.PERSPECTIVE);

    SLog.d(did, "Surface created.");
  }
Esempio n. 3
0
  public void changePerspective(GL10 gl, Projection p) {
    SLog.d(did, "Changing perspective.");
    gl.glMatrixMode(GL10.GL_PROJECTION); // select projection
    gl.glLoadIdentity(); // reset
    float aspect = ((float) viewport[2] / viewport[3]);
    switch (p) {
      case PERSPECTIVE:
        SLog.d(did, "Setting perspective mode width aspect = " + aspect);
        gl.glFrustumf(-aspect, aspect, -1f, 1f, near, far);
        break;
      case ORTHOGRAPHIC:
        SLog.d(did, "Setting orthographic mode.");
        gl.glOrthof(-1, 1, -1, 1, -1f, 10.0f);
        break;
      default:
        break;
    }

    hasChanged = true;
  }