NoHighDPI - Disable High DPI on Android devices
Posted: Wed Aug 21, 2019 7:16 pm
It's my first post in this community, sorry for anything
High DPI scaling on Android is very annoying, especially when you use both the Windows and Android to work with the same project.
There is a trick to solve this using love.window.fromPixels and love.window.toPixels, so I made this library to do this for you!
How to use
You just need to do this:
And voilà, you can use LÖVE normally without worrying about DPI scaling!
Manual mode
You can also use this library manually:
Using only "graphics" manually
Github page
High DPI scaling on Android is very annoying, especially when you use both the Windows and Android to work with the same project.
There is a trick to solve this using love.window.fromPixels and love.window.toPixels, so I made this library to do this for you!
How to use
You just need to do this:
Code: Select all
nohdpi = require "nohighdpi"
function love.load()
--Pass "graphics", "mouse" and/or "touch"
--as arguments to replace the given modules.
--If you don't give any arguments, then
--all modules will be replaced.
nohighdpi:replace()
end
Manual mode
You can also use this library manually:
Code: Select all
nohdpi = require "nohighdpi"
function love.load()
end
function love.draw()
--You can optionally give a custom resolution
nohdpi:start(800, 600)
--Draw your things here
love.graphics.circle("line", nohdpi:mouseX(), nohdpi:mouseY(), 5, 100)
--You can also change the resolution
nohdpi:rescale(1000, 675)
nohdpi:stop()
end
function love.update(dt)
end
function love.mousepressed(x, y, button, isTouch)
x, y = nohdpi:toResized(x, y)
--Use it normally. The same goes to mousereleased, touchpressed, touchreleased...
end
Code: Select all
nohdpi = require "nohighdpi"
function love.load()
nohdpi:replace("mouse", "touch")
end
function love.draw()
nohdpi:start()
love.graphics.circle("line", love.mouse.getX(), love.mouse.getY(), 5, 100)
nohdpi:stop()
end
function love.update(dt)
end
function love.mousepressed(x, y, button, isTouch)
end