Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the Renderer's Resolution #3810

Closed
ghost opened this issue Mar 6, 2017 · 16 comments
Closed

Changing the Renderer's Resolution #3810

ghost opened this issue Mar 6, 2017 · 16 comments
Labels
🤔 Question User question, similar to Help Wanted or Needs Help. These can be addressed whenever someone has tim

Comments

@ghost
Copy link

ghost commented Mar 6, 2017

Is there a way to update the renderer's resolution? I tried renderer.resolution = window.devicePixelRatio, but it just makes the screen flash white.

@themoonrat themoonrat added the 🤔 Question User question, similar to Help Wanted or Needs Help. These can be addressed whenever someone has tim label Mar 6, 2017
@ghost
Copy link
Author

ghost commented Mar 6, 2017

The best temporary workaround that I came up with is to destroy and re-create the renderer, passing the new resolution to autoDetectRenderer. This works but maybe isn't the most efficient way to do it. Also, there's maybe still an issue with repeatedly destroying and re-creating the renderer: #2233

It seems like there should be a simple function call to do this, like renderer.setResolution, that minimizes the amount of extra processing and dead resources.

@GoodBoyDigital
Copy link
Member

Hi @jaspervaz! Curious about what is your use-case for this is?
Cheers!

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Mar 6, 2017

Yes, it is. I will make that function later, but this might work for now:

renderer.resolution = 2;
renderer.rootRenderTarget.resolution = 2;
renderer.resize(w-1, h);
renderer.resize(w, h);

Don't forget to update ALL FILTERS RESOLUTIONS.

@themoonrat
Copy link
Member

And don't forget to update the interaction plugin resolution too

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Mar 6, 2017

@jaspervaz

EXACTLY, Zoom changes, that's what i want to do too :)
For now assume that "renderer.screen" is rectangle of screen in logical coords, while "renderer.view" is canvas and thus width and height are multiplied by resolution.

@ghost
Copy link
Author

ghost commented Mar 7, 2017

Check like this to make it work for both renderers:

if (renderer.rootRenderTarget) { renderer.rootRenderTarget.resolution = newResoultion; }

Also, it seems to work the same without the following line, I think because zooming changes both the resolution and the window dimensions, but maybe other use cases require it:

renderer.resize(w-1, h);

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Mar 13, 2017

Yes, I agree.

@starInEcust
Copy link

@ivanpopelyshev I want to scale the screen.
Using your method will make the canvas blurred.
Using my method resolution can not be greater than 20

https://jsfiddle.net/starCoding/p49u34hd/8/

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Mar 15, 2017

@starInEcust Why do you need resolution more than 20? Resolution is not about scaling, its browser zoom. Scale is part of stage transform.

@starInEcust
Copy link

@ivanpopelyshev I want to enlarge the the renderer and keep the text and svg pictures won't be distorted

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Mar 16, 2017

@starInEcust I solved that kind of issues by manual adjusting of scale and font size.

There's also new solution: use SDF fonts. https://github.com/PixelsCommander/pixi-sdf-text

@starInEcust
Copy link

@ivanpopelyshev how about svg? I just want to make a text editor with cool animation, in the print preview can zoom in and out, but does not affect the typesetting.
And is there any problem with the use of resolution magnification?

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Mar 16, 2017

That's very unusual use-case for pixi. You have to change zoom through "stage.scale" and adjust resolution only of SVG and text, not the resolution of whole renderer. In your case screen size of renderer is fixed, and when you change resolution, canvas dimensions are becoming too big, you're hitting 16k x 16k pixels size!

I didnt use SVG in pixi so I dont know how to adjust resolution for it :)

@starInEcust
Copy link

Thank you very much!Maybe I should open an issue to discuss this question :(

@englercj
Copy link
Member

Going to close this issue since it seems answered, feel free to open another if you have another question!

@lock
Copy link

lock bot commented Feb 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤔 Question User question, similar to Help Wanted or Needs Help. These can be addressed whenever someone has tim
Projects
None yet
Development

No branches or pull requests

5 participants