diff options
Diffstat (limited to 'doc/python_api/examples/gpu.6.py')
-rw-r--r-- | doc/python_api/examples/gpu.6.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/doc/python_api/examples/gpu.6.py b/doc/python_api/examples/gpu.6.py new file mode 100644 index 00000000000..df28d801960 --- /dev/null +++ b/doc/python_api/examples/gpu.6.py @@ -0,0 +1,24 @@ +""" +2D Rectangle +------------ +""" +import bpy +import gpu +from gpu_extras.batch import batch_for_shader + +vertices = ( + (100, 100), (300, 100), + (100, 200), (300, 200)) + +indices = ( + (0, 1, 2), (2, 1, 3)) + +shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') +batch = batch_for_shader(shader, 'TRIS', {"pos" : vertices}, indices=indices) + +def draw(): + shader.bind() + shader.uniform_float("color", (0, 0.5, 0.5, 1.0)) + batch.draw(shader) + +bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')
\ No newline at end of file |