clear canvas in coroutine not work

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
User avatar
zaher
Prole
Posts: 6
Joined: Sat Nov 05, 2016 10:28 pm
Location: Syria, Damascus
Contact:

clear canvas in coroutine not work

Post 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
Last edited by zaher on Sat Dec 03, 2016 9:00 am, edited 1 time in total.
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: clear canvas in coroutine not work

Post 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
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
zaher
Prole
Posts: 6
Joined: Sat Nov 05, 2016 10:28 pm
Location: Syria, Damascus
Contact:

Re: clear canvas in coroutine not work

Post by zaher »

Nop, that circle still appear
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 194 guests