Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/webgl/p5.RendererGL.Retained.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,26 @@ p5.RendererGL.prototype._drawElements = function(drawMode, gId) {
p5.RendererGL.prototype._drawPoints = function(vertices, pointBuffers) {
const gl = this.GL;
const pointShader = this._getImmediatePointShader();
this._setPointUniforms(pointShader);

// Prepare position and optional per-vertex color buffers
if (Array.isArray(pointBuffers)) {
const geom = this.immediateMode.geometry;

if (geom.vertices !== vertices) {
geom.vertices = vertices;
geom.dirtyFlags.vertices = true;
if (geom.vertexStrokeColors.length > 0) {
geom.vertexStrokeColors.length = 0;
geom.dirtyFlags.vertexStrokeColors = true;
}
}

this._setPointUniforms(pointShader);

for (const buff of pointBuffers) {
buff._prepareBuffer(this.immediateMode.geometry, pointShader);
buff._prepareBuffer(geom, pointShader);
}
} else {
// Backward compatibility if a raw GL buffer is passed
this._setPointUniforms(pointShader);
this._bindBuffer(
pointBuffers,
gl.ARRAY_BUFFER,
Expand Down
29 changes: 29 additions & 0 deletions test/unit/visual/cases/webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,34 @@ visualSuite('WebGL', function() {
p5.box(30);
screenshot();
});

visualTest(
'Per-vertex POINTS color does not leak into point()',
(p5, screenshot) => {
p5.createCanvas(100, 100, p5.WEBGL);
p5.background(0);
p5.strokeWeight(8);

p5.beginShape(p5.POINTS);
p5.stroke(255, 0, 0);
p5.vertex(-30, -20, 0);
p5.stroke(0, 255, 0);
p5.vertex(-10, -20, 0);
p5.stroke(0, 0, 255);
p5.vertex(10, -20, 0);
p5.stroke(255, 255, 0);
p5.vertex(30, -20, 0);
p5.endShape();

p5.stroke(255, 0, 255);
p5.point(-20, 20, 0);
p5.stroke(0, 255, 255);
p5.point(0, 20, 0);
p5.stroke(255);
p5.point(20, 20, 0);

screenshot();
}
);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading