Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Emscripten 7DRL results

A topic by heckruler created Mar 11, 2024 Views: 115 Replies: 1
Viewing posts 1 to 2
(+2)

Results: Failure.   No game produced.

Didn't get to dedicate too much time this year, but I learned a lot about emscripten as a build target for C projects.  The plan was to simply take any previous 7DRL entry, build it with emscripten, and publish the results.   Taking C and turning it into javascript has a little extra shimmy and shake to do.   The first time I tried this I thought it'd be as easy and switching one and and firing it off. A nice little feature on the side. But no.   The tough part here is every library you want to use needs WASM binaries.  It's a different build target. It needs all the code.   SDL comes pre-packaged with the emsdk, which is great. But libtcod and ncurses do not and so you have to build them with emcc.   

A couple of days digging into what's previously been done with ncurses on emscripten tells me there's still work to do there. I'd love to dive in and help debug this thing, but a 7DRL challenge isn't the best place. Switching over to a different project that used SDL, I learned a lot about what needs to be done porting over code.   There's a couple ways of bringing over files to load, and I got one working. There's also extra shenanigans you have to pull when dealing with big loops, which... well I never got to the bottom of. 

In the end I got one screenshot of the initial screen before I had to kill it as it was eating 1GB/sec of ram.

If you want to make something, use tools you know. If you want to grow, use tools you don't.

Fully agree to your closing  sentence.  I thought the same - how nice would it be to target desktop and web via emscripten. 

I had roughly 4 days for this 7drl challenge and eventually spent two days only for getting the build run via emscripten. Initially I used opengl 4.1 core but learned that I need to make it compatible with opengl 3.3 - so that it would run in webgl 2.0 which is similar to opengl es 3.0 in emscripten.

I needed to adjust all my glsl shaders and tackle some nasty bugs where things like the world generation would behave differently in the browser compared to the desktop version. 

So I needed to check the random number generators and also convert the data structures from c-style arrays to std::vector.

Also the asset loading needed to be adjusted for the browser with preloading resources in the virtual filesystem.

All in all I'm quite happy with the results and that I was eventually still able to make a web build via emscripten, although I thought it would take way less time to get it to work. But it was time well invested - now I'm able to do cross-platform for desktop and web for future jams and next years 7drl!