Page 1 of 1

Löve vs GameMaker - Drawing triangles

Posted: Sun Apr 01, 2012 7:54 pm
by timmeh42
(This may not be interesting to most users, but I thought it could interest people new to Löve and those who don't know its full cababilities)

I was interested in how fast Löve/Lua is at drawing triangles, so I wrote a demo/benchmark that fills the screen with 60702 triangles - it got a decent 12 fps on my pc.
I then figured it would be interesting to do the same test with GameMaker, so I wrote the exact same code (give or take the language differences) into GML and ran it. The results were actually not as different as I would have thought - I always assumed that GameMaker was rather slow, but I got an average of 3 or 4 fps.

Screenshot of the tests running simultaneously (oddly, this did not affect the performance - similar results were achieved whether the tests were running concurrently or not).
The numbers are FPS (top) and triangle count (bottom)
Image
Looks like my screenshot gets cut off a bit there, the Löve version's window is exactly the same size as the GML verson's.

Code for the Löve version:

Code: Select all

function love.load()
	love.graphics.setBackgroundColor(128,128,128)
end
function love.update(dt)
	fps = 1/dt
	tris = 0
end
function love.draw()
	love.graphics.setColor(0,0,0)
	for n=0,800,4 do
		for m=0,600,4 do
			love.graphics.triangle("line",n,m,n+4,m,n,m+4)
			love.graphics.triangle("line",n+4,m+4,n+4,m,n,m+4)
			tris = tris+2
		end
	end
	love.graphics.setColor(255,255,255)
	love.graphics.print(fps,16,16,0,1,1)
	love.graphics.print(tris,16,48,0,1,1)
end
Code for the GML version (all in a single default object, without a sprite, in a 800x600 room with only that object in it)

Code: Select all

On Create:

tris=0

On Step:

tris=0

On Draw:

draw_set_color(c_black)
    for(n=0;n<=800;n+=4)
        {
        for(m=0;m<=600;m+=4)
            {
            draw_triangle(n,m,n+4,m,n,m+4,1)
            draw_triangle(n+4,m+4,n+4,m,n,m+4,1)
            tris += 2
            }
        }
draw_set_color(c_white)
draw_text(16,16,fps)
draw_text(16,48,tris)
Uploaded the .love test, coudln't upload the GML one, as its compiled into an .exe

Also interestingly, Löve and GameMaker seem to draw their triangles slightly differently.

Re: Löve vs GameMaker - Drawing triangles

Posted: Sun Apr 01, 2012 8:33 pm
by rokit boy
Edit: NEVERMIND

Re: Löve vs GameMaker - Drawing triangles

Posted: Sun Apr 01, 2012 9:34 pm
by TechnoCat
You'll have to remove the love.timer.sleep() from love.run if you want a true benchmark.
And I hope you aren't running them at the same time.

Re: Löve vs GameMaker - Drawing triangles

Posted: Sun Apr 01, 2012 9:48 pm
by Nixola
Screenshot of the tests running simultaneously (oddly, this did not affect the performance - similar results were achieved whether the tests were running concurrently or not).

Re: Löve vs GameMaker - Drawing triangles

Posted: Sun Apr 01, 2012 9:57 pm
by TechnoCat
Nixola wrote:
Screenshot of the tests running simultaneously (oddly, this did not affect the performance - similar results were achieved whether the tests were running concurrently or not).
Remove love.timer.sleep() from love.run and that will change.

Re: Löve vs GameMaker - Drawing triangles

Posted: Sun Apr 01, 2012 10:28 pm
by Xgoff
you're probably measuring their api performance more than anything

Re: Löve vs GameMaker - Drawing triangles

Posted: Mon Apr 02, 2012 7:07 am
by bartbes
I'd suggest you use love.timer.getFPS as well, it's more accurate (supposedly, and in 0.8.0 it should be spot on).

Also, I'd like to note that already love is three times as fast, and we generally recommend to not draw those amounts of "stuff" over and over again as it's one of the slowest things there is.

Re: Löve vs GameMaker - Drawing triangles

Posted: Mon Apr 02, 2012 8:29 am
by timmeh42
TechnoCat wrote:
Nixola wrote:
Screenshot of the tests running simultaneously (oddly, this did not affect the performance - similar results were achieved whether the tests were running concurrently or not).
Remove love.timer.sleep() from love.run and that will change.
Did, and the results were exactly the same, both running concurrently and not.
To clarify, you mean getting the default run bitty from love.run and removing the line near the end that says "if love.timer then love.timer.sleep(1)"?
bartbes wrote:I'd suggest you use love.timer.getFPS as well, it's more accurate (supposedly, and in 0.8.0 it should be spot on).
Did that, too, but it's pretty much the same, just changes a lot less now.

Also, Löve can do all these optimisation things, but GM does not have much you can do on that front. I don't suppose it's very efficient to stick everything into 'objects' and then put those in 'rooms' and have to check through all the rooms and objects and all their miscellaneous properties that nobody ever uses.

The test was actually a rather foolish test to see if 3D - specifically simple voxels - could be done to any measure of success in Löve. Doesn't look like it. And yes, I know that's not the aim of Löve.

Re: Löve vs GameMaker - Drawing triangles

Posted: Mon Apr 02, 2012 2:34 pm
by slime
Orthographic 3D can and has been done successfully in LÖVE. Perspective 3D can be done but definitely not easily or efficiently.