lovebrew / lovepotion

LÖVE for Nintendo Homebrew
https://lovebrew.org
Other
552 stars 42 forks source link

[BUG] Alpha does not work properly when drawing to canvases #135

Closed Nehemek closed 3 years ago

Nehemek commented 3 years ago

Describe the bug

When setting an fractional alpha value with love.graphics.setColor() and drawing to a canvas, elements will be drawn with a wrong alpha value.

Expected behavior

Alpha should work on canvases the same way it works when drawing normally.

Relevant Code To Reproduce

The following code will produce the screenshot below:

function love.load()
    love.graphics.setBackgroundColor(0.8,0.75,1)
    love.graphics.set3D(false)
    canvas = love.graphics.newCanvas(200,240)
end

function love.draw(screen)
    if screen == "top" then
        love.graphics.setColor(1,1,1,1)
        love.graphics.circle("fill",100,60,16)
        love.graphics.setColor(1,1,1,.5)
        love.graphics.circle("fill",100,120,16)
        love.graphics.setColor(1,1,1,.2)
        love.graphics.circle("fill",100,180,16)

        love.graphics.setCanvas(canvas)
        love.graphics.clear(255,255,255,0)
        love.graphics.setColor(1,1,1,1)
        love.graphics.circle("fill",100,60,16)
        love.graphics.setColor(1,1,1,.5)
        love.graphics.circle("fill",100,120,16)
        love.graphics.setColor(1,1,1,.2)
        love.graphics.circle("fill",100,180,16)
        love.graphics.setCanvas()

        love.graphics.setColor(1,1,1,1)
        love.graphics.draw(canvas,200,0)
    end
end

function love.gamepadpressed(joystick, button)
    if button == "start" then love.event.quit() end
end

[Screenshots]

canvasalphaissue

System Info [Please complete the following information]:

System: 3ds v11.14.0-46U CFW: Luma v10.2.1 Method of execution: Homebrew App LÖVE Potion version: 2.0.0

TurtleP commented 3 years ago

How did you test this originally? Someone tested this on hardware (aside from me) and the circles appear to be fine.

Nehemek commented 3 years ago

Well, I took the screenshot minutes before submitting and did so in a o3DS. Also I'm sure it has been present in all the dev versions since the canvas fix (that's when I first noticed the issue). The code I ran is the exact one above and this also happens in my main project.

TurtleP commented 3 years ago

Fixed with commit 7892bfd