Hullo, I'm new here; both to Love and Lua! I had a question about how Love draws things. (Lovelily, of course. )
I want to do basic ghosting, a pretty common trick for processing users. Instead of manually redrawing the background at each frame (which processing folk have to do), if we overlay a semi-transparent rectangle it will fade out previously drawn frames slowly. The effect looks pretty spiffy I daresay.
love.draw(), however, redraws the background at every frame on its own. Is there any way to disable the solid background color so that I can use the same ghosting trick?
function love.run()
--...
if love.graphics then
--love.graphics.clear()
if love.draw then love.draw() end
end
--...
if love.timer then love.timer.sleep(1) end
if love.graphics then love.graphics.present() end
end
end
In fact, the run() code works fine when I leave the love.graphics.clear() as-is.
love.graphics.setRenderTarget(buffers[buffers.current]) -- draw to current buffer
love.graphics.setColor(255,255,255,100) -- alpha value to fade the previous frame out
love.graphics.draw(buffers[not buffers.current], 0, 0) -- draw previous frame
-- draw new content over last frame
draw_stuff()
love.graphics.setRenderTarget() -- draw to screen again
love.graphics.draw(buffers[buffers.current], 0, 0) -- draw 'ghosted' scene
buffers.current = not buffers.current -- switch buffers
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.
I've tried modifying love.run to do this before. It just gave me headaches with different computers with a single buffer or a double and triple buffer.
As far as I know, Framebuffers aren't supported on all computers because of their OpenGL implementations (mine for example), so you have to be careful with that.
BlackBulletIV wrote:Framebuffers aren't supported on all computers
Yeah, if you want to make sure it will run on all computers I suggest first off, having a fallback mode with no FBOs (even if it doesn't look spiffy), and also rounding up the FBO to the next power of two (like 1024X1024 for 800X600 or 1024X768 resolutions) will make it generally more compatible with bad hardware / drivers.