Jump to content

Change resolution/renderer at runtime


Recommended Posts

I am currently trying to adapt the resolution of my game based on the framerate I'm getting on the first ~30 seconds. Basically, measure the framerate for the first seconds, and if it's too low, work with a smaller resolution.


Right now, this is the code I have:

    setResolution : function(resolution){        this.renderer.destroy();                var rendererOptions = {            resolution : resolution        };        this.renderer = new PIXI.WebGLRenderer(this.params.width,this.params.height,rendererOptions);                var parent = this.canvas.parentNode;        parent.insertBefore(this.renderer.view, this.canvas);        parent.removeChild(this.canvas);                this.canvas = this.renderer.view;        this.canvas.id = this.params.canvasId;    }

It works fine with a CanvasRenderer, but not with a WebGLRenderer, because of cached data. I'm getting this error:

Uncaught TypeError: Cannot read property 'data' of undefined

Now, I was wondering if there was a way to reset all this cached data so I can still use a WebGLRenderer.


Can anyone help?

Link to comment
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.

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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...