3
$\begingroup$

I'm investigating making some simple widgets using bgl and finding it difficult to use the depth buffer without making a mess of the area I'm drawing in.

Enable depth testing:

glEnable(GL_DEPTH_TEST)
glDepthMask(GL_TRUE)

From here I've tried calls to glDepthRange(...) , glDepthFunc(...) , with varying degrees of success, but without a handle on writing above the view, ie when I do get an element to draw behind it ends up behind everything and can't be seen. (well at least I'm assuming that's the case)

Will keep editing the question as I get more o fay with bgl / opengl.

$\endgroup$

1 Answer 1

2
$\begingroup$

Ok I have found one way of doing this.

bgl.glEnable(bgl.GL_DEPTH_TEST)
bgl.glDepthRange (0.0, 0.9);

# Draw "Something" here

bgl.glDepthRange (0.1, 1.0)

# Anything drawn now will be below "Something" drawn above

# restore opengl defaults

bgl.glLineWidth(1)
bgl.glDisable(bgl.GL_DEPTH_TEST)
bgl.glDisable(bgl.GL_BLEND)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .