Android depth buffer issue: Advice for anyone experiencing problem

Posted by Andrew Smith on Stack Overflow See other posts from Stack Overflow or by Andrew Smith
Published on 2011-01-16T06:28:40Z Indexed on 2011/01/16 7:53 UTC
Read the original article Hit count: 253

Filed under:
|
|
|

I've wasted around 30 hours this week writing and re-writing code, believing that I had misunderstood how the OpenGL depth buffer works. Everything I tried, failed. I have now resolved my problem by finding what may be an error in the Android implementation of OpenGL.

See this API entry:

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

void glClearDepth(GLclampd depth);

Specifies the depth value used when the depth buffer is cleared. The initial value is 1.

Android's implementation has two versions of this command:

  • glClearDepthx which takes an integer value, clamped 0-1

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

If you use glClearDepthf(1) then you get the results you would expect. If you use glClearDepthx(1), as I was doing then you get different results. (Note that 1 is the default value, but calling the command with the argument 1 produces different results than not calling it at all.) Quite what is happening I do not know, but the depth buffer was being cleared to a value different from what I had specified.

© Stack Overflow or respective owner

Related posts about android

Related posts about opengl-es