Error when creating 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
User avatar
Party member
Posts: 231
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria

Error when creating canvas

Post by Luke100000 » Sat Jul 15, 2017 8:02 am


My game receives this error when creating a new normal 8rgba canvas where I do not know why:
"Cannot create canvas: Texture format cannot be rendered to on this system."

I can reproduce this error when creating thousands of canvases until my system runs out of memory, but I'm very sure my game doesn't do this and it still crashes, sometimes early, sometimes later and not always. My game uses canvases to render chunks of the world and the amount of canvases can easily be limited, but as I said I do not think it reached a limit. On my cheap netbook, 2GB RAM, and maybe ~512 MB VRAM I can create 2200 512x512 8rgba canvases.

Are there any other reasons this error might appear?

Posts: 3
Joined: Fri Sep 15, 2017 2:14 am

Re: Error when creating canvas

Post by CameronGoble » Fri Sep 15, 2017 2:22 am

I encountered the same issue and found your message on the forums. I was using code to create a canvas object out of a Text object so I could do interesting transforms on it:

Code: Select all

function textToCanvasObject(textObject)
    -- Maybe draw text onto a canvas first?
    local h = textObject:getHeight()
    local w = textObject:getWidth()
    local textCanvas = w, h )
      function(), 0,0)
  return canvasObject
I solved it by reviewing the textObject parameter I was passing that object. I forgot to properly index the object from the function call in another segment of code, so h and w were coming out to be zero. That's what threw the error. See the difference here:

Code: Select all

nameText = textToCanvasObject(, crisisList[i].name))

Code: Select all

nameText = textToCanvasObject(, name))
THe first worked, the second gave the error. Try re-checking any parameters you send to newCanvas().

Post Reply

Who is online

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