Skip to content
Closed
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
17 changes: 17 additions & 0 deletions src/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,23 @@ class p5 {

// This is a pointer to our global mode p5 instance, if we're in
// global mode.
/**
* A variable that stores a reference to the sketch's p5 instance.
*
* In global mode, `p5.instance` refers to the sketch's p5 instance. It's
* useful when a function or method needs a reference to the sketch. For
* example, it can be used with
* <a href="#/p5.Shader/copyToContext">copyToContext()</a> to copy a
* <a href="#/p5.Shader">p5.Shader</a> object from a
* <a href="#/p5.Graphics">p5.Graphics</a> object to the main canvas.
*
* Note: `p5.instance` is only available in global mode. In instance mode,
* use the instance variable instead.
*
* @property {p5} instance
* @for p5
* @readOnly
*/
p5.instance = null;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/webgl/p5.Shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ p5.Shader = class {
* <a href="#/p5.Graphics">p5.Graphics</a>, as in
* `myShader.copyToContext(pg)`. The shader can also be copied from a
* <a href="#/p5.Graphics">p5.Graphics</a> object to the main canvas using
* the `window` variable, as in `myShader.copyToContext(window)`.
* <a href="#/p5/instance">p5.instance</a>, as in `myShader.copyToContext(p5.instance)`.
*
* Note: A <a href="#/p5.Shader">p5.Shader</a> object created with
* <a href="#/p5/createShader">createShader()</a>,
Expand Down Expand Up @@ -729,7 +729,7 @@ p5.Shader = class {
* pg.shader(original);
*
* // Copy the original shader to the main canvas.
* copied = original.copyToContext(window);
* copied = original.copyToContext(p5.instance);
*
* // Apply the copied shader to the main canvas.
* shader(copied);
Expand Down