Replies: 10 comments 2 replies
|
To start the discussion, I want to share some data points that I gathered while doing work on emscripten:
glfw is not a very well supported API for emscripten:
|
|
SDL2 is actually an emscripten "port": the actual source code lives in the SDL library itself and emscripten is simply pulling it when you use the This library is actually written in C and compiled to wasm when using the port. Note that this library is already Hi DPI aware (via flag Note that @ubkp already did an amazing job demonstrating that emscripten SDL can be used as a new or alternate raylib web platform (see PR). The PR also demonstrates that there are far more raylib APIs implemented due to the fact that emscripten/SDLs has more equivalent. |
|
Based on these initial observations I think:
I also think that the PLATFORM_WEB_SDL direction from the PR should be investigated to see if it would be a better implementation than glfw. |
|
Thanks for the detailed investigation. |
|
@Peter0x44 Thank you for pointing out the copy/paste issue. I fixed it in the comment. |
|
@ypujante Thanks for the investigation and the recap. Here some info for completion:
In any case, as usual, maintenance is a big concern for me so, new platform additions or big code changes would require some maintainer. |
|
@raysan5 Thank you for providing history and context. It is always a pleasure to learn why things are the way they are and perspective moving forward. This helps a lot.
When I started my project (desktop ImGui based) I tried to use SDL and I agree that it was very big so I could not embed it and went with GLFW as well. That being said, as I was pointing out, when using the emscripten compiler, you don't need to embed SDL in raylib, nor need to worry about having it installed locally, nor how to compile it. It's all taken care of (which is pretty neat). But I totally see your point.
I think that it is definitely an interesting idea. As I suggested in one of the other issue/pr threads, when I have a few spare cycles, I can take a look at this and see how big of an effort that would be.
I feel like with a little more work on the platform split, it should be fairly easy to be able to add a new platform without requiring any changes to raylib at all, which would allow for external platforms that are neither created nor maintained by you. I do not know if this is something of interest to you, but this is something I could provide help as well with. |
Thanks, please, let me know. I think it shouldn't be that complex but it could require some redesign on how inputs are polled to deal with the async nature of browser... probably the previous callback-based mechanism won't work any more.
That's ok for me, actually, I'm already aware of some custom platform implementations using the new architecture: PS4/PSVita homebrew, not officially released yet. |
|
I have been thinking about this for a long time. I really like wasi-sdk, and just relying on WASI for as much as possible (files, memory-management, etc) and leaving other functions directly to WASM imports. It means that if I need to make the wasm run in native wasm host, I just expose a few functions that do the extra stuff. Emscritpen is obfuscated, and has a lot of layers that assume web/js is the host, so it's very hard to actually use it's wasm in anything else, and it's js/wasm shim things end up really big & complicated and lock you into js (and sometimes web) hosts. I think emscripten's way of a jenky SDL layer, then a bunch of junk on top of that, all using embedded JS calls, is just not the right way to go. I use it when I want to quickly get something working on the web, but it's never efficient or extensible. I made easywasm/gl to explore the idea of just exposing GLFW over wasm. The basic idea is you write code as if you have stdlib (handled by wasi imports) and glfw (handled by imports in host) and it ends up pretty small & simple. I think it'd need a lot more GL functions to be usable, but this sort of path might work. My goal is no-recompile game blobs that are small, efficient, and can be written in any language that compiles to wasm (many languages supported) and run in any wasm host (native, web, esp32, etc.) I managed to accomplish this with my engine, but the host part still uses emscripten, and I would prefer raylib's API to mine. I did similar here, but more recently I am trying to drop all of my dependency on emscripten. It requires implementing the entire raylib API as web-code, then importing it. That way on a native host I could do similar, but just use the native APIs. I think a 3rd option might work, which is to make a new PLATFORM and implement it on GLFW/WASI imported functions. Another idea is to just follow a spec like wasi-gfx and skip the GLFW-compatable interface, or even just write a whole new one (focused on a minimal amount of functions that need to be implemented and passed over the wasm boundry.) |
|
I am just going to close this discussion. This discussion was opened 3 years ago I am no longer involved in raylib, so please open another one. |
Uh oh!
There was an error while loading. Please reload this page.
I am creating this ticket as a follow up to a bunch of conversations that happened throughout various tickets and pull requests created in the past right before the release of raylib 5.0.
This discussion is about the raylib web platform and the usage of emscripten.
The status (as of raylib 5.0) for the web platform is to use emscripten/glfw.
This implementation currently works fine since it is the one used for all the raylib examples. That being said it has a lot of limitations as indicated by the many unimplemented APIs.
The purpose of this ticket is to see whether there is a better alternative.
Disclaimer: I will not be offended if this ticket gets closed or leads nowhere. I am just trying to help, but I also understand that I do not have all the pieces/history of the project and it's fine to not want to move forward.
All reactions