Page 1 of 3

Motor2D - Löve2D for the Web with Emscripten

Posted: Wed Jul 29, 2015 1:21 pm
by rnlf
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

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

Posted: Wed Jul 29, 2015 2:22 pm
by slime
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.

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

Posted: Wed Jul 29, 2015 2:37 pm
by rnlf
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 :-)

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

Posted: Thu Jul 30, 2015 4:42 am
by rlaitila
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!

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

Posted: Thu Jul 30, 2015 7:02 am
by rnlf
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!

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

Posted: Sat Aug 08, 2015 5:30 pm
by Murii
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) ;)

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

Posted: Sat Aug 22, 2015 5:25 pm
by bakpakin
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.

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

Posted: Sun Aug 23, 2015 1:46 pm
by Shviller
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!

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

Posted: Mon Aug 31, 2015 1:20 pm
by rnlf
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!

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

Posted: Mon Aug 31, 2015 1:25 pm
by undef
Awesome!