OpenGL help with GLArea

I am drawing a map of the world, but can’t get the Depth Testing to work. I have

        unsafe {
            gl::Enable(gl::DEPTH_TEST);
            gl::Enable(gl::LINE_SMOOTH);
            gl::DepthFunc(gl::LESS);
            gl::DepthMask(gl::TRUE);

            gl::ClearColor(0.26, 0.19, 0.31, 1.);
            gl::Clear(gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT);
        }

But When I draw, first an opaque sphere and then the global coastlines, I see both sides of the world showing. I expect just to see the near side.

GTK does not use a depth buffer, you must allocate one and ensure it is attached before rendering. Edit: Also see the comment by ebassi below for a much easier way to do that.

Have you called set_has_depth_buffer(true) on the GLArea widget?

Hi @ebassi ,

Thanks

set_has_depth_buffer(true)

Works perfectly.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.