Fix #144700: Incorrect operator model draw example
The example script for the Model Draw Operator was out of date. It didn't used the polyline shader. This PR updates the example to use the polyline shader. Pull Request: https://projects.blender.org/blender/blender/pulls/144722
This commit is contained in:
@@ -15,15 +15,15 @@ def draw_callback_px(self, context):
|
|||||||
blf.draw(font_id, "Hello Word " + str(len(self.mouse_path)))
|
blf.draw(font_id, "Hello Word " + str(len(self.mouse_path)))
|
||||||
|
|
||||||
# 50% alpha, 2 pixel width line
|
# 50% alpha, 2 pixel width line
|
||||||
shader = gpu.shader.from_builtin('UNIFORM_COLOR')
|
|
||||||
gpu.state.blend_set('ALPHA')
|
gpu.state.blend_set('ALPHA')
|
||||||
gpu.state.line_width_set(2.0)
|
shader = gpu.shader.from_builtin('POLYLINE_UNIFORM_COLOR')
|
||||||
batch = batch_for_shader(shader, 'LINE_STRIP', {"pos": self.mouse_path})
|
|
||||||
shader.uniform_float("color", (0.0, 0.0, 0.0, 0.5))
|
shader.uniform_float("color", (0.0, 0.0, 0.0, 0.5))
|
||||||
|
shader.uniform_float("viewportSize", (context.area.width, context.area.height))
|
||||||
|
shader.uniform_float('lineWidth', 2.0)
|
||||||
|
batch = batch_for_shader(shader, 'LINE_STRIP', {"pos": self.mouse_path})
|
||||||
batch.draw(shader)
|
batch.draw(shader)
|
||||||
|
|
||||||
# restore opengl defaults
|
# restore gpu defaults
|
||||||
gpu.state.line_width_set(1.0)
|
|
||||||
gpu.state.blend_set('NONE')
|
gpu.state.blend_set('NONE')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user