## Motor2D - Löve2D for the Web with Emscripten

Discuss any ports of LÖVE to different platforms.
rnlf
Prole
Posts: 7
Joined: Wed Jul 29, 2015 1:15 pm

### Motor2D - Löve2D for the Web with Emscripten

Hey guys,

I've spent the last few months rewriting the Löve API with Emscripten. I made quite some progress so far and aim for a 100% compatibility. You can use normal .love files (if they don't use any not-yet supported features).

My previous three Ludum Dare entries all run in Motor2D, thought a lot is still missing.

It is not open source yet, but as soon as I implemented all the stuff I think are interesting enough for me, I will open it.

You can grab the current preview here.

I know there have been a lot of Löve->Web projects, but I think I am on the right track to get an actual mostly compatible one.

Let me know what you think!

Cheers,
rnlf

slime
Solid Snayke
Posts: 2811
Joined: Mon Aug 23, 2010 6:45 am
Contact:

### Re: Motor2D - Löve2D for the Web with Emscripten

Awesome! I didn't know code that uses exceptions is a lot more expensive in asm.js, that's good to know.

Just a few notes:
• LÖVE is the name. love2d.org is the website domain name, but it's not called love2d.
• From what I understand, SDL2's emscripten backend is pretty solid now. There was a Humble Bundle last year which featured games that use SDL2 running in the browser via emscripten, and it worked well: http://developer.humblebundle.com/post/ ... using-sdl2
• LÖVE 0.10.0 has OpenGL 2.1 or OpenGL ES 2.0 (which is roughly WebGL 1.0) as a minimum system requirement, which eliminates a lot (but certainly not all) of the code necessary to support different GL versions. However even WebGL can support various extensions that LÖVE uses at runtime, which LÖVE's graphics code is already written to take advantage of.
What does the * mean next to SpriteBatch:bind and SpriteBatch:unbind?

Also, if you have any questions about LÖVE's codebase, the IRC channel (#love on irc.oftc.net) is a great place to ask. Either myself or bartbes will probably be around.

rnlf
Prole
Posts: 7
Joined: Wed Jul 29, 2015 1:15 pm

### Re: Motor2D - Löve2D for the Web with Emscripten

Oh, okay I will take care to fix the references to LÖVE :-)

Actually, I am already using parts of Emscripten's SDL2 by now, my documentation is a bit outdated on that topic.

The asterisks are there to indicate that those functions are deprecated in LÖVE by now, but I still keep it in my code because all my test projects are not yet up to date. I somehow removed that explanation when compiling the web page.

Even though I aim to get 100% compatibility, I will probably only get to 95% or so. There are some things that would be mostly impossible to do in Emscripten. Writing your own love.run will probably never be allowed in motor2d, because of we need to regularly return to the browser from the JavaScript environment (so love.run is actually written in C in my version). For the same reason I don't plan to provide workarounds for GLSL differences. I'm looking forward to 0.10.0, it will probably boost my compatibility without me doing much work :-)

rlaitila
Prole
Posts: 9
Joined: Sat Jun 08, 2013 5:33 am

### Re: Motor2D - Löve2D for the Web with Emscripten

Aw man I lost my draft I was writing you a big raving compliment!

Awesome work!

Do you have any plans to help backfill important emscripten code into love master once you achieve a certain functionality level? Just like we are seeing with andoird-sdl2 and ios ports? It would be great to add emscripten to android and ios soon to be supported platforms!

rnlf
Prole
Posts: 7
Joined: Wed Jul 29, 2015 1:15 pm

### Re: Motor2D - Löve2D for the Web with Emscripten

I am not sure how useful that would be. My code is a complete rewrite of LöVE, I take a hint from LÖVE's source every now and then to make sure I get as compatible as possible, but it's not based on LÖVE's structure and even written in a different language.

If people think the stuff I learned about emscripten will be useful to the LÖVE project itself, I am happy to help!

Murii
Party member
Posts: 212
Joined: Fri Jul 05, 2013 9:58 am
Contact:

### Re: Motor2D - Löve2D for the Web with Emscripten

How much time do you think we need to wait until we can get our hands on the src? (I hope it will be hosted on Github)

bakpakin
Party member
Posts: 114
Joined: Sun Mar 15, 2015 9:29 am
Location: Boston

### Re: Motor2D - Löve2D for the Web with Emscripten

I just tried using this, and it works moderately well. Some of the functions that you've listed as compatible don't actually seem compatible (or just buggy). Also, love.audio doesn't seem to work at all, I just get this in the Mozilla console.

Code: Select all

TypeError: entry.buffer is null motor2d.js:1:461774
TypeError: entry.buffer.duration is null

Besides that and a few other quirks, It works remarkably well. I would love to get the source and play with it.
((_((_CRAYOLA_((_((_> GitHub <_((_((_CRAYOLA_((_(()

Shviller
Prole
Posts: 7
Joined: Sat Jul 19, 2014 10:51 pm

### Re: Motor2D - Löve2D for the Web with Emscripten

Quick question:

Code: Select all

self.font:getWrap(...)
returns 0, nil. The font object was created with

Code: Select all

love.graphics.newFont(12)
Is this supposed to happen?

Thanks in advance and thanks for making Motor2D in the first place!

rnlf
Prole
Posts: 7
Joined: Wed Jul 29, 2015 1:15 pm

### Re: Motor2D - Löve2D for the Web with Emscripten

I just published the source: https://github.com/rnlf/motor.

There is still a lot of work to do, but it runs several Ludum Dare 33 games now.

I'll enter all your bug reports into github's issue tracker, thanks for telling me about it!

undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Awesome!