[SOLVED] Canvas is crashing 11.2

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
DGM
Prole
Posts: 14
Joined: Tue Mar 20, 2018 6:42 am

[SOLVED] Canvas is crashing 11.2

Post by DGM » Sun Jan 20, 2019 10:27 pm

Hello,

I'm using v11.2 in 64-bit Windows 10. Trying to use a canvas causes an immediate crash, even with the following minimal code:

Code: Select all

function love.load()
	canvas_1 = love.graphics.newCanvas()
end

function love.update()

end

function love.draw()
	love.graphics.setCanvas(canvas_1)
end
Here's the error message:

Code: Select all

Error

boot.lua:514: present cannot be called while a Canvas is active.


Traceback

[C]: in function 'present'
[C]: in function 'xpcall'
I've tried moving setCanvas to update() and moving the newCanvas command outside load(), but the results are the same. I tinkered with canvases a bit in the previous version and don't remember having this problem, so am I correct in assuming this is a bug in 11.2 or am I doing something wrong?
Last edited by DGM on Tue Jan 22, 2019 1:58 am, edited 1 time in total.

User avatar
pgimeno
Party member
Posts: 1561
Joined: Sun Oct 18, 2015 2:58 pm

Re: Canvas is crashing 11.2

Post by pgimeno » Sun Jan 20, 2019 10:52 pm

When love.draw finishes, you need to have no canvas active, so you need to disable it at some point before the end of love.draw(). This works, for example:

Code: Select all

function love.draw()
	love.graphics.setCanvas(canvas_1)
	-- do stuff here
	love.graphics.setCanvas()
end
Of course, drawing only to a canvas in love.draw and not to the screen isn't very useful, but then your example had the same problem; it's only for illustrative purposes. Here's something a bit more useful:

Code: Select all

function love.draw()
	love.graphics.setCanvas(canvas_1)
	-- do stuff here
	love.graphics.setCanvas()
	love.graphics.draw(canvas_1)
end

DGM
Prole
Posts: 14
Joined: Tue Mar 20, 2018 6:42 am

Re: Canvas is crashing 11.2

Post by DGM » Sun Jan 20, 2019 11:02 pm

pgimeno wrote:
Sun Jan 20, 2019 10:52 pm
When love.draw finishes, you need to have no canvas active, so you need to disable it at some point before the end of love.draw(). This works, for example:
That was the problem. Thanks.

Suggestion to the Love2D devs: a warning about needing to deactivate your canvases in the documentation for the canvas feature might be a good idea.

User avatar
pgimeno
Party member
Posts: 1561
Joined: Sun Oct 18, 2015 2:58 pm

Re: Canvas is crashing 11.2

Post by pgimeno » Sun Jan 20, 2019 11:42 pm

I've added a paragraph to love.graphics.setCanvas, feel free to correct it if you think the wording could be improved (wiki accounts use the same user/password as the forum). To prevent confusion: I'm not a Love2d dev.

Post Reply

Who is online

Users browsing this forum: Exabot [Bot] and 5 guests