Copies the shader from one drawing context to another.
Each p5.Shader object must be compiled by calling shader() before it can run. Compilation happens in a drawing context which is usually the main canvas or an instance of p5.Graphics. A shader can only be used in the context where it was compiled. The copyToContext() method compiles the shader again and copies it to another drawing context where it can be reused.
The parameter, context, is the drawing context where the shader will be used. The shader can be copied to an instance of p5.Graphics, as in myShader.copyToContext(pg). The shader can also be copied from a p5.Graphics object to the main canvas using the window variable, as in myShader.copyToContext(window).
Note: A p5.Shader object created with createShader(), createFilterShader(), or loadShader() can be used directly with a p5.Framebuffer object created with createFramebuffer(). Both objects have the same context as the main canvas.
Ejemplos
Sintaxis
copyToContext(context)
Parámetros
WebGL context for the copied shader.
Returns
Referencias Relacionadas
ambientMaterial
Establece el color ambiental del material de la superficie de las formas.
createFilterShader
Crea un objeto p5.Shader para ser utilizado con la función filter().
createShader
Crea un nuevo objeto p5.Shader.
emissiveMaterial
Establece el color de emisión del material de la superficie de las formas.