Opengl android深度测试错误

时间:2011-07-19 15:51:45

标签: android opengl-es buffer pixel

我的Android应用上有GL_DEPTH_TEST。 但这是我的OpenGl PixelBuffer的结果(仅在第一次) Like this image: INIT:

    int[] version = new int[2];
    int[] attribList = new int[] {
        EGL_WIDTH, mWidth,
        EGL_HEIGHT, mHeight,
        EGL_NONE
    };

    // No error checking performed, minimum required code to elucidate logic
    mEGL = (EGL10) EGLContext.getEGL();
    mEGLDisplay = mEGL.eglGetDisplay(EGL_DEFAULT_DISPLAY);
    mEGL.eglInitialize(mEGLDisplay, version);
    mEGLConfig = chooseConfig(); // Choosing a config is a little more complicated
    mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL_NO_CONTEXT, null);
    mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig,  attribList);
    mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
    mGL = new MatrixTrackingGL((GL10) mEGLContext.getGL());

Surface Created:

        gl.glEnable(GL10.GL_DITHER);    
        gl.glEnable(GL10.GL_LIGHT0);

        gl.glShadeModel(GL10.GL_SMOOTH);            
        gl.glDepthFunc(GL10.GL_LEQUAL); 

        gl.glEnable(GL10.GL_DEPTH_TEST);        
        //gl.glClearDepthf(1.0f); 
        gl.glClearDepthx(65536);
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); 

        gl.glHint(GL10.GL_POINT_SMOOTH_HINT, GL10.GL_NICEST); 
        gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST); 
        gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); 
        if (mTranslucentBackground) {          
            gl.glClearColor(0,0,0,0);      
        } else {        
            gl.glClearColor(1,1,1,1);     
        }   

OnDrawFrame:

    gl.glDisable(GL10.GL_STENCIL_TEST);
    gl.glDisable(GL10.GL_DITHER);
    gl.glDisable(GL10.GL_DEPTH_TEST); 

    gl.glClearColor(0f, 0f, 0f, 0.0f);
    gl.glClearDepthf(1.0f);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); 
    gl.glDepthMask(true);        
    gl.glEnable(GL10.GL_DEPTH_TEST); 

0 个答案:

没有答案