Android Depth Buffer Problem: Recommendations for Anyone Having Problems

I spent about 30 hours writing and rewriting code this week, believing that I misunderstood how the OpenGL depth buffer works. Everything I tried failed. Now I solved the problem by discovering what might be a bug in the implementation of OpenGL for Android.

See this API entry:

http://www.opengl.org/sdk/docs/man/xhtml/glClearDepth.xml

void glClearDepth (GLclampd depth);

Defines the depth value used when the depth buffer is cleared. the initial value is 1.

There are two versions of this command in the Android implementation:

  • glClearDep thanks , which takes an integer value, clamped 0-1

  • glClearDepthf , which takes a floating point value, clamped 0-1

If you use glClearDepthf (1) , you will get the expected results. If you use glClearDep , thanks (1) , as I did, you get different results. (Note that the value is 1 by default, but calling the command with argument 1 produces different results, not a call at all). Pretty much what happens, I don’t know, but the depth buffer was cleared to a value other than what I indicated.

+3
source share
1 answer

Try passing 65536to glClearDepthx().

GLfixedis a fixed point of S15.16, therefore, is 1.0represented by 2^16or 65536.

, OpenGL, OpenGL ES 1.1.

+3

Source: https://habr.com/ru/post/1785693/


All Articles