Java Code Examples for javax.microedition.khronos.opengles.GL11#glViewport()

The following examples show how to use javax.microedition.khronos.opengles.GL11#glViewport() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setSize(final int width, final int height) {
    mScreenWidth = width;
    mScreenHeight = height;
    mAlpha = 1.0f;

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

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

    final float matrix[] = mMatrixValues;
    Matrix.setIdentityM(matrix, 0);
    // to match the graphic coordinate system in android, we flip it vertically.
    Matrix.translateM(matrix, 0, 0, height, 0);
    Matrix.scaleM(matrix, 0, 1, -1, 1);
}
 
Example 2
Source File: GLES11Canvas.java    From PhotoMovie with Apache License 2.0 5 votes vote down vote up
@Override
public void setSize(int width, int height) {
    Assert.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);
    }
}