From 5cd3cfe5485390d8412b10a0e47d3be45bb22f3c Mon Sep 17 00:00:00 2001 From: Stefano Musumeci Date: Mon, 11 Aug 2014 17:24:21 +0200 Subject: [PATCH] TINYGL: Fixed a bug with triangle strip rendering. --- graphics/tinygl/zdirtyrect.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/graphics/tinygl/zdirtyrect.cpp b/graphics/tinygl/zdirtyrect.cpp index bd6256cfd50..1edf870cc1d 100644 --- a/graphics/tinygl/zdirtyrect.cpp +++ b/graphics/tinygl/zdirtyrect.cpp @@ -352,9 +352,18 @@ void RasterizationDrawCall::execute(bool restoreState) const { } break; case TGL_TRIANGLE_STRIP: - for(int i = 0; i < cnt; i += 2) { - gl_draw_triangle(c, &c->vertex[i], &c->vertex[i + 1], &c->vertex[i + 2]); - gl_draw_triangle(c, &c->vertex[i + 2], &c->vertex[i + 1], &c->vertex[i + 3]); + while (cnt >= 3) { + // needed to respect triangle orientation + switch (cnt & 1) { + case 0: + gl_draw_triangle(c, &c->vertex[2], &c->vertex[1], &c->vertex[0]); + break; + case 1: + gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); + break; + } + cnt--; + c->vertex++; } break; case TGL_TRIANGLE_FAN: