Page 1 of 1

Android - Low resolution pixel perfect rendering?

Posted: Sun Jul 17, 2022 1:00 am
by LeviathaninWaves
So I'm having a very difficult time figuring this one out. My guess is the problem has something to do with DPI.

Anyways, I'd like to create a pixel art game with a resolution of 400 x 240. I'm trying to use the push library to deal with this and although the library appears to function, it seems unable to render each pixel accurately and uniformly. I tested the retro example included with push, I also tried drawing a diagonal line of pixels and the results for both are awful.

The screenshot is of the push example with very little tampering around in settings. The pixels are distorted. What gives?

EDIT: Solved! I made a few edits to the push example code. It renders very cleanly now

Code: Select all

        sysw, sysh = love.window.getDesktopDimensions()
	love.window.setMode(sysw, sysh, {resizable = false, fullscreen = true, highdpi = true, usedpiscale = false})
	push.setupScreen(64, 64, {upscale = "pixel-perfect", canvas = true, highdpi = false}) -- push resolution 64x64, pixel perfect scaling, drawn to a canvas

Re: Android - Low resolution pixel perfect rendering?

Posted: Sun Jul 17, 2022 3:22 am
by ReFreezed
When you call push:setupScreen(), does setting the highdpi flag to false fix the issue?

Re: Android - Low resolution pixel perfect rendering?

Posted: Sun Jul 17, 2022 3:39 am
by LeviathaninWaves
ReFreezed wrote: Sun Jul 17, 2022 3:22 am When you call push:setupScreen(), does setting the highdpi flag to false fix the issue?
It does not unfortunately.
EDIT: I solved this one thanks to your help. I'll update the original post with the solution.

Re: Android - Low resolution pixel perfect rendering?

Posted: Sun Jul 17, 2022 11:21 pm
by pgimeno
I wonder if an alternative solution that doesn't involve modifying push, would be to set t.window.usedpiscale = false in love.conf.

Re: Android - Low resolution pixel perfect rendering?

Posted: Tue Dec 13, 2022 10:32 am
by Kitsune64
Hi I have done one love file that run well on Android but not on Windows about the screen rendering.
It calculate the best scale for fit in screen in 1:1 and centering the game on Android (not on Windows and I don't know why)

You can try it!

Here an exemple with VGA resolution 320x200 but you can change it. The code use à font and a picture.
Screenshoot
Screenshoot
test.png (165.87 KiB) Viewed 1535 times

Code: Select all

function love.load()
   sysw, sysh = love.graphics.getDimensions()
	love.window.setMode(sysw, sysh, {resizable = false, fullscreen = true, highdpi = true})
	gameWidth=320
	gameHeight=200
	canvas = love.graphics.newCanvas(gameWidth,gameHeight)
	
	--Scaling to max with 1:1 aspect ratio
	for cpt=8, 1,-1 do
	    if(sysw/cpt >= gameWidth and sysh/cpt>= gameHeight)then
	         scale=cpt
	    break
	    end
	end
   image = love.graphics.newImage("Pics/Kyrandia.png")
   image:setFilter("nearest","nearest")
   font = love.graphics.newFont("Font/PixeloidMono.ttf", 7)
   font:setFilter("nearest","nearest")
end

function love.draw()
    canvas:setFilter("nearest","nearest")
	    love.graphics.setCanvas(canvas)
        love.graphics.clear(0, 0, 0, 0)
        love.graphics.setColor(0, 0,0)
        love.graphics.rectangle("fill", 0,0, gameWidth,gameHeight)
        love.graphics.setColor(1,1,1)
        love.graphics.draw(image,0,0)
        love.graphics.setFont(font)
      love.graphics.print("Bienvenu voyageur!",0,gameHeight-10)
    love.graphics.setCanvas()
    winPosX=(sysw-gameWidth*scale)/2
    winPosY=(sysh-gameHeight*scale)/2
    love.graphics.draw(canvas,winPosX,winPosY,0,scale,scale)
end