It's me again, and my neverending confusion with canvases. This problem only affects windows (and wine) as far as I know.
When creating canvases and drawing to them, sometimes it seems like the gpu can't catch up with the rest of the program and just leaves the canvas empty. This doesn't happen on linux though, so I'm confused.
I've attached a .love file where exactly this happens if it's run on windows/wine, when the window is resized and the canvases are released, then created again.
Code: Select all
local lg = love.graphics
local small_canvas_size = 100
local needs_resize = false
function love.load ()
small_canvas = lg.newCanvas(small_canvas_size, small_canvas_size)
big_canvas = lg.newCanvas(small_canvas_size * 4, small_canvas_size * 4)
counter = 0
lg.setCanvas(small_canvas)
render_small_canvas()
lg.setCanvas(big_canvas)
render_big_canvas()
lg.setCanvas()
end
function render_small_canvas ()
lg.setColor(0, 1, 0, 1)
lg.rectangle('fill', 1, 1, small_canvas_size, small_canvas_size)
lg.setColor(1, 0, 0, 1)
lg.circle('fill', small_canvas_size / 2, small_canvas_size / 2, small_canvas_size / 2)
lg.setColor(1, 1, 1, 1)
end
function render_big_canvas ()
lg.draw(small_canvas, 0, 0)
lg.draw(small_canvas, small_canvas_size, 0)
lg.draw(small_canvas, 0, small_canvas_size)
lg.draw(small_canvas, small_canvas_size, small_canvas_size)
lg.setColor(1, 1, 1, 1)
end
function love.draw ()
if needs_resize then
print("resize")
small_canvas:release()
big_canvas:release()
small_canvas = lg.newCanvas(small_canvas_size, small_canvas_size)
big_canvas = lg.newCanvas(small_canvas_size * 4, small_canvas_size * 4)
lg.setCanvas(small_canvas)
render_small_canvas()
lg.setCanvas(big_canvas)
render_big_canvas()
lg.setCanvas()
needs_resize = false
end
lg.draw(small_canvas, 0, 0)
lg.draw(big_canvas, small_canvas_size + 50, 0)
end
function love.resize () --this is just the flag to do the resize stuff in love.draw, the bug also happens when I do here directly.
needs_resize = true
end
https://github.com/Bananicorn/lvg
Edit: I'm an idiot, my package manager updated my Löve binary to 11.2, where it works, but I didn't download the new binaries for Windows...
It works now. I hope no one wasted too much time on this...