[SOLVED]canvases come up empty on windows

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
Bananicorn
Prole
Posts: 21
Joined: Thu Apr 12, 2018 9:59 am

[SOLVED]canvases come up empty on windows

Post by Bananicorn » Wed Jan 02, 2019 10:23 am

Hello fellow Lövers!

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
If you're wondering as to where I actually need this, it's because I'm making a simple svg library and need to resize canvases when I resize the window, so the graphics stay nice and crisp :)

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...
Attachments
canvas_bug_test.love
(1004 Bytes) Downloaded 57 times
Last edited by Bananicorn on Mon Jan 21, 2019 10:18 pm, edited 1 time in total.

User avatar
ironsheikh
Prole
Posts: 9
Joined: Mon Jan 14, 2019 9:17 am

Re: canvases come up empty on windows

Post by ironsheikh » Thu Jan 17, 2019 6:02 pm

Just wanted to check if you resolved this issue before I spend any time on it?
"If at first you don't succeed, skydiving is not for you."

User avatar
slime
Solid Snayke
Posts: 2813
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: canvases come up empty on windows

Post by slime » Thu Jan 17, 2019 9:51 pm

Wine probably isn't a good platform to test graphics on - emulation layers come with all sorts of their own graphics problems which don't exist on the real deal.

User avatar
ironsheikh
Prole
Posts: 9
Joined: Mon Jan 14, 2019 9:17 am

Re: canvases come up empty on windows

Post by ironsheikh » Thu Jan 17, 2019 11:28 pm

Agree with the user above, and I wouldn't touch Wine with a bargepole when it comes down to testing a build for which no specific optimisations exist.

To prove the point, your build seems to work fine on my Win 10 machine.

Virtual machines are the way to go (or dual boot, to a lesser extent).

Good luck.
"If at first you don't succeed, skydiving is not for you."

Bananicorn
Prole
Posts: 21
Joined: Thu Apr 12, 2018 9:59 am

Re: canvases come up empty on windows

Post by Bananicorn » Mon Jan 21, 2019 10:20 pm

ironsheikh wrote:
Thu Jan 17, 2019 11:28 pm
Agree with the user above, and I wouldn't touch Wine with a bargepole when it comes down to testing a build for which no specific optimisations exist.

To prove the point, your build seems to work fine on my Win 10 machine.

Virtual machines are the way to go (or dual boot, to a lesser extent).

Good luck.
So far wine has worked okay, but I can imagine there being a whole bunch of problems...
It works on the latest version of Löve, I just didn't update the Windows Löve binary I used in testing...

Bananicorn
Prole
Posts: 21
Joined: Thu Apr 12, 2018 9:59 am

Re: canvases come up empty on windows

Post by Bananicorn » Mon Jan 21, 2019 10:23 pm

ironsheikh wrote:
Thu Jan 17, 2019 11:28 pm
Agree with the user above, and I wouldn't touch Wine with a bargepole when it comes down to testing a build for which no specific optimisations exist.

To prove the point, your build seems to work fine on my Win 10 machine.

Virtual machines are the way to go (or dual boot, to a lesser extent).

Good luck.
I've found the error - which was just me not using the 11.2 binaries for my Windows build (maybe I even still had the 11.0 ones, don't know)
So sorry if I've wasted a lot of your time, next time I'll know the check all my dependencies...

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 6 guests