Blender Ktisu: Fix Drawing Sequence Line #157
@ -30,7 +30,7 @@ from gpu_extras.batch import batch_for_shader
|
|||||||
# Shaders and batches
|
# Shaders and batches
|
||||||
|
|
||||||
rect_coords = ((0, 0), (1, 0), (1, 1), (0, 1))
|
rect_coords = ((0, 0), (1, 0), (1, 1), (0, 1))
|
||||||
|
indices = ((0, 1, 2), (2, 3, 0))
|
||||||
# Setup shaders only if Blender runs in the foreground.
|
# Setup shaders only if Blender runs in the foreground.
|
||||||
# If running in the background, no handles are registered, as drawing extra UI
|
# If running in the background, no handles are registered, as drawing extra UI
|
||||||
# elements does not make sense.
|
# elements does not make sense.
|
||||||
@ -42,7 +42,7 @@ else:
|
|||||||
if not bpy.app.background:
|
if not bpy.app.background:
|
||||||
ucolor_2d_shader = gpu.shader.from_builtin(color_key)
|
ucolor_2d_shader = gpu.shader.from_builtin(color_key)
|
||||||
ucolor_2d_rect_batch = batch_for_shader(
|
ucolor_2d_rect_batch = batch_for_shader(
|
||||||
ucolor_2d_shader, "TRI_FAN", {"pos": rect_coords}
|
ucolor_2d_shader, "TRIS", {"pos": rect_coords}, indices=indices
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -58,8 +58,6 @@ def draw_line(position: Float2, size: Float2, color: Float4):
|
|||||||
gpu.matrix.translate(position)
|
gpu.matrix.translate(position)
|
||||||
gpu.matrix.scale(size)
|
gpu.matrix.scale(size)
|
||||||
|
|
||||||
# Render a colored rectangle
|
|
||||||
ucolor_2d_shader.bind()
|
|
||||||
ucolor_2d_shader.uniform_float("color", color)
|
ucolor_2d_shader.uniform_float("color", color)
|
||||||
ucolor_2d_rect_batch.draw(ucolor_2d_shader)
|
ucolor_2d_rect_batch.draw(ucolor_2d_shader)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user