Line problem on amd and supertoast

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
elbrunzy
Prole
Posts: 12
Joined: Sun May 03, 2015 5:29 am

Line problem on amd and supertoast

Post by elbrunzy »

I'm coding a game and lately started to work on the menu, so I made a small lib to help me drawing box and menu element. So I was showing it to the person doing the gfx when I noticed there is a line issue only on her laptop. I realised it was an amd radeon card and I never tested the game on such hardware (only nvidia and intel), so I did test on another r5 240 where I could reproduce the issue. The problem is that line horizontal are always one pixel lower than with nvidia or intel gpu. Quads and other drawable elements (text, canvas, whatnot) are okay, it only seem to affect line horizontality, verticality is allright.

Here is an example of what it look like on nvidia and intel where the horizontal line are ok, and on amd where they are one pixel too low
imageprob.png
imageprob.png (25.24 KiB) Viewed 4826 times
I've did some research on the forum but found nothing, maybe I am not searching the right keywords ? Also I'm using 0.10.2 (Super Toast), maybe it was a small glitch that could be fixed into another version of love2d.

You might have noticed that I allow the user to change the resolution of the screen, but it's only a framebuffer that I zoom from the original window of 320x240 :
I declare the window with : love.window.setMode(320,240,{vsync=true, fullscreen=false; resizable=false})
then zoom it with this : love.graphics.draw(frameBuffer2,0,0,0,configGFXmode,configGFXmode)
but the glitch is also present on 320x240.

Any input would be much appreciated as I've tried nothing and I'm all out of ideas. :death:
User avatar
pgimeno
Party member
Posts: 3549
Joined: Sun Oct 18, 2015 2:58 pm

Re: Line problem on amd and supertoast

Post by pgimeno »

It may be a difference in rounding between the two platforms, nothing too unexpected. Are you drawing the lines between pixel centres? What linestyle are you using?
User avatar
elbrunzy
Prole
Posts: 12
Joined: Sun May 03, 2015 5:29 am

Re: Line problem on amd and supertoast

Post by elbrunzy »

Hi pgimeno, thanks alot for taking the time to give me some pointers, it's much appreciated.

the style I have been using is : love.graphics.setLineStyle("rough"), I see there is other line style I could fiddle around in the help to fix the video card inconsistency. I can maybe try using smooth line, as I don't use diagonal and see what it does. I guess by drawing line between pixel you mean not using integer ? I don't think I do.

Here is the a sample code to draw the box around the player sprite, maybe I am doing something wrong ? If I made no mistake, I did put the according value in comment for the code sample.

Code: Select all

drawBox(11,21,70,90,0) 

function drawBox(x,y,xd,yd,mode)
	if mode == 0 then -- recessed
		love.graphics.setColor( 192, 64, 64, 255)
		love.graphics.line(xd,y, xd,yd) -- 70, 21, 70, 90
		love.graphics.line(x,yd, xd,yd) -- 11,90, 70, 90
		love.graphics.setColor( 128, 32, 32, 255)
		love.graphics.line(x,y-1, x,yd) -- 11, 21-1, 11, 90
		love.graphics.line(x,y, xd,y) -- 11, 21, 70, 21
	end
...
I don't know where rounding could occur. I always draw line from left to right and top to bottom, is it not ideal?

I have seen no easy way from love2d to detect video card and patch code accordingly, and I'm not sure it's a good idea to go this way.

Also I'm all stressed out now as I realize I should had put my thread in Support and Development instead, maybe a mod could move it? :oops:
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Line problem on amd and supertoast

Post by grump »

Try adding .5 to your line coordinates to put the endpoints on pixel centers. ...although it shouldn't matter with rough linestyle afaik
User avatar
elbrunzy
Prole
Posts: 12
Joined: Sun May 03, 2015 5:29 am

Re: Line problem on amd and supertoast

Post by elbrunzy »

so I did try to revert to baby inspector or upgrade to mysterious mysteries, same problem. Using smooth only make line double as them tiniest :ultrashocked: and setting width to 1 did not help (must be 1 by default anyway).

For some reason adding (or in fact subtracting) .5 at some places did allow to fix it ! It was a real puzzle to find the correct melange that allow the nvidia and amd to display the same, but it would not be fun if it was easy :crazy:

So thank you alot grump and pgimeno, I'm ever so glad my problem is solved very much thank to you. In a way that I did not expected but satisfy me plenty!!! :awesome:
User avatar
pgimeno
Party member
Posts: 3549
Joined: Sun Oct 18, 2015 2:58 pm

Re: Line problem on amd and supertoast

Post by pgimeno »

See viewtopic.php?p=199019#p199019 for an explanation :) (the explanation applies to "smooth" mode, but the principle about pixel centres is the same).

"rough" is basically forcing rounding, but that rounding might happen in different directions for different hardware.
Post Reply

Who is online

Users browsing this forum: No registered users and 102 guests