question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to copy Webgl content to another canvas element without create new Pixi.application

See original GitHub issue

Hi all,

How to do the result like pure html canvas for redraw canvasA’s content to canvasB.

Here is the result i wished:

var canvasA = document.getElementById("canvasA");
var ctxA = canvasA.getContext("2d");
//ctxA drawsomthing......
...
...

var canvasB = document.getElementById("canvasB");
var ctxB = canvasB.getContext("2d");

ctxB.drawImage(canvasA, 0, 0, canvasB.width, canvasB.height);

How to do it in Pixi.jsV4 By the way, my renderer is ‘Webgl context’

Thanks a lot!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
vicchoutwcommented, Dec 21, 2017

Really helpful, thanks

1reaction
ivanpopelyshevcommented, Dec 21, 2017

Application is a mashup: https://github.com/pixijs/pixi.js/blob/dev/src/core/Application.js , it has Renderer, ticker and stage inside.

Juts make two renderers instead of one and render the same stage.

var renderer1 = new PIXI.WebGLRenderer(100, 100, { view : ... } );
var renderer2 = new PIXI.WebGLRenderer(100, 100, { view : ... } );
var stage = new PIXI.Container();

function RAF() {
    renderer1.render(stage);
    renderer2.render(stage);
    requestAnimationFrame(RAF);
}

requestAnimationFrame(RAF);

You can customize some params, like transform applied to stage, if you look at render documentation

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to change the canvas element of a WebGL context?
Moving WebGL contexts to different canvases is not currently possible. Does this technique not work for you?
Read more >
How to use PIXI.Application() when there is already a canvas ...
I am using pixi.js version 5.2.0 to create a word app at Facebook and your library ... But I already have a canvas...
Read more >
PIXI.Application - PixiJS API Documentation
Convenience class to create a new PixiJS application. This class automatically creates the renderer, ticker and root container. new PIXI.
Read more >
Building an Images Gallery using PixiJS and WebGL
Add the PixiJS library as a script in the HTML. Have a <canvas> element (or add it dynamically from Javascript), to render the...
Read more >
Pixi.js Tutorial For Complete Beginners - Create 2D ... - YouTube
In this tutorial, we're going to learn the fundamental parts of the Javascript library Pixi.js, such as creating and adding elements to the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found