Löve vs GameMaker - Drawing triangles

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
timmeh42
Citizen
Posts: 90
Joined: Wed Mar 07, 2012 7:32 pm
Location: Cape Town, South Africa

Löve vs GameMaker - Drawing triangles

Post 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.
Attachments
main.love
(324 Bytes) Downloaded 134 times
User avatar
rokit boy
Party member
Posts: 198
Joined: Wed Jan 18, 2012 7:40 pm

Re: Löve vs GameMaker - Drawing triangles

Post by rokit boy »

Edit: NEVERMIND
u wot m8
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Löve vs GameMaker - Drawing triangles

Post 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.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Löve vs GameMaker - Drawing triangles

Post 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).
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Löve vs GameMaker - Drawing triangles

Post 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.
User avatar
Xgoff
Party member
Posts: 211
Joined: Fri Nov 19, 2010 4:20 am

Re: Löve vs GameMaker - Drawing triangles

Post by Xgoff »

you're probably measuring their api performance more than anything
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Löve vs GameMaker - Drawing triangles

Post 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.
User avatar
timmeh42
Citizen
Posts: 90
Joined: Wed Mar 07, 2012 7:32 pm
Location: Cape Town, South Africa

Re: Löve vs GameMaker - Drawing triangles

Post 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.
User avatar
slime
Solid Snayke
Posts: 3148
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Löve vs GameMaker - Drawing triangles

Post by slime »

Orthographic 3D can and has been done successfully in LÖVE. Perspective 3D can be done but definitely not easily or efficiently.
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests