How to draw a point in 3DView always in front

Hi;

The Mathvis Addon used to draw pixels always in front (in blender 2.79). This is no longer the case in Blender 2.80 So i wanted to fix this, but i do not know how and where to define that.

here is the function that draws a point in the MathVis Addon:

COLOR_POINT = (1, 0, 1, 1)
def draw_points(points):
    batch = batch_from_points(points, "POINTS")
    single_color_shader.bind()
    single_color_shader.uniform_float("color", COLOR_POINT)
    batch.draw(single_color_shader)

Any hint for how to define “draw always in front” is very welcome :slight_smile:
thanks

Make sure bgl is imported. Then in the draw callback add:

bgl.glDepthFunc(bgl.GL_ALWAYS)

before

batch.draw(single_color_shader)

See more info here. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glDepthFunc.xhtml

1 Like

As far as i can tell the usage of the bgl module is disallowed or at least deprecated in blender 2.80.
However your suggestions works :slight_smile:
I still need to be sure it is accepted (or what is the replacement for this in Blender 2.80)

There are no plans to remove bgl as quoted by brecht from this post.

Functions that simplified creation of geometry has been stripped away, yes.
Functions defined in the core profile will remain.

@kaio

I have now fixed the MathVis Addon according to your suggestion :slight_smile:
Thanks for helping!

cheers,
Gaia

1 Like