Skip to content

Commit 6e09836

Browse files
committed
make triangles ~ 15% faster via GL_TRIANGLES and avoiding glLineDash when possible
1 parent 61e79f6 commit 6e09836

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

nodebox/graphics/context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,11 @@ def triangle(x1, y1, x2, y2, x3, y3, **kwargs):
609609
if clr is not None and (i==0 or strokewidth > 0):
610610
if i == 1:
611611
glLineWidth(strokewidth)
612-
glLineDash(strokestyle)
612+
if strokestyle != _strokestyle:
613+
glLineDash(strokestyle)
613614
glColor4f(clr[0], clr[1], clr[2], clr[3] * _alpha)
614615
# Note: this performs equally well as when using precompile().
615-
glBegin((GL_POLYGON, GL_LINE_LOOP)[i])
616+
glBegin((GL_TRIANGLES, GL_LINE_LOOP)[i])
616617
glVertex2f(x1, y1)
617618
glVertex2f(x2, y2)
618619
glVertex2f(x3, y3)

0 commit comments

Comments
 (0)