3

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.

p2or
  • 15,860
  • 10
  • 83
  • 143
batFINGER
  • 84,216
  • 10
  • 108
  • 233

1 Answers1

2

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)
batFINGER
  • 84,216
  • 10
  • 108
  • 233