Hi all,
I am trying to do an occlusion effect in my AR demo but I seem to have a problem with the depth buffer; it seems to be flipped upside down.
Basically, I have 2 virtual objects that follow their own marker. I would lik the first one to occlude the second one, when it is in front. But I don’t want to see it on screen I would like the video feed (displayed in the background) to show up instead.
To do that, I call this for the object I use to occlude (to write it in the depth buffer only):
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer);
And this for the other object:
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer);
The occlusion works but if I move the first marker down, I can see that the object that does the occlusion goes up instead, it follows horizontal moves correctly though, which leads me to believe the depth buffer is flipped upside down somehow.
The strange thing is that if I actually attach the colorRenderbuffer to that “occlusion object”, it is displayed correctly and it occludes the other object correctly.
Any idea what is happening? It is the first time I am trying to do something with the depth buffer so I am not completely sure that what I’m doing is the right thing, any pointer appreciated.
For info, I am developing on iPhone 4, using the Qualcomm AR SDK.
Thanks for your help.