From ba5402733598259ecc69a7376dd0199489161d4e Mon Sep 17 00:00:00 2001 From: Gaurav Tiwary <97665755+Gaurav-1306@users.noreply.github.com> Date: Sat, 30 Sep 2023 17:48:50 +0530 Subject: [PATCH 1/2] fixed issue #6440 --- src/webgl/p5.RendererGL.Immediate.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/webgl/p5.RendererGL.Immediate.js b/src/webgl/p5.RendererGL.Immediate.js index 9c47730078..ef186bf11d 100644 --- a/src/webgl/p5.RendererGL.Immediate.js +++ b/src/webgl/p5.RendererGL.Immediate.js @@ -205,6 +205,12 @@ p5.RendererGL.prototype.endShape = function( this._processVertices(...arguments); this.isProcessingVertices = false; + // Check the number of vertices and if equal to 3 + // Change the shapemode to traingle + if (this.immediateMode.geometry.vertices.length === 3) { + this.immediateMode.shapeMode === constants.TRIANGLES; + } + // LINE_STRIP and LINES are not used for rendering, instead // they only indicate a way to modify vertices during the _processVertices() step if ( From 617e16ee1cd01aa24e0c3278c063c162a0802857 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwary <97665755+Gaurav-1306@users.noreply.github.com> Date: Mon, 2 Oct 2023 20:17:24 +0530 Subject: [PATCH 2/2] made the nesscary changes --- src/webgl/p5.RendererGL.Immediate.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/webgl/p5.RendererGL.Immediate.js b/src/webgl/p5.RendererGL.Immediate.js index ef186bf11d..5a2beaf990 100644 --- a/src/webgl/p5.RendererGL.Immediate.js +++ b/src/webgl/p5.RendererGL.Immediate.js @@ -201,16 +201,19 @@ p5.RendererGL.prototype.endShape = function( ); return this; } + // When we are drawing a shape then the shape mode is TESS, + // but in case of triangle we can skip the breaking into small triangle + // this can optimize performance by skipping the step of breaking it into triangles + if (this.immediateMode.geometry.vertices.length === 3 && + this.immediateMode.shapeMode === constants.TESS + ) { + this.immediateMode.shapeMode === constants.TRIANGLES; + } + this.isProcessingVertices = true; this._processVertices(...arguments); this.isProcessingVertices = false; - // Check the number of vertices and if equal to 3 - // Change the shapemode to traingle - if (this.immediateMode.geometry.vertices.length === 3) { - this.immediateMode.shapeMode === constants.TRIANGLES; - } - // LINE_STRIP and LINES are not used for rendering, instead // they only indicate a way to modify vertices during the _processVertices() step if (