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