页面卷曲上的奇怪闪电

时间:2014-02-20 02:37:01

标签: android opengl-es page-curl

我正在使用由Harism在https://github.com/harism/android_page_curl创建的页面卷曲动画。我已经将他的动画实现到了我的电子书阅读器应用程序的android,问题是当我快速刷页时,有时奇怪的白色闪电是切换。然而,当我正常卷曲页面时,没有这种情况。我认为问题出在 OpenGL 方面。我对这项技术并不熟悉,但在调试过程中,我看到页面卷曲完成后仍有一些绘制过程正在进行 CurlRenderer 类在 onDrawFrame 方法。

    @Override
    public synchronized void onDrawFrame(final GL10 gl) {
        mObserver.onDrawFrame();
        gl.glClearColor(Color.red(mBackgroundColor) / 255f,
                Color.green(mBackgroundColor) / 255f,
                Color.blue(mBackgroundColor) / 255f,
                Color.alpha(mBackgroundColor) / 255f);
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        gl.glLoadIdentity();
        if (USE_PERSPECTIVE_PROJECTION) {
            gl.glTranslatef(0, 0, -6f);
        }
        for (int i = 0; i < mCurlMeshes.size(); ++i) {

            mCurlMeshes.get(i).onDrawFrame(gl);
        }
        Calendar now = Calendar.getInstance();
        int minute = now.get(Calendar.MINUTE);
        int second = now.get(Calendar.SECOND);
        int millis = now.get(Calendar.MILLISECOND);
        Log.i("time curl renderer (onDrawFrame) : ", minute + ":" + second + "." + millis);
    }

以下是日志

02-20 07:27:37.320  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.326
02-20 07:27:37.328  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.336
02-20 07:27:37.335  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.344
02-20 07:27:37.343  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.354
02-20 07:27:37.359  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.367
02-20 07:27:37.367  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.377
02-20 07:27:37.375  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.387
02-20 07:27:37.390  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.399
02-20 07:27:37.398  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.410
02-20 07:27:37.414  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.422
02-20 07:27:37.421  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.432
02-20 07:27:37.437  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.444
02-20 07:27:37.445  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.455
02-20 07:27:37.453  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.465
02-20 07:27:37.468  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.477
02-20 07:27:37.476  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.487
02-20 07:27:37.492  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.501
02-20 07:27:37.500  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.509
02-20 07:27:37.515  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.520
02-20 07:27:37.523  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.532
02-20 07:27:37.531  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.542
02-20 07:27:37.546  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.555
02-20 07:27:37.554  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.565
02-20 07:27:37.570  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.576
02-20 07:27:37.578  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.588
02-20 07:27:37.585  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.598
02-20 07:27:37.601  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.610
02-20 07:27:37.609  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.619
02-20 07:27:37.617  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.629 

当第一行日志出现时,本书的页面完成卷曲,在这种情况下说02-20 07:27:37.320,但在接下来的行中你可以看到 onDrawFrame 方法被称为continuosly.Maybe我正在卷曲页面,当这种方法还没有完成它的工作,并且闪电开关来自那个故障?任何帮助?以下是您可以看到的视频链接,有时会出现闪电http://www.youtube.com/watch?v=HPJ2U18Caok&feature=youtu.be

1 个答案:

答案 0 :(得分:0)

其他可能的解决方案:

尝试使用Render Script Page curl!

enter image description here

Renderscript是一种语言,API和运行时库,可用于实现Android应用程序的高性能渲染和计算。请参阅Jason Sams的介绍性文章Introducing RenderscriptRenderscript Part 2.

还可以使用Page Turner查看这个真棒page curl lib

更多来源:

http://www.zeropointnine.com/blog/3d-page-curl-effect-updated/

http://www.doubleencore.com/2013/10/renderscript-for-all/