OpenGL depth buffer on Android

前端 未结 2 1916
余生分开走
余生分开走 2021-01-14 00:52

I\'m currently learning OpenGL ES programming on Android (2.1). I started with the obligatory rotating cube. It\'s rotating fine but I can\'t get the depth buffer to work. T

相关标签:
2条回答
  • I was using the GL2JNIView provided in the hello-gl2 sample in NDK r10, and I was also having this issue.

    The problem was that when creating the GL2JNIView object, i didn't specify the depth size on the constructor, so that the private class ConfigChooser could find the right EGL configuration.

    public GameJNIView(Context context, boolean translucent, int depth, int stencil){...}
    public GameJNIView(Context context){...}
    
    myView = new GL2JNIView(this, false, 16, 0);
    

    instead of

    myView = new GL2JNIView(this);
    
    0 讨论(0)
  • 2021-01-14 01:15

    Found it myself. It wasn't GL code, it was android code:

    view.setEGLConfigChooser(false);
    

    The "false" in this line explicitly says that no Z-Buffer should be allocated. After switching it to "true" it worked perfectly.

    0 讨论(0)
提交回复
热议问题