MCPcopy
hub / github.com/processing/p5.js / _renderPass

Method _renderPass

src/image/filterRenderer2D.js:393–441  ·  view source on GitHub ↗

* Prepares and runs the full-screen quad draw call.

()

Source from the content-addressed store, hash-verified

391 * Prepares and runs the full-screen quad draw call.
392 */
393 _renderPass() {
394 const gl = this.gl;
395 this._shader.bindShader('fill');
396 const pixelDensity = this.parentRenderer.pixelDensity ?
397 this.parentRenderer.pixelDensity() : 1;
398
399 const texelSize = [
400 1 / (this.parentRenderer.width * pixelDensity),
401 1 / (this.parentRenderer.height * pixelDensity)
402 ];
403
404 const canvasTexture = this.canvasTexture;
405
406 // Set uniforms for the shader
407 this._shader.setUniform('tex0', canvasTexture);
408 this._shader.setUniform('texelSize', texelSize);
409 this._shader.setUniform('canvasSize', [this.parentRenderer.width, this.parentRenderer.height]);
410 this._shader.setUniform('radius', Math.max(1, this.filterParameter));
411 this._shader.setUniform('filterParameter', this.filterParameter);
412 this._shader.setDefaultUniforms();
413
414 this.parentRenderer.states.setValue('rectMode', constants.CORNER);
415 this.parentRenderer.states.setValue('imageMode', constants.CORNER);
416 this.parentRenderer.blendMode(constants.BLEND);
417 this.parentRenderer.resetMatrix();
418
419
420 const identityMatrix = [1, 0, 0, 0,
421 0, 1, 0, 0,
422 0, 0, 1, 0,
423 0, 0, 0, 1];
424 this._shader.setUniform('uModelViewMatrix', identityMatrix);
425 this._shader.setUniform('uProjectionMatrix', identityMatrix);
426
427 // Bind and enable vertex attributes
428 gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
429 this._shader.enableAttrib(this._shader.attributes.aPosition, 2);
430
431 gl.bindBuffer(gl.ARRAY_BUFFER, this.texcoordBuffer);
432 this._shader.enableAttrib(this._shader.attributes.aTexCoord, 2);
433
434 this._shader.bindTextures();
435 this._renderer._disableRemainingAttributes(this._shader);
436
437 // Draw the quad
438 gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
439 // Unbind the shader
440 this._shader.unbindShader();
441 }
442
443 /**
444 * Applies the current filter operation. If the filter requires multiple passes (e.g. blur),

Callers 1

applyFilterMethod · 0.95

Calls 11

bindShaderMethod · 0.80
setUniformMethod · 0.80
setDefaultUniformsMethod · 0.80
enableAttribMethod · 0.80
bindTexturesMethod · 0.80
unbindShaderMethod · 0.80
pixelDensityMethod · 0.45
setValueMethod · 0.45
blendModeMethod · 0.45
resetMatrixMethod · 0.45

Tested by

no test coverage detected