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

Method init

src/webgl/p5.Shader.js:499–520  ·  view source on GitHub ↗

* Creates, compiles, and links the shader based on its * sources for the vertex and fragment shaders (provided * to the constructor). Populates known attributes and * uniforms from the shader. * @chainable * @private

()

Source from the content-addressed store, hash-verified

497 * @private
498 */
499 init() {
500 // If the shader is uninitialized or context was lost
501 if (!this._initialized) {
502 try {
503 this._renderer._initShader(this); // Backend-specific shader init
504 } catch (err) {
505 throw new Error(
506 `Whoops! Something went wrong initializing the shader:\n${err.message || err}`
507 );
508 }
509
510 if (this.shaderType !== 'compute') {
511 this._loadAttributes();
512 }
513 this._loadUniforms();
514 this._renderer._finalizeShader(this);
515
516 this._initialized = true;
517 }
518
519 return this;
520 }
521
522 /**
523 * @private

Callers 5

bindShaderMethod · 0.95
setUniformMethod · 0.95
textFunction · 0.45
computeMethod · 0.45

Calls 4

_loadAttributesMethod · 0.95
_loadUniformsMethod · 0.95
_initShaderMethod · 0.45
_finalizeShaderMethod · 0.45

Tested by

no test coverage detected