-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
oF in HTML5 #1319
Comments
This sounds amazing! How would it work? Do you have any links describing this process? I imagine we'd have to figure out how to run a severely stripped down version of OF so we're only doing OpenGL? On Jun 9, 2012, at 10:58 AM, David Stolarskyreply@reply.github.com wrote:
|
Right, camera input for example wouldn't work for free, but you could get it through a Flash webcam bridge, or eventually through HTML5 webcam support. Likewise sockets won't work, but XmlHttpRequest and WebSockets will. Also libs we don't have source for, like Fmod, won't work. But if you have the C++ (or C, or Obj-C, or others), emscripten will convert it to JavaScript, and the switch from OpenGL to WebGL is demonstrated e.g. here: http://www.syntensity.com/static/ammo.html (Bullet Physics demo, it's a big C++ 3D physics engine). emscripten: https://github.com/kripken/emscripten/wiki I haven't used emscripten myself yet, but it looks very very healthy on github, and obviously it's really amazing. LLVM is the new compiler Apple is pushing, it replaces parts of or all of GCC, depending on how you use it. It's the default compiler when you use Xcode 4. Basically the LLVM family can compile lots of languages, including the C's, into "LLVM bitcode" and from there, backends can generate native code for x86, or ARM, or whatever, and these crazy people decided to make a JavaScript generator for it. |
that's amazing. we totally need to get on this. i think webgl will definitely be more likely to be adopted in a cross-platform, cross-browser way than any of the chrome nacl stuff. and having OF running on the web would be huge! |
there's a demo of a Python runtime ported to JavaScript using emscripten, and also a h264 decoder it seems using the v8(?) engine of chrome it's possible to get machine-code like performance if you code it with specific 'register'-friendly data structures. something like a 20% drop from machine code is possible for some projects. but this is all a toy and doesn't offer true oF-in-browser support (devices, filesystem, consistent performance) emscripten and equivalents could revolutionise webcode what would the IDE be like? is there a reason not to make a native openFrameworks.js? what about native client (that's a pretty easy cross-platform deployment mechanism we could hook right into with likely less hassle than event an iPhone or Android which we've already achieved) |
right, this would not fully support all of oF. "openFrameworks.js" might be the wrong name. it's more like oF on iPhone, which also does not support arbitrary devices. the IDE is whatever you normally use, the code looks the same, you just compile in a different way, outputting JavaScript and HTML instead of OS-native binaries. the filesystem (well file reads at least) would become HTTP loads. writes actually could happen too, by just adding a little server-side file write end point (one filesystem, endless number of users, interesting, no?). webcam will work with some glue; overall device support would be no worse than on iOS. my original motivation is to have a way to write primarily graphical / animation "widgets" in one language/framework and deploy them to web browsers, natively on mobile devices, and natively on desktop platforms. but i think "apps" and "applications" are also viable candidates for this sort of system, and perhaps the web server as the filesystem could be a quite interesting feature to offer oF-land. i think performance will work itself out as JavaScript and WebGL mature. |
Hi ! A. writing javascript language and use oF API. It seems @codeboost already made a step in the A path : https://github.com/codeboost/JOpenFrameworks What would be the benefit ? What would be the limit ? Actually, it seems that :
About performance I totally agree with @gimlids performance will work while JS + WebGL grow up. Have a nice day ! |
the way i imagine it, this is (B), exporting a normal C++ oF app to HTML5. though perhaps converting oF to .js through emscripten would make it pretty easy to actually provide oF's API to JavaScript coders. the benefit is (1) opening the web browser to oF developers, but maybe they already know sufficient JavaScript? need to do some market research =) and benefit (2) "write once, run everywhere" for graphical / animated apps. to elaborate on my original motivation -- i want to target native iOS and the web browser at the same time. (and Android and desktop at the same time as well, sure why not) also i agree, JavaScript is surprisingly delightful, especially once you get into the functional style. |
the 'tidy way' is going to be somehow writing an openFrameworks lib that compiles to js and wraps native WebGL calls for graphics. then when you compile you staticly link that lib instead of the oF OpenGL ones and then a seperate piece of work to expose oF api back to JS for in-browser livecode hacking |
A little update/bump because today Google/Chromium announced they are forking WebKit --> Blink and making some big, interesting changes, and also emscripten is alive and well, and Mozilla is somehow involved with it. So like, the web, and stuff. @elliotwoods If I understand you correctly, I think you are suggesting more work than is necessary for this. What emscripten is supposed to mean is that we just write an appropriate Makefile and voila, oF apps can be compiled straight to "HTML5." Only caveats I think are local filesystem access, sockets, things like that. OpenGLES automatically gets mapped to WebGL through the emscripten (and maybe asmjs.org) process, so as long as "HTML5" mode uses OpenGLES calls, as already exist for iOS, that part is taken care of. Maybe C/C++ sockets will be automatically mapped to WebSockets now, or in the future.. not sure on that. Can anyone think of outstanding reasons a lot more work might have to be done? Poco (I'm not so familiar with it, nor its integration in oF)? FMOD audio comes as a DLL already, so I assume emscripten will not eat it up. For ofFile, a portion of ofFile (the read part) could be implemented as a URL load, so you just put your app on a web server, and file reads happen over HTTP... |
i've been trying emscripten, haven't done anything serious yet just tried to compile a couple of c programs and it looks promissing. i want to try to compile OF. i've been looking at google's naci for a while but the fact that it only runs on chrome and that the only way to distribute naci apps is through the chrome store so it makes it way less interesting that it could seem at first. Once we have gles2 in the core it should be fully compatible with webGL i guess. There's probably some stuff to do like packing resources with the binary while compiling but apart from that i think it's just a matter of compiling and removing the modules that won't work ( i guess sound and video by now ) |
i discovered the JopenFrameworks project and i tought that it can run in a browser. After seeing the video in the forum http://forum.openframeworks.cc/index.php/topic,6335.0.html and reading this discussion i realize that it can't as it is run in a browser. Will be nice if we can run OF application via a .js in a browser. But when it will possible? |
@kalwalt i don't know anyone who is actively developing OF in the browser right now. the only real "plans" for OF are to keep supporting people in whatever way they're using it. but if it's something you're excited to see, we're excited to support you in making it happen :) maybe @gimlids and @arturoc can give an update on what they've found so far. |
thank's for the answer @kylemcdonald ! yes i'm very excited , i'm trying right now emscrypten. I've only tested the basic examples for now. i want to see OF in my browser! In Ubuntu 12.04 64bit i installed llvm3.2 as suggested form the emscripten wiki https://github.com/kripken/emscripten/wiki/Tutorial . I'm not sure of one thing. i have installed only the 64bit version of llvm3.2 should i install also the 32 bit version? |
@kalwalt any updates? I just installed LLVM and Clang 3.2 in Ubuntu 11.10 and I'm interested in helping with oF building using emscriptem. As pointed in https://github.com/kripken/emscripten/wiki/Building-Projects I believe we have to build every oF dependency as well... |
I've been looking at this recently and i also think the best option would be emscripten, nacl is another, it would be faster but it's chrome only and it requires to go through the chrome store. emscripten supports webgl, which should work without problem with the latest programmable GL renderer, except for VAOs which i'm not sure if they work in GL ES/WebGL and yes it needs to recompile every library we use with emscripten so a good beginning would be to start by doing that, the other thing needed would be to create the corresponding platform makefile config file. we'll probably need to do something in the makefile to include any resource file in data in the executable although in this case the best would be to use online resources. apart from that i think all the code we currently have should work. |
@automata @arturoc for now i'm only trying to understand how emscripten works. I tried different simple examples that you can find in the tests folder and i can say that it is very easy when the code is limited to one or few .cpp or .c files. Even the ability to export directly to .html with the javascript code embedded is awesome! For me became more difficult when is involved an entire project. But as point out arturo we should recompile every library we use. The question is: should be a difference doing this in linux or windows or Mac? the final result should be something like a of.js as for processing.js ? we should use emscripten also for testApp.* and main.cpp? or we can code directly in javascript after?
do you mean a config.h? i looked in https://github.com/kripken/box2d.js/blob/master/Makefile and https://github.com/kripken/box2d.js/blob/master/root.h |
i don't think there's a big difference, although perhaps the easiest
i think we should compile the apps from c++ but there could also be an
there's a linker option to add resources in the final 'executable' don't
|
If we had an of.js that supported all the libraries we use (not just gl) wouldn't that mean of.js would be something like a 3MB download? Is it common to have js libraries that are that big? |
this issue interested me a lot, and I can confirm you that it is not common :) 3MB is like mega huge. Interesting talk about emscripten : John Resig about size : My two cents is , what would be the purpose, does of.js will allow to develop in the browser and see in realtime what we are developing or will it just allow any of application to be ported to the browser. If it is the second then size matter and should be tiny tiny. |
3Mb is huge and probably an of.js would be even bigger, i think it's ok though this is not a usual web page it's a c++ app running in the browser, users won't shouldn't expect fast downloads... also we can host the libraries with version somewhere so every app can point to the same library and take advantage of the browser cache, that way the library will be downloaded once only for all the apps using the same version |
you @kylemcdonald @gabrielstuff and @arturoc are right regarding the size of the hypothetical of.js. This is a nonsense if you want make a little interactive app on the web. ( but maybe at this point better use another library, processing.js , jquery, or other) but if you want develop a 3D interactive app? see the BananBread project https://github.com/kripken/BananaBread for the code and for the demo https://developer.mozilla.org/it/demos/detail/bananabread just for an idea. The point is that Openframeworks is not a game engine but we could do very interesting stuff with a javscript version in the 3d field and with the OF flexibility. |
if you are only interested in 3D, why not three.js ? |
Absolutely yes, sure it will be easier. There are also other project like scene3d.js and osg.js (mentioned above) but i'd like to do also some little app with OF if it is possible. In these days i'm exploring different javascript libraries to find the best that fits on my ideas and Three.js is full of resources... |
here's a slide show about C++ and emscripten that has some useful info about porting games, etc: http://de.slideshare.net/andreweissflog3/quovadis2013-cpp-ontheweb |
thanks @ofZach the slide is very useful. it is a bit clear now some of the emscripten ascpects. |
Tryed the smartest possiblity with emscripten id est run emmake make in an example folder but i got this:
shouldn't pkg's already configured with makefile? |
At some point the iOS target should be specified (or better yet a more On Tuesday, April 30, 2013, Walter Perdan wrote:
|
@walter: you'll need to hack oF a bit to have no video player / no video grabber / compiling poco for emcripten might be tougher (threads, network, filesystem the other packages (gstreamer, cairo) can be dropped from the project if you need video support later, then there'll have to be an my 2cents : i also think this is a lab curiosity more than a serious that said, i can see the attraction. elliot On 1 May 2013 02:20, David Stolarsky notifications@github.com wrote:
Elliot Woods |
@elliotwoods i think that the reason for those errors is the fact that i didn't run a ./configure emconfigure before the emmake make process (because we haven't one in OF, but i'm not very expert in this field, i have a lot to learn) . the emconfigure should configure emscripten with all the packages, includes, etc as a configure always should do. Your are right about video player, video grabber and cairo. I didn't change any part of OpenFrameworks in this test. I'll have to exclude some parts of the code and to try to solve the problem of packages and especially GL. the most problematic definitely will be the poco lib.I'll have to exclude some part of the code and try to solve the problem of packages and especially GL. the most problematic definitely going to be the poco lib. p.s. my name is walter but my nick is @kalwalt not @ w a l t e r . sorry for the problem! |
oh, great, since i had already read the thesis, i didn't got in the pdf :) |
Openframeworks -> emiscripten: I can't belive that is becoming reality! Many thanks for this @abergmeier and good luck for your thesis! @elliotwoods next stop online IDE? yesss! |
openFrameworks has been added to the demo page of Emscripten. |
@abergmeier that's great! |
there are some news from this side? when we can test the new OF with emscripten? (i'm not talking of the example that you show) i'm learning three.js but i'd like to develop some personal project with Openframeworks in webgl. |
You can of course always start working based on my repo. Be aware, thought, that It depends on some experimental Emscripten stuff, that we are discussing about currently. So not ETA, when this will be upstreamed. |
Thank you @abergmeier i will try with your repo, also i see that is well commented with istructions, really excited to get hand on it! |
i'm trying to build the libraries (poco,kiss.. ect) but i don't undesrtand the 'empkg' command where it come from? it's a special feature of emscripten or i need to install other pkg ? |
|
thank you @abergmeier i'm going to fork your repo (incoming branch) and to test in linux64 and maybe windows. i will report here my progress from a OF side. |
@abergmeier i installed your branch i run empkg inside the openframeworks folder and i get this error:
i run only poco at the moment, have you an idea of this kind of error? |
Sorry, from a google search the error above happens because i'haven't Ninja generator installed, and maybe my cmake version is outdated... |
@abergmeier i have installed Ninja and the newest version of cmake 2.8.12.2, i did this:
i get some erros like this:
if i run ./rebuild in the same folder i receive unknown command. a part this issue may i run cmake after that can you give more detailed details fo the build process please? |
this has been merged in master, there's still some problems buf there's an specific issue |
guys sorry that i am late to the party here... I am new to the OF community and very interested in using OF on the web with emscripten. does anyone know of a repo where i can download the example code that @arturoc used in his site http://arturocastro.net/files/of-emscripten/ ? i would love to see file structures and understand how to run this locally on my machine... thanks all for your help! |
@reginaflores equally late in responding to your comment, but i think the status of emscripten is that it's been broken in master for some time #3426 (comment) and as far as i can tell, there is no issue tracking this besides #3426... |
hey, sorry i couldn't answer this before and then i totally forgot. the emscripten build is working fine. you just need to install emscripten acording to the instructions on their site and using the nightly builds build any of the examples using the normal makefiles. instead of |
I have no idea what I'm doing |
Hey All! Guess what????? IT'S WORKING!!!! http://faceproject.nyc/sphere/sphere.html This is just a silly proof of concept, but the point is that it works! Emscripten is AWESOME! Thanks for all the comments and assistance!!! I heart OF Community! |
woo! looking good @reginaflores! |
Does this not work on mac? Because I am getting a |
it shouldn't be using that file at all, are you using emmake make? you also need to have the emscripten tools in your path |
Yes I am using What I find strange is that the line of my error |
Hi @Inuart - maybe this can help:
try those tricks... it worked for me... also to note: i had to actually put the files online to see them working. Some of the examples I tried didn't worked when I was running them locally... not sure why. Good luck! |
yes somethings need a sever mostly with chrome, firefox is usually ok with it. you can also use |
Well nice @reginaflores ! It now compiles with the nightly builds! Although even running the |
yay! glad you got it to compile!!! As Arturo said (from my list above): For what its worth I put this in a blog post with pictures... maybe it's helpful: |
Hey @arturoc @reginaflores @kylemcdonald @abergmeier ! It works!!! This is AWESOME! I was able to compile the color example, i need to refresh the page in firefox browser to start the app (something to do with 'canvas'...). Tested in linux64 bit (Ubuntu 14.04): the most difficulties was due to my llvm installed. My wrong because you need the fastcomp llvm version as described in emscripten http://kripken.github.io/emscripten-site/docs/building_from_source/LLVM-Backend.html. So thank you all!... as soon i will do something with it , you will see on my web pages! |
Issue: openFrameworks does not run in the web browser.
Solution: the emscripten backend for the LLVM compiler generates JavaScript, many C++ OpenGL projects have been demonstrated running in the browser with WebGL.
Is anyone interested in this?
The text was updated successfully, but these errors were encountered: