Emscripten port

The Emscripten support is now in revision control!

 https://hg.libsdl.org/SDL/rev/8900afb78a19

This means you can now compile your SDL2-based application, written in C
or C++ with Emscripten, and it will run as a web app.

For example, here’s a C++ test app I wrote that uses SDL’s render API,
compiled with Emscripten:

https://icculus.org/~icculus/emscripten/test_renderer/test_renderer.html

(The render calls end up as WebGL, so you get hardware acceleration,
render targets, etc. You can use OpenGL ES 2.0 directly if you like, too.)

You can read more about Emscripten at http://emscripten.org

Emscripten already ships with a “close enough” implementation of the SDL
1.2 API (written by hand in Javascript), but this new work makes it so
you can just compile SDL2’s actual code with Emscripten, along with the
new backends for video, audio, etc, and link the resulting library to
your Emscripten app.

There are one or two gotchas to porting your app code, but overall, it’s
pretty amazing how well this works.

Thanks to Charlie Birks, Sathyanarayanan Gunasekaran, Jukka Jyl?nki,
Alon Zakai, Edward Rudd, Bruce Mitchener, and Martin Gerhardy for all
their hard work on this!

–ryan.

This looks awesome.

Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768On Wed, Dec 24, 2014 at 2:39 PM, Ryan C. Gordon wrote:

The Emscripten support is now in revision control!

https://hg.libsdl.org/SDL/rev/8900afb78a19

This means you can now compile your SDL2-based application, written in C
or C++ with Emscripten, and it will run as a web app.

For example, here’s a C++ test app I wrote that uses SDL’s render API,
compiled with Emscripten:

https://icculus.org/~icculus/emscripten/test_renderer/test_renderer.html

(The render calls end up as WebGL, so you get hardware acceleration,
render targets, etc. You can use OpenGL ES 2.0 directly if you like, too.)

You can read more about Emscripten at http://emscripten.org

Emscripten already ships with a “close enough” implementation of the SDL
1.2 API (written by hand in Javascript), but this new work makes it so you
can just compile SDL2’s actual code with Emscripten, along with the new
backends for video, audio, etc, and link the resulting library to your
Emscripten app.

There are one or two gotchas to porting your app code, but overall, it’s
pretty amazing how well this works.

Thanks to Charlie Birks, Sathyanarayanan Gunasekaran, Jukka Jyl?nki, Alon
Zakai, Edward Rudd, Bruce Mitchener, and Martin Gerhardy for all their hard
work on this!

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

This seems like magic!
Thank you very much for sharing, Ryan, and to all those who also work hard
to get it to work!.

JosebaOn Wed, Dec 24, 2014 at 10:29 AM, Pallav Nawani wrote:

This looks awesome.

Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768

On Wed, Dec 24, 2014 at 2:39 PM, Ryan C. Gordon wrote:

The Emscripten support is now in revision control!

https://hg.libsdl.org/SDL/rev/8900afb78a19

This means you can now compile your SDL2-based application, written in C
or C++ with Emscripten, and it will run as a web app.

For example, here’s a C++ test app I wrote that uses SDL’s render API,
compiled with Emscripten:

https://icculus.org/~icculus/emscripten/test_renderer/test_renderer.html

(The render calls end up as WebGL, so you get hardware acceleration,
render targets, etc. You can use OpenGL ES 2.0 directly if you like, too.)

You can read more about Emscripten at http://emscripten.org

Emscripten already ships with a “close enough” implementation of the SDL
1.2 API (written by hand in Javascript), but this new work makes it so you
can just compile SDL2’s actual code with Emscripten, along with the new
backends for video, audio, etc, and link the resulting library to your
Emscripten app.

There are one or two gotchas to porting your app code, but overall, it’s
pretty amazing how well this works.

Thanks to Charlie Birks, Sathyanarayanan Gunasekaran, Jukka Jyl?nki, Alon
Zakai, Edward Rudd, Bruce Mitchener, and Martin Gerhardy for all their hard
work on this!

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

hi.

a small showcase of my game compiled with emscripten+sdl2

the code is available on github at https://github.com/mgerhardy/caveexpress

to compile it on your own, just type ./configure --enable-release
–target-os=html5 && make (after setting up the emscripten sdk of course)

The url to see it in actiom is:http://88.198.107.20/caveexpress.html

there are some issues left:

  • the mouse cursor handling (use tab to navigate in the ui)
  • esc handling doesn’t go back in the ui, but closes the fullscreen mode
  • no tweaks for download progress bar and so on… just wait a little bit
    to get the 30mb downloaded)

Feedback is welcome.

The game is also available in the android app store and on desura. have fun,

Regards
Martin

http://www.caveproductions.orgOn Thu, Dec 25, 2014 at 7:05 PM, Joseba Garc?a Etxebarria < josebagar at gmail.com> wrote:

This seems like magic!
Thank you very much for sharing, Ryan, and to all those who also work hard
to get it to work!.

Joseba

On Wed, Dec 24, 2014 at 10:29 AM, Pallav Nawani wrote:

This looks awesome.

Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768

On Wed, Dec 24, 2014 at 2:39 PM, Ryan C. Gordon wrote:

The Emscripten support is now in revision control!

https://hg.libsdl.org/SDL/rev/8900afb78a19

This means you can now compile your SDL2-based application, written in C
or C++ with Emscripten, and it will run as a web app.

For example, here’s a C++ test app I wrote that uses SDL’s render API,
compiled with Emscripten:

https://icculus.org/~icculus/emscripten/test_renderer/test_renderer.html

(The render calls end up as WebGL, so you get hardware acceleration,
render targets, etc. You can use OpenGL ES 2.0 directly if you like, too.)

You can read more about Emscripten at http://emscripten.org

Emscripten already ships with a “close enough” implementation of the SDL
1.2 API (written by hand in Javascript), but this new work makes it so you
can just compile SDL2’s actual code with Emscripten, along with the new
backends for video, audio, etc, and link the resulting library to your
Emscripten app.

There are one or two gotchas to porting your app code, but overall, it’s
pretty amazing how well this works.

Thanks to Charlie Birks, Sathyanarayanan Gunasekaran, Jukka Jyl?nki,
Alon Zakai, Edward Rudd, Bruce Mitchener, and Martin Gerhardy for all their
hard work on this!

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://ufoai.sf.net

Updated the url:

https://rawgit.com/mgerhardy/caveexpress/master/contrib/bin/html5/caveexpress.htmlOn Fri, Dec 26, 2014 at 2:43 PM, M. Gerhardy <@Martin_Gerhardy> wrote:

hi.

a small showcase of my game compiled with emscripten+sdl2

the code is available on github at
https://github.com/mgerhardy/caveexpress

to compile it on your own, just type ./configure --enable-release
–target-os=html5 && make (after setting up the emscripten sdk of course)

The url to see it in actiom is:http://88.198.107.20/caveexpress.html

there are some issues left:

  • the mouse cursor handling (use tab to navigate in the ui)
  • esc handling doesn’t go back in the ui, but closes the fullscreen mode
  • no tweaks for download progress bar and so on… just wait a little bit
    to get the 30mb downloaded)

Feedback is welcome.

The game is also available in the android app store and on desura. have
fun,

Regards
Martin

http://www.caveproductions.org

On Thu, Dec 25, 2014 at 7:05 PM, Joseba Garc?a Etxebarria < josebagar at gmail.com> wrote:

This seems like magic!
Thank you very much for sharing, Ryan, and to all those who also work
hard to get it to work!.

Joseba

On Wed, Dec 24, 2014 at 10:29 AM, Pallav Nawani wrote:

This looks awesome.

Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768

On Wed, Dec 24, 2014 at 2:39 PM, Ryan C. Gordon wrote:

The Emscripten support is now in revision control!

https://hg.libsdl.org/SDL/rev/8900afb78a19

This means you can now compile your SDL2-based application, written in
C or C++ with Emscripten, and it will run as a web app.

For example, here’s a C++ test app I wrote that uses SDL’s render API,
compiled with Emscripten:

https://icculus.org/~icculus/emscripten/test_renderer/test_
renderer.html

(The render calls end up as WebGL, so you get hardware acceleration,
render targets, etc. You can use OpenGL ES 2.0 directly if you like, too.)

You can read more about Emscripten at http://emscripten.org

Emscripten already ships with a “close enough” implementation of the
SDL 1.2 API (written by hand in Javascript), but this new work makes it so
you can just compile SDL2’s actual code with Emscripten, along with the new
backends for video, audio, etc, and link the resulting library to your
Emscripten app.

There are one or two gotchas to porting your app code, but overall,
it’s pretty amazing how well this works.

Thanks to Charlie Birks, Sathyanarayanan Gunasekaran, Jukka Jyl?nki,
Alon Zakai, Edward Rudd, Bruce Mitchener, and Martin Gerhardy for all their
hard work on this!

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://ufoai.sf.net
http://sf.net/projects/ufoai


http://ufoai.sf.net

Ups - updated the url:
https://cdn.rawgit.com/mgerhardy/caveexpress/master/contrib/bin/html5/caveexpress.htmlOn Wed, Dec 24, 2014 at 10:09 AM, Ryan C. Gordon wrote:

The Emscripten support is now in revision control!

https://hg.libsdl.org/SDL/rev/8900afb78a19

This means you can now compile your SDL2-based application, written in C
or C++ with Emscripten, and it will run as a web app.

For example, here’s a C++ test app I wrote that uses SDL’s render API,
compiled with Emscripten:

https://icculus.org/~icculus/emscripten/test_renderer/test_renderer.html

(The render calls end up as WebGL, so you get hardware acceleration,
render targets, etc. You can use OpenGL ES 2.0 directly if you like, too.)

You can read more about Emscripten at http://emscripten.org

Emscripten already ships with a “close enough” implementation of the SDL
1.2 API (written by hand in Javascript), but this new work makes it so you
can just compile SDL2’s actual code with Emscripten, along with the new
backends for video, audio, etc, and link the resulting library to your
Emscripten app.

There are one or two gotchas to porting your app code, but overall, it’s
pretty amazing how well this works.

Thanks to Charlie Birks, Sathyanarayanan Gunasekaran, Jukka Jyl?nki, Alon
Zakai, Edward Rudd, Bruce Mitchener, and Martin Gerhardy for all their hard
work on this!

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://ufoai.sf.net

And another game is working - code is also at https://github.com/mgerhardy

direct links (be patient while it’s loading)
caveexpress:
https://cdn.rawgit.com/mgerhardy/caveexpress/master/contrib/bin/html5/caveexpress.html
cavepacker:
https://cdn.rawgit.com/mgerhardy/caveexpress/master/contrib/bin/html5/cavepacker.htmlOn Fri, Dec 26, 2014 at 3:10 PM, M. Gerhardy <@Martin_Gerhardy> wrote:

Ups - updated the url:
https://cdn.rawgit.com/mgerhardy/caveexpress/master/contrib/bin/html5/caveexpress.html

On Wed, Dec 24, 2014 at 10:09 AM, Ryan C. Gordon wrote:

The Emscripten support is now in revision control!

https://hg.libsdl.org/SDL/rev/8900afb78a19

This means you can now compile your SDL2-based application, written in C
or C++ with Emscripten, and it will run as a web app.

For example, here’s a C++ test app I wrote that uses SDL’s render API,
compiled with Emscripten:

https://icculus.org/~icculus/emscripten/test_renderer/test_renderer.html

(The render calls end up as WebGL, so you get hardware acceleration,
render targets, etc. You can use OpenGL ES 2.0 directly if you like, too.)

You can read more about Emscripten at http://emscripten.org

Emscripten already ships with a “close enough” implementation of the SDL
1.2 API (written by hand in Javascript), but this new work makes it so you
can just compile SDL2’s actual code with Emscripten, along with the new
backends for video, audio, etc, and link the resulting library to your
Emscripten app.

There are one or two gotchas to porting your app code, but overall, it’s
pretty amazing how well this works.

Thanks to Charlie Birks, Sathyanarayanan Gunasekaran, Jukka Jyl?nki, Alon
Zakai, Edward Rudd, Bruce Mitchener, and Martin Gerhardy for all their hard
work on this!

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://ufoai.sf.net
http://sf.net/projects/ufoai


http://ufoai.sf.net

Cool news------------------------
My project

Ryan,
Your test app works fine on my Android phone using Chrome and will run fine
on my linux laptop using Firefox but will not work at all using Chrome on
my laptop. It ends up with this output when it fails under Chrome:

  • Engine: Log file started Tue Dec 30 15:53:23 2014
  • Engine: Build string: test_renderer, revision hg-411:37f26bc0e0cc, built
    Dec 10 2014 15:21:26, by Clang 3.3.0
    E Ini: Failed to open config file engine.ini
    I Engine: Command line:
    I Engine: argv[0]: ./this.program
    I Renderer: Setting video mode to 800x600/windowed
    I Renderer: SDL available renderers: opengles2 software
    Could not create canvas: Web page was not allowed to create a WebGL
    context.,:(,{“antialias”:true,“alpha”:false,“depth”:true,“stencil”:true,“majorVersion”:1,“minorVersion”:0}
    E Renderer: SDL error: SDL_CreateRenderer (Couldn’t find matching render
    driver)
    E Renderer: Couldn’t create renderer!
    I Renderer: Shutting down…
    I Renderer: Setting video mode to 800x600/fullscreen
    I Renderer: SDL available renderers: opengles2 software
    Could not create canvas: Web page was not allowed to create a WebGL
    context.,:(,{“antialias”:true,“alpha”:false,“depth”:true,“stencil”:true,“majorVersion”:1,“minorVersion”:0}
    E Renderer: SDL error: SDL_CreateRenderer (Couldn’t find matching render
    driver)
    E Renderer: Couldn’t create renderer!
    I Renderer: Shutting down…
  • Engine: Log file ended Tue Dec 30 15:53:23 2014

My laptop has Nvidia Optimus technology in it so since the message
mentioned it couldn’t create a renderer I thought that it might have
something to do with it using the Intel GPU or the Nvidia one. So I tried
running primusrun chromium-browser https://icculus.org/~icculus/ emscripten/test_renderer/test_renderer.html but it still fails. Is this a
problem that you or others have encountered?

I’m interested in Emscripten and have played around using it a bit myself
although I’m still not very familiar with many things. I’ve seen some
really neat stuff done with it but all of it seems to be demos rather than
something of actual use or production purposes. It is hard to deny that
your demo is very cool though :slight_smile:

Martin,
All of your links do not work no matter what I try :frowning: I noticed a bit of
activity on your GitHub repo when you initially posted the links and
figured you were still changing stuff but they are still not working. It
always results in a large gray box (probably the rendering window) with a
fullscreen button beneath and then below that is another gray box (which
appears to be a text box of some sort).

Cheers
JonathanOn Sat, Dec 27, 2014 at 4:43 PM, samleo <samuel.leonardo19 at gmail.com> wrote:

Cool news


My project
http://sourceforge.net/projects/dangeroustux/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

i will try to add a loading bar to my examples. currently you have to wait until they are loaded - which may take some time dependent on your connection. the games are working for me in chrome and firefox on linux. it just takes a few minutes until they are loaded. cavepacker is smaller (round 10mb) caveexpress is bigger (35mb) - so the first should be loaded faster. the html5 links on http://www.caveproductions.org should now always be up to date.

thanks for testing it and for the feedback. i will try to improve them.Am 30.12.2014 um 23:06 schrieb Jonathan Greig :

Ryan,
Your test app works fine on my Android phone using Chrome and will run fine on my linux laptop using Firefox but will not work at all using Chrome on my laptop. It ends up with this output when it fails under Chrome:

  • Engine: Log file started Tue Dec 30 15:53:23 2014
  • Engine: Build string: test_renderer, revision hg-411:37f26bc0e0cc, built Dec 10 2014 15:21:26, by Clang 3.3.0
    E Ini: Failed to open config file engine.ini
    I Engine: Command line:
    I Engine: argv[0]: ./this.program
    I Renderer: Setting video mode to 800x600/windowed
    I Renderer: SDL available renderers: opengles2 software
    Could not create canvas: Web page was not allowed to create a WebGL context.,:(,{“antialias”:true,“alpha”:false,“depth”:true,“stencil”:true,“majorVersion”:1,“minorVersion”:0}
    E Renderer: SDL error: SDL_CreateRenderer (Couldn’t find matching render driver)
    E Renderer: Couldn’t create renderer!
    I Renderer: Shutting down…
    I Renderer: Setting video mode to 800x600/fullscreen
    I Renderer: SDL available renderers: opengles2 software
    Could not create canvas: Web page was not allowed to create a WebGL context.,:(,{“antialias”:true,“alpha”:false,“depth”:true,“stencil”:true,“majorVersion”:1,“minorVersion”:0}
    E Renderer: SDL error: SDL_CreateRenderer (Couldn’t find matching render driver)
    E Renderer: Couldn’t create renderer!
    I Renderer: Shutting down…
  • Engine: Log file ended Tue Dec 30 15:53:23 2014

My laptop has Nvidia Optimus technology in it so since the message mentioned it couldn’t create a renderer I thought that it might have something to do with it using the Intel GPU or the Nvidia one. So I tried running primusrun chromium-browser https://icculus.org/~icculus/emscripten/test_renderer/test_renderer.html but it still fails. Is this a problem that you or others have encountered?

I’m interested in Emscripten and have played around using it a bit myself although I’m still not very familiar with many things. I’ve seen some really neat stuff done with it but all of it seems to be demos rather than something of actual use or production purposes. It is hard to deny that your demo is very cool though :slight_smile:

Martin,
All of your links do not work no matter what I try :frowning: I noticed a bit of activity on your GitHub repo when you initially posted the links and figured you were still changing stuff but they are still not working. It always results in a large gray box (probably the rendering window) with a fullscreen button beneath and then below that is another gray box (which appears to be a text box of some sort).

Cheers
Jonathan

On Sat, Dec 27, 2014 at 4:43 PM, samleo <samuel.leonardo19 at gmail.com> wrote:
Cool news

My project
http://sourceforge.net/projects/dangeroustux/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Great ! I have tried emscripten port and it worked immediately.
I have also compiled sdl mixer, image and ttf with a few dependencies
(jpeg, png, freetype, libz).

A few tips in the makefile would have been useful like :

  • don’t use the sdk from the linux distribution but get it from the
    official website.
  • use the option “–preload-file” to add assets to you app
  • use the option “-Oz” to reduce the size of the ouputOn Wed, Dec 31, 2014 at 8:07 AM, Martin Gerhardy <martin.gerhardy at gmail.com> wrote:

i will try to add a loading bar to my examples. currently you have to wait
until they are loaded - which may take some time dependent on your
connection. the games are working for me in chrome and firefox on linux. it
just takes a few minutes until they are loaded. cavepacker is smaller (round
10mb) caveexpress is bigger (35mb) - so the first should be loaded faster.
the html5 links on http://www.caveproductions.org should now always be up to
date.

thanks for testing it and for the feedback. i will try to improve them.

Am 30.12.2014 um 23:06 schrieb Jonathan Greig :

Ryan,
Your test app works fine on my Android phone using Chrome and will run fine
on my linux laptop using Firefox but will not work at all using Chrome on my
laptop. It ends up with this output when it fails under Chrome:

  • Engine: Log file started Tue Dec 30 15:53:23 2014
  • Engine: Build string: test_renderer, revision hg-411:37f26bc0e0cc, built
    Dec 10 2014 15:21:26, by Clang 3.3.0
    E Ini: Failed to open config file engine.ini
    I Engine: Command line:
    I Engine: argv[0]: ./this.program
    I Renderer: Setting video mode to 800x600/windowed
    I Renderer: SDL available renderers: opengles2 software
    Could not create canvas: Web page was not allowed to create a WebGL
    context.,:(,{“antialias”:true,“alpha”:false,“depth”:true,“stencil”:true,“majorVersion”:1,“minorVersion”:0}
    E Renderer: SDL error: SDL_CreateRenderer (Couldn’t find matching render
    driver)
    E Renderer: Couldn’t create renderer!
    I Renderer: Shutting down…
    I Renderer: Setting video mode to 800x600/fullscreen
    I Renderer: SDL available renderers: opengles2 software
    Could not create canvas: Web page was not allowed to create a WebGL
    context.,:(,{“antialias”:true,“alpha”:false,“depth”:true,“stencil”:true,“majorVersion”:1,“minorVersion”:0}
    E Renderer: SDL error: SDL_CreateRenderer (Couldn’t find matching render
    driver)
    E Renderer: Couldn’t create renderer!
    I Renderer: Shutting down…
  • Engine: Log file ended Tue Dec 30 15:53:23 2014

My laptop has Nvidia Optimus technology in it so since the message mentioned
it couldn’t create a renderer I thought that it might have something to do
with it using the Intel GPU or the Nvidia one. So I tried running primusrun chromium-browser https://icculus.org/~icculus/emscripten/test_renderer/test_renderer.html
but it still fails. Is this a problem that you or others have encountered?

I’m interested in Emscripten and have played around using it a bit myself
although I’m still not very familiar with many things. I’ve seen some really
neat stuff done with it but all of it seems to be demos rather than
something of actual use or production purposes. It is hard to deny that your
demo is very cool though :slight_smile:

Martin,
All of your links do not work no matter what I try :frowning: I noticed a bit of
activity on your GitHub repo when you initially posted the links and figured
you were still changing stuff but they are still not working. It always
results in a large gray box (probably the rendering window) with a
fullscreen button beneath and then below that is another gray box (which
appears to be a text box of some sort).

Cheers
Jonathan

On Sat, Dec 27, 2014 at 4:43 PM, samleo <samuel.leonardo19 at gmail.com> wrote:

Cool news


My project
http://sourceforge.net/projects/dangeroustux/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Sylvain Becker