public void undistortTexture(final int textureId) { if (this.mRestoreGLStateEnabled) { if (this.mChromaticAberrationCorrectionEnabled) { this.mGLStateBackupAberration.readFromGL(); } else { this.mGLStateBackup.readFromGL(); } } if (this.mFovsChanged || this.mTextureFormatChanged) { this.updateTextureAndDistortionMesh(); } GLES20.glViewport( 0, 0, this.mHmd.getScreenParams().getWidth(), this.mHmd.getScreenParams().getHeight()); GLES20.glDisable(GLES20.GL_SCISSOR_TEST); GLES20.glDisable(GLES20.GL_CULL_FACE); GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); if (this.mChromaticAberrationCorrectionEnabled) { GLES20.glUseProgram(this.mProgramHolderAberration.program); } else { GLES20.glUseProgram(this.mProgramHolder.program); } GLES20.glEnable(GLES20.GL_SCISSOR_TEST); GLES20.glScissor( 0, 0, this.mHmd.getScreenParams().getWidth() / 2, this.mHmd.getScreenParams().getHeight()); this.renderDistortionMesh(this.mLeftEyeDistortionMesh, textureId); GLES20.glScissor( this.mHmd.getScreenParams().getWidth() / 2, 0, this.mHmd.getScreenParams().getWidth() / 2, this.mHmd.getScreenParams().getHeight()); this.renderDistortionMesh(this.mRightEyeDistortionMesh, textureId); if (this.mRestoreGLStateEnabled) { if (this.mChromaticAberrationCorrectionEnabled) { this.mGLStateBackupAberration.writeToGL(); } else { this.mGLStateBackup.writeToGL(); } } }