Hi all! In my current project, I'd like to treat rendering as part of the standard game update loop. But since love.run has a love.graphics.clear() between calling love.update and love.draw, anything drawn will be immediately lost.
I know I can very easily change this behaviour by moving the offending love.graphics.clear() up a few lines in love.run. However, changing love.run seems terribly intrusive for a library, so I'm wondering if there are more elegant ways of going about it? ("Elegant" discounting solutions such as running all updates in love.draw - eww)
Enabling drawing in love.update() - Solved!
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Enabling drawing in love.update() - Solved!
Last edited by Taehl on Mon Mar 14, 2016 1:23 am, edited 1 time in total.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: Enabling drawing in love.update()
You could draw to a canvas, then draw the canvas in love.draw
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Enabling drawing in love.update()
Usually a great approach, but I don't have canvas support.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Enabling drawing in love.update()
Wait, that's it!love.graphics.clear - LOVE wiki wrote:Note that the scissor area bounds the cleared region.
Code: Select all
function love.update( dt )
local perfLength = 128
local timer = love.timer.getTime
-- clear any scissor region (like the one used below) and the screen
love.graphics.setScissor()
love.graphics.clear()
-- the following is what I'm using right now, as an example
for sysN,system in ipairs( ECS.systems ) do
if not system.__skipUpdate then
-- run each system and profile their performance
local start = timer()
TECS.runSystem( sysN, dt ) -- some systems use love.graphics to draw stuff
table.insert( ECS.perf[sysN], 1, timer()-start )
ECS.perf[sysN][perfLength] = nil -- only keep the most recent updates
end
end
-- prevent Love2D from clearing the screen between here and love.draw
love.graphics.setScissor( -1,-1, 1,1 )
end
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Who is online
Users browsing this forum: Google [Bot] and 4 guests