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

window.devicePixelRatio support? #2833

Closed
mrdoob opened this issue Dec 23, 2012 · 6 comments
Closed

window.devicePixelRatio support? #2833

mrdoob opened this issue Dec 23, 2012 · 6 comments

Comments

@mrdoob
Copy link
Owner

mrdoob commented Dec 23, 2012

I'm struggling to decide whether three.js should handle window.devicePixelRatio internally or not.

This would mean adding this kind of code to each renderer:

var ratio = window.devicePixelRatio || 1;

canvas.width = width * ratio;
canvas.height = height * ratio;

canvas.style.width = width + 'px';
canvas.style.height = height + 'px';

The good thing is that people wouldn't have to worry about having to implement it on their end. But I don't know what the bad things would be. I'm sure this could lead to some confusion at some point.

@mrdoob
Copy link
Owner Author

mrdoob commented Dec 23, 2012

Uhm... probably just simpler to implement it as a renderer flag such as:

var renderer = new THREE.CanvasRenderer( { useDevicePixelRatio: false } ); // true by default

@mrdoob
Copy link
Owner Author

mrdoob commented Dec 23, 2012

Going for a walk made me come up with a better implementation:

var renderer = new THREE.CanvasRenderer( { devicePixelRatio: 1 } ); // if undefined then it gets set by using window.devicePixelRatio

@mrdoob
Copy link
Owner Author

mrdoob commented Dec 23, 2012

And... implemented. 2feae0e

@mrdoob mrdoob closed this as completed Dec 23, 2012
@gprasanth
Copy link

Thanks. This fix helped me -

threejs fix low fps for high dpi devices like macbook pro

p.s just leaving a comment here for people searching for it

@that-ben
Copy link
Contributor

MY FACE WHEN I DISCOVERED renderer.setPixelRatio(1)

Thanks Ricardo for talking about this! That small detail by itself made my 3D FPS implementation achieve almost 60fps without changing anything else. Incredibly useful for mobile devices and horrible laptop GPU's.

jaw drop wtf wow

@mrdoob
Copy link
Owner Author

mrdoob commented Mar 17, 2016

😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants