diff options
author | Jacques Lucke <mail@jlucke.com> | 2018-11-05 21:26:53 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2018-11-05 21:28:28 +0300 |
commit | a8e9959e07a05f08cbe28a3b37c0b24874f6f76f (patch) | |
tree | 56f012d4ec7ab60c0940d8eaa1c3af71464f54c1 /doc/python_api/examples/gpu.2.py | |
parent | abbe4df30164b6a73c3d05efca1ecbacaf5a0476 (diff) |
API Docs: gpu api introduction + examples
Diffstat (limited to 'doc/python_api/examples/gpu.2.py')
-rw-r--r-- | doc/python_api/examples/gpu.2.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/python_api/examples/gpu.2.py b/doc/python_api/examples/gpu.2.py new file mode 100644 index 00000000000..8188110d096 --- /dev/null +++ b/doc/python_api/examples/gpu.2.py @@ -0,0 +1,19 @@ +""" +3D Lines with Single Color +-------------------------- +""" +import bpy +import gpu +from gpu_extras.batch import batch_for_shader + +coords = [(1, 1, 1), (-2, 0, 0), (-2, -1, 3), (0, 1, 1)] +shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') +batch = batch_for_shader(shader, 'LINES', {"pos" : coords}) + +def draw(): + shader.bind() + shader.uniform_float("color", (1, 1, 0, 1)) + batch.draw(shader) + +bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW') + |