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 .
NetherGranite
Prole
Posts: 30 Joined: Wed Jul 11, 2018 11:08 pm
Post
by NetherGranite » Mon Oct 22, 2018 2:07 pm
I'm getting this error:
Code: Select all
main.lua:346: bad argument #2 to 'setCanvas' (number expected, got no value)
What number am I supposed to be giving it?
Trying to pass 0 to it gives me this error:
Code: Select all
main.lua:346: Invalid slice index: 0.
To clarify, this is love.graphics.setCanvas(canvas1, canvas2, …) that I'm trying to call.
Last edited by
NetherGranite on Wed Oct 24, 2018 12:15 am, edited 1 time in total.
pgimeno
Party member
Posts: 3550 Joined: Sun Oct 18, 2015 2:58 pm
Post
by pgimeno » Mon Oct 22, 2018 3:00 pm
Works for me.
Code: Select all
local canvas1 = love.graphics.newCanvas()
local canvas2 = love.graphics.newCanvas()
love.graphics.setCanvas(canvas1, canvas2)
love.graphics.setCanvas()
You'll need to provide more information.
slime
Solid Snayke
Posts: 3133 Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:
Post
by slime » Mon Oct 22, 2018 10:21 pm
If the canvas is an array texture or cubemap or 3D texture, you need to give it a layer/cube index to render to as an argument in setCanvas.
NetherGranite
Prole
Posts: 30 Joined: Wed Jul 11, 2018 11:08 pm
Post
by NetherGranite » Wed Oct 24, 2018 12:15 am
It turns out this happens if you try to pass three numbers to newCanvas(), e.g. love.graphics.newCanvas(1920, 1080, 5). This is because the third argument is how many layers the canvas should have; as a result, setCanvas() now expects a number argument telling it which layer of the canvas to use.
I should add the disclaimer that this is my best guess since such behavior is undocumented as of writing this. I have bought up this lack of documentation in
this post .
Users browsing this forum: No registered users and 190 guests