The wiki states "Most LÖVE functions return values and expect arguments in terms of pixels rather than density-independent units.
The units of love.graphics.getWidth, love.graphics.getHeight, love.mouse.getPosition, mouse events, love.touch.getPosition, and touch events are always in terms of pixels."
So, I'm nervous about the word "most".
Q1. How can I tell which LÖVE functions use pixels, and which use density-independent units?
Q2. Assume I'm making an app that should work on mobiles as well as desktops. Would you recommend I use pixels or density-independent units internally?
https://github.com/oddstream/lsol
Pixels vs density independent units
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Pixels vs density independent units
I'm not sure what the wiki says is correct; I think it's the other way around, unless you define c.window.usedpiscale = false in love.conf.
I think "most" includes all functions requiring graphical coordinates except those where it's obvious that the coordinates are the other ones, e.g. love.window.fromPixels obviously requires coordinates in pixels, while love.window.toPixels obviously requires coordinates in device-independent units.
As for what to use internally, it's hard to say but most likely DIU will be better in the long run.
I think "most" includes all functions requiring graphical coordinates except those where it's obvious that the coordinates are the other ones, e.g. love.window.fromPixels obviously requires coordinates in pixels, while love.window.toPixels obviously requires coordinates in device-independent units.
As for what to use internally, it's hard to say but most likely DIU will be better in the long run.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Pixels vs density independent units
love.graphics APIs (except those with "Pixel" in the name, like Texture:getPixelDimensions) return DPI-scaled a.k.a. density independent units, unless t.window.usedpiscale = false.
ImageData (via the love.image module) is the main thing that only uses pixels, since it doesn't interact with the screen. Pixel shaders also use pixels for things like the pixel coordinate value.
The love.window.toPixels wiki page (where the quote is from) is outdated - love used to only use pixels, but that changed in love 11, and that API page hasn't been updated.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 9 guests