Question

I'm trying to write program that draws complex non-convex object. But I have problem - some faces appear to be transparent. I partially solved this by adding GLES20.glEnable(GLES20.GL_CULL_FACE);

But after that I found out that it doesn't work if there are two faces with the same direction of their normals and one placed behind the other. In this case Open GL renders incorrectly. Also I tried to add GLES20.glEnable(GLES20.GL_DEPTH_TEST)

but I didn't attain the aim. Moreover, a half of the object vanished. Could you please explain me, where am I wrong?

P.S. To get object vertices I used Blender(I exported its data into obj file). Also I checked this data - there is right order of vertices(CCW).

Was it helpful?

Solution

I faced the same problem. The problem is you are not allocating size of the buffer for depth and stencil in configAttribslist. So its not calculating the depth even when you specify DepthTest.

solution: add the following lines to eglChooseConfig attribs list. EGL10.EGL_DEPTH_SIZE, 8, EGL10.EGL_STENCIL_SIZE, 8, this fixed the issue for me.

Code:

private static int[] s_configAttribs2 = { 
   EGL10.EGL_RED_SIZE, 4, 
   EGL10.EGL_GREEN_SIZE, 4, 
   EGL10.EGL_BLUE_SIZE, 4, 
   EGL10.EGL_DEPTH_SIZE, 8, 
   EGL10.EGL_STENCIL_SIZE, 8, 
   EGL10.EGL_SAMPLE_BUFFERS, 1,
   EGL10.EGL_RENDERABLE_TYPE, 
   EGL_OPENGL_ES2_BIT, 
   EGL10.EGL_NONE 

};

egl.eglChooseConfig(display, s_configAttribs2, configs, numConfigs, num_config);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top