Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
add strokes back to WebGL mode
  • Loading branch information
lukeplowden committed Jun 16, 2025
commit f0875d795be9297bcdf9b312dffcafeda4741536
42 changes: 17 additions & 25 deletions src/webgl/p5.RendererGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,37 +270,29 @@ class RendererGL extends Renderer3D {
}
}

// Stroke version for now:
//
// {
// const gl = this.GL;
// // move this to _drawBuffers ?
// if (count === 1) {
// gl.drawArrays(gl.TRIANGLES, 0, geometry.lineVertices.length / 3);
// } else {
// try {
// gl.drawArraysInstanced(
// gl.TRIANGLES,
// 0,
// geometry.lineVertices.length / 3,
// count
// );
// } catch (e) {
// console.log(
// "🌸 p5.js says: Instancing is only supported in WebGL2 mode"
// );
// }
// }
// }

_drawBuffers(geometry, { mode = constants.TRIANGLES, count }) {
const gl = this.GL;
const glBuffers = this.geometryBufferCache.getCached(geometry);
//console.log(glBuffers);

if (!glBuffers) return;

if (glBuffers.indexBuffer) {
if (this._curShader.shaderType === 'stroke'){
if (count === 1) {
gl.drawArrays(gl.TRIANGLES, 0, geometry.lineVertices.length / 3);
} else {
try {
gl.drawArraysInstanced(
gl.TRIANGLES,
0,
geometry.lineVertices.length / 3,
count
);
} catch (e) {
console.log(
"🌸 p5.js says: Instancing is only supported in WebGL2 mode"
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be missing a } here

} else if (glBuffers.indexBuffer) {
this._bindBuffer(glBuffers.indexBuffer, gl.ELEMENT_ARRAY_BUFFER);

// If this model is using a Uint32Array we need to ensure the
Expand Down
Loading