Page 1 of 1

clear canvas in coroutine not work

Posted: Fri Dec 02, 2016 11:10 pm
by zaher
Last clear in coroutine not effects until i draw something after it or before it without yield, the circle in this example still shown
I tested in Windows 8.1, Love 10.2, 10.1, 9.1 same bug video card "Intel(R) HD Graphics"
but when I tested in linux debian jessie, in virtual machine it work fine (result blank screen)

Code: Select all

co = nil
buffer = nil

program = function()
    love.graphics.setColor({255, 255, 255})
    love.graphics.circle("line", 100, 100, 50)
    coroutine.yield()
    --love.graphics.circle("line", 100, 100, 50)
    love.graphics.clear() --not cleared
    coroutine.yield()
    --love.graphics.points(10, 10) --<-- it clear now
end

local function resume()
    if co then
        if coroutine.status(co) ~= "dead" then
            love.graphics.setCanvas(buffer)
            assert(coroutine.resume(co))
            love.graphics.setCanvas()
        else
--            co = nil
        end
    end
end

function love.load()
    buffer = love.graphics.newCanvas()
    co = coroutine.create(program)
end

function love.draw()
    love.graphics.push("all")
    love.graphics.setColor({255, 255, 255})
    love.graphics.setBlendMode("alpha", "premultiplied")
    love.graphics.draw(buffer)
    love.graphics.pop()
    resume()
end

Re: clear canvas in coroutine not work

Posted: Sat Dec 03, 2016 1:52 am
by zorg
My guess is you want to actually do this:

Code: Select all

function love.draw()
    love.graphics.push("all")
    resume()
    love.graphics.setColor({255, 255, 255})
    love.graphics.setBlendMode("alpha", "premultiplied")
    love.graphics.draw(buffer)
    love.graphics.pop()
end

Re: clear canvas in coroutine not work

Posted: Sat Dec 03, 2016 8:59 am
by zaher
Nop, that circle still appear