public void setSize(int width, int height) {
    Utils.assertTrue(width >= 0 && height >= 0);

    if (mTargetTexture == null) {
      mScreenWidth = width;
      mScreenHeight = height;
    }
    mAlpha = 1.0f;

    GL11 gl = mGL;
    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL11.GL_PROJECTION);
    gl.glLoadIdentity();
    GLU.gluOrtho2D(gl, 0, width, 0, height);

    gl.glMatrixMode(GL11.GL_MODELVIEW);
    gl.glLoadIdentity();

    float matrix[] = mMatrixValues;
    Matrix.setIdentityM(matrix, 0);
    // to match the graphic coordinate system in android, we flip it vertically.
    if (mTargetTexture == null) {
      Matrix.translateM(matrix, 0, 0, height, 0);
      Matrix.scaleM(matrix, 0, 1, -1, 1);
    }
  }
  public void onSurfaceChanged(GL10 gl, int width, int height) {
    if (height == 0) {
      height = 1;
    }

    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();

    //		GLU.gluPerspective(gl, 45.0f, (float)width / (float)height, 0.1f, 100.0f);
    GLU.gluOrtho2D(gl, 0, (float) width, -(float) height, 0);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();
  }
Beispiel #3
0
  // This is a GLSurfaceView.Renderer callback
  public void onSurfaceChanged(GL10 gl1, int width, int height) {
    Log.v(TAG, "onSurfaceChanged: " + width + "x" + height + ", gl10: " + gl1.toString());
    GL11 gl = (GL11) gl1;
    mGL = gl;
    gl.glViewport(0, 0, width, height);

    gl.glMatrixMode(GL11.GL_PROJECTION);
    gl.glLoadIdentity();

    GLU.gluOrtho2D(gl, 0, width, 0, height);
    Matrix matrix = mTransformation.getMatrix();
    matrix.reset();
    matrix.preTranslate(0, getHeight());
    matrix.preScale(1, -1);
  }
Beispiel #4
0
  /**
   * Handle changes such as orientation changes. This also happens when the surface is created. <br>
   * <br>
   * This method will set the background color, set the viewport, remove perspective.
   */
  @Override
  public void onSurfaceChanged(GL10 gl, int width, int height) {
    if (height == 0) { // Prevent A Divide By Zero By
      height = 1; // Making Height Equal One
    }

    camwidth = width;
    camheight = height;

    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL10.GL_PROJECTION); // Select The Projection Matrix
    gl.glLoadIdentity(); // Reset The Projection Matrix
    GLU.gluOrtho2D(gl, 0, width, 0, height); // Use orthogonic view. No perspective.

    gl.glMatrixMode(GL10.GL_MODELVIEW); // Select The Modelview Matrix
    gl.glLoadIdentity();
  }
  @Override
  public void onSurfaceChanged(GL10 gl, int width, int height) {
    gl.glViewport(0, 0, width, height);
    mViewportWidth = width;
    mViewportHeight = height;

    float ratio = (float) width / height;
    mViewRect.top = 1.0f;
    mViewRect.bottom = -1.0f;
    mViewRect.left = -ratio;
    mViewRect.right = ratio;
    setViewMode(mViewMode);

    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    GLU.gluOrtho2D(gl, mViewRect.left, mViewRect.right, mViewRect.bottom, mViewRect.top);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();
  }
Beispiel #6
0
  @Override
  public void onDrawFrame(GL10 gl) {
    if (busy) {
      return;
    }

    gl.glClearColor(1.0f, 1.0f, 0.2f, 0.0f);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    // GLU.gluOrtho2D(gl, 0.0f,1.3f,0.0f,1.0f);
    GLU.gluOrtho2D(gl, 0.0f, 320.0f, 480.0f, 0.0f);

    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glShadeModel(GL10.GL_SMOOTH);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();

    gl.glColor4f(0.25f, 0.25f, 0.75f, 1.0f);
    // gl.glTranslatef(0f, 1f, 0.0f);
    // gl.glScalef(1.0f/320, -1.0f/480, 0.001f);
    // gl.glRotatef(0, 0, 1, 0);

    Log.e("navit", "flb_len " + flb_len);
    for (int i = 0; i < flb_len; i++) {
      if (flb[i] != null) {
        gl.glVertexPointer(3, GL10.GL_FLOAT, 0, flb[i]);
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, flb[i].capacity() / 3);
      }
    }
    //		FloatBuffer buf=makeFloatBuffer(square);
    //		gl.glVertexPointer(3, GL10.GL_FLOAT, 0, buf);
    //		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    //		Log.e("navit", "capacity "+buf.capacity());
    //		gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, buf.capacity()/3);
  }
  @Override
  public void onSurfaceChanged(GL10 gl, int width, int height) {
    gl.glViewport(0, 0, width, height);
    mViewportWidth = width;
    mViewportHeight = height;

    float ratio = (float) width / height;
    mViewRect.top = 1.0f;
    mViewRect.bottom = -1.0f;
    mViewRect.left = -ratio;
    mViewRect.right = ratio;
    updatePageRects();

    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    if (USE_PERSPECTIVE_PROJECTION) {
      GLU.gluPerspective(gl, 20f, (float) width / height, .1f, 100f);
    } else {
      GLU.gluOrtho2D(gl, mViewRect.left, mViewRect.right, mViewRect.bottom, mViewRect.top);
    }

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();
  }