graphics.clear clears screen instead of canvas

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
ardera
Prole
Posts: 1
Joined: Mon Feb 10, 2014 11:25 am

graphics.clear clears screen instead of canvas

Post by ardera »

There is not much code to reproduce this, you don't need to download the .love file.

It's easy:

Code: Select all

function love.load()
  mycanvas = love.graphics.newCanvas(300, 300)
end
function love.draw()
  love.graphics.setCanvas(mycanvas)
  love.graphics.setColor(255, 255, 255, 255)
  love.graphics.setBackgroundColor(0, 0, 255, 0)
  love.graphics.clear()
  love.graphics.setCanvas()
end
Normally, you should just see a black screen, because the canvas is never drawn to the screen.
But instead, at least setBackgroundColor and clear are targetting the screen instead of the canvas, so you see a blue screen.

I am using an unmodified version of love version 0.9.2
Attachments
test.love
(280 Bytes) Downloaded 38 times
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: graphics.clear clears screen instead of canvas

Post by Robin »

You can use [wiki]Canvas:clear[/wiki] instead.
Help us help you: attach a .love.
User avatar
slime
Solid Snayke
Posts: 3170
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: graphics.clear clears screen instead of canvas

Post by slime »

love.graphics.clear is called automatically before love.draw, in the default [wiki]love.run[/wiki] – and your call to love.graphics.setBackgroundColor affects that.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: graphics.clear clears screen instead of canvas

Post by Robin »

Code: Select all

function love.load()
	mycanvas = love.graphics.newCanvas(300, 300)
end
function love.draw()
    love.graphics.print("If you can see this, slime is right")
	love.graphics.setCanvas(mycanvas)
	love.graphics.setColor(255, 255, 255, 255)
	love.graphics.setBackgroundColor(0, 0, 255, 0)
	love.graphics.clear()
	love.graphics.setCanvas()
end
(And I was wrong.)
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 4 guests