gpu.2.py 477 B

123456789101112131415161718192021
  1. """
  2. 3D Lines with Single Color
  3. --------------------------
  4. """
  5. import bpy
  6. import gpu
  7. from gpu_extras.batch import batch_for_shader
  8. coords = [(1, 1, 1), (-2, 0, 0), (-2, -1, 3), (0, 1, 1)]
  9. shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
  10. batch = batch_for_shader(shader, 'LINES', {"pos": coords})
  11. def draw():
  12. shader.bind()
  13. shader.uniform_float("color", (1, 1, 0, 1))
  14. batch.draw(shader)
  15. bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')