Canvas VS Directly drawing to the screen

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
Styper
Prole
Posts: 6
Joined: Sun Jul 29, 2018 11:53 am

Canvas VS Directly drawing to the screen

Post by Styper »

I have a project where I'm drawing 25 lines on the screen, I thought a canvas would increase the performance of this task but I'm actually getting poorer results

How come this?

Code: Select all

function love.draw()
  line5() --This has 25 draw lines inside
end
Performs better than this?

Code: Select all

function love.load()
  canvas = love.graphics.newCanvas(800, 600)
  love.graphics.setCanvas(canvas)
  love.graphics.clear()
  line5() --This has 25 draw lines inside
  love.graphics.setCanvas()
end
function love.draw()
  love.graphics.draw(canvas)
end
I'm using FPS as a benchmark:

Without canvas:

Code: Select all

FPS: 205
FPS: 205
FPS: 207
FPS: 211
FPS: 206
FPS: 206
FPS: 206
FPS: 209
FPS: 209
FPS: 204
FPS: 208
FPS: 203
FPS: 205
With canvas:

Code: Select all

FPS: 156
FPS: 167
FPS: 151
FPS: 157
FPS: 167
FPS: 159
FPS: 175
FPS: 181
FPS: 181
FPS: 181
FPS: 183
FPS: 173
FPS: 172
Any help is appreciated
Post Reply

Who is online

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