I can't get the depth buffer to work using MonoTouch on iOS 5. I'm using the
standard MonoTouch "OpenGL Application" template and added this code to test
the depth buffer (OpenGL ES 1.1):

    GL.Enable(All.DepthTest);
    GL.DepthFunc(All.Greater);
    GL.DepthMask(true);

    // Shape A
    GL.DrawArrays (All.TriangleStrip, 0, 4); 

    // Shape B (should be behind Shape A)
    GL.Translate (.5f,.5f,.5f);
    GL.DrawArrays (All.TriangleStrip, 0, 4); 

    // Shape C (should be in front of Shape A)
    GL.Translate (-1f,-1f,-1f);
    GL.DrawArrays (All.TriangleStrip, 0, 4);

Both shape B and C are drawn in front of shape A. The same thing happens
even with "GL.DepthFunc(All.Never)". The depth buffer is completely ignored.
I also tried manually creating a depth buffer (instead of relying on the
MonoTouch/OpenTK "iPhoneOSGameView" to create one for me) using this code:

    protected override void CreateFrameBuffer()
    {
        base.CreateFrameBuffer();    
        uint depthbuffer=0;
        GL.Oes.GenRenderbuffers (1, ref depthbuffer);
        GL.Oes.BindFramebuffer (All.RenderbufferOes, depthbuffer);
        GL.Oes.RenderbufferStorage (All.RenderbufferOes,
All.DepthComponent16Oes, (int) 768, (int) 1024);
        GL.Oes.FramebufferRenderbuffer (All.FramebufferOes,
All.DepthAttachmentOes, All.RenderbufferOes, depthbuffer);
    }

It's still not working. Do you have any idea how I can get the depth buffer
to work? Am I missing something?

--
View this message in context: 
http://monotouch.2284126.n4.nabble.com/OpenGL-ES-1-1-depth-buffer-not-working-using-MonoTouch-on-iOS-5-tp4655725.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to