Sign in to follow this  
Twelve47Kevin

forceCanvas property of PIXI.Application having no affect.

Recommended Posts

G.App = new PIXI.Application({forceCanvas: true, width: w, height:h, transparent: true});

console.log(G.App.renderer.type);

This always prints "1"  for WebGL.  and not "2" for canvas.  Why isn't canvas being used here?  I'm using the latest v5 version of Pixi.js

Share this post


Link to post
Share on other sites

Hello,

how to set the canvas renderer properly? Even if I have installed pixi.js-legacy or pixi/canvas-renderer and set forceCanvas to true while creating the app, it still have webgl renderer.

Share this post


Link to post
Share on other sites

Hello Ivan,

I was able to make it work by assigning CanvasRenderer as type to temp variable - then also app renderer has changed but now the error occurs: Uncaught TypeError: displayObject.renderCanvas is not a function

Edited by MichalGo

Share this post


Link to post
Share on other sites

If you work with individual pixi packages you have to be aware about bundles

https://github.com/pixijs/pixi.js/blob/dev/bundles/pixi.js/src/index.js

https://github.com/pixijs/pixi.js/blob/dev/bundles/pixi.js-legacy/src/index.js

You can use only "@pixi/canvas-renderer" if you are ready to write all display scene related functions yourself.

The big problem with ES6 imports/exports is that this approach doesnt care about initialization of dependencies. PixiJS is not a framework, it does not have dependency injection but it uses a few internal dependencies that make it whole. That makes work of library and plugin maintainers hell.

1. People use npm, React and webpack

2. People are convinced that is our problem to deal with the fact that they use webpack.

3. People require extra documentation from us to make their apps work with pixi through treeshaking bundler

And you know what? We are ready to do it, because we love our community! Just not right now, maybe in a year or a few, and only if there will be more people to help us. Its a work in progress at the moment.

Here's a thread about it: 

 

Alternatively: Throw it all out, use vanillaJS and single file we supply in release: https://github.com/pixijs/pixi.js/releases/tag/v5.2.1

Share this post


Link to post
Share on other sites

Regarding your case - you are doing something wrong. just include "pixi.js-legacy" somewhere , and it should register all renderers in autodetect. Unless you somehow stumbled across a bug with two pixies alive (pixi.js 5.2.0, pixi-legacy 5.2.1 or something like that). In that case, erase node_modules and package.lock and reinstall it.

Edited by ivan.popelyshev

Share this post


Link to post
Share on other sites

Hello Ivan. I installed pixi.js-legacy and used it while creating the app (PIXI.Application) and set forceCanvas to true and it works now thanks. I have one more question. I use only PIXI.Application from pixi.js-legacy and the rest from pixi.js - is that good or should be changed?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.