@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(); }
@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(); }
public void setSize(int width, int height) { Utils.assertTrue(width >= 0 && height >= 0); mHeight = height; 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); Matrix.translateM(matrix, 0, 0, mHeight, 0); Matrix.scaleM(matrix, 0, 1, -1, 1); mClipRect.set(0, 0, width, height); gl.glScissor(0, 0, width, height); }
@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(); }
@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); }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glClearColor(0.0f, 0.0f, 0.0f, 1); gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST); gl.glShadeModel(GL10.GL_FLAT); gl.glDisable(GL10.GL_DEPTH_TEST); // Alpha support. gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); GLU.gluOrtho2D(gl, 0, getWidth(), getHeight(), 0); } }