Comments (9)
I integrated raylib into the repository above. I'll add this to h-raylib as soon as possible.
from h-raylib.
It’s been a while since I made that comment. At the moment, h-raylib uses a lot of template haskell internally, so I don’t think it is possible to get it to work. Afaik we’ll just have to wait for ghc wasm support for template haskell.
from h-raylib.
Update: I was able to make a simple example using haskell to call JS functions. Once it's cleaned up a bit I'll create a repository for it.
from h-raylib.
This will be possible when the ghc WebAssembly backend adds support for JS FFI. Then the C code can be compiled with emscripten and the Haskell can be compiled to wasm.
from h-raylib.
Do we know if GHC has made any progress on this? I feel like h-raylib could handle this this could become a really simple and universal method of getting into haskell gamedev. I feel like it'd be a huge challenge to get this working and I wouldn't know where to begin, but if you think it's possible then there's hope maybe? :)
from h-raylib.
Web building with GHC is still a somewhat complex process (this has the instructions. It seems a lot simpler than it was when I created this issue though).
What I had in mind for this was to compile the Raylib C code using emscripten (as described here), which would output JS equivalents to the raylib functions. Then the Haskell code would be compiled using GHC's web build support. The main problem is finding a way to link the two together (i.e. call the JS functions from Haskell). I found this article about it (the article is about Asterius, which has since been merged into GHC), so it should be possible.
from h-raylib.
Here's the proof-of-concept repository: https://github.com/Anut-py/ghc-web-test
As I said, the Haskell-to-WASM compilation process is a bit of a hassle, but it's relatively simple with Nix. Now that this is done I have to figure out how to call the raylib functions through WASM.
from h-raylib.
I have (in the web
branch) added experimental web support and converted the basic-window example into a web-compatible example. Unfortunately, ghc's wasm backend does not yet support Template Haskell, which is required for the changes I made*, so we'll have to wait a bit. TH support for the wasm backend is being worked on, and you can track the progress here.
* The changes to support the web actually don't require TH; I made a TH function to make writing h-raylib/web programs easier, which is why Template Haskell support is necessary. See Raylib.Util.raylibApplication
and the basic-window example for more (in the web
branch, of course).
from h-raylib.
First of all, you are doing great work here! I'm very excited about the possibility of running a Haskell/raylib game in the browser.
The changes to support the web actually don't require TH; I made a TH function to make writing h-raylib/web programs easier, which is why Template Haskell support is necessary. See Raylib.Util.raylibApplication and the basic-window example for more (in the web branch, of course).
Does this mean that it's possible to skip raylibApplication
to get web working without template haskell? I'm eager to get the web support 😄
Thanks!
from h-raylib.
Related Issues (20)
- Add Lens instances for Raylib types HOT 1
- Make whileWindows more general by replacing IO with MonadIO HOT 1
- Should drawCapsule using Float instead of CFloat? HOT 1
- Suport for ghc 9.4 and higher?
- Considering add some helper `bracket` functions to Util in order to avoid begin* and end* syntax HOT 2
- More abstraction for WindowResources passed to load/unload* functions? HOT 1
- `clamp` function in Raylib.Util.Math can be more haskellish HOT 1
- Add script file to update raylib git ref in flake.nix
- Add support for raygui HOT 2
- Windows - GCC missing libs error HOT 1
- Add nix build in GitHub actions
- Add bunnymark example
- `5.1.1.0` release checklist
- Incompatible with latest base versions (anything above 4.18.2.0) HOT 2
- Module ‘Raylib.Util’ does not export ‘raylibApplication’ HOT 2
- Drag and drop does not work as expected HOT 2
- defaultWindowResources is undocumented HOT 3
- Pure version of `getScreenToWorld2D` function in rcore HOT 1
- `unloadImage` is missing in `Raylib.Core.Texture` HOT 1
- The function loadDroppedFiles
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from h-raylib.