Android - Low resolution pixel perfect rendering?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
LeviathaninWaves
Prole
Posts: 9
Joined: Sun Jul 17, 2022 12:46 am

Android - Low resolution pixel perfect rendering?

Post 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
Attachments
Screenshot_20220716-195805.jpg
Screenshot_20220716-195805.jpg (147.01 KiB) Viewed 2894 times
Last edited by LeviathaninWaves on Sun Jul 17, 2022 3:59 am, edited 1 time in total.
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Android - Low resolution pixel perfect rendering?

Post by ReFreezed »

When you call push:setupScreen(), does setting the highdpi flag to false fix the issue?
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
LeviathaninWaves
Prole
Posts: 9
Joined: Sun Jul 17, 2022 12:46 am

Re: Android - Low resolution pixel perfect rendering?

Post 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.
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: Android - Low resolution pixel perfect rendering?

Post 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.
Kitsune64
Prole
Posts: 9
Joined: Mon Jul 12, 2021 3:33 pm

Re: Android - Low resolution pixel perfect rendering?

Post 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 1530 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
Attachments
Archive.love
VGA 256 colors Rendering for Android. Love 11.
(47.02 KiB) Downloaded 58 times
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests