xymeng's blog
Summary of my WebGL port
The three months' coding for GSoC has ended and I'm proud to say that I've achieved the main goals in my project proposal. The final product is here:
http://hedgewars.org/hwjs/hwjs.html
In fact, when I started the project, I didn't have much idea about how well it would go. The tools I was going to use were not mature so it was hard to predict how many obstacles I might encounter. Fortunately, the developers in the channel, especially my mentor nemo, offered a lot of help so that I could proceed in the right direction. And finally, it turns out to be very successful.
I will still hang around in the channel and maintain the web port, though I won't be as free as in the summer vacation. There are still a few things to be done, probably also a project idea for next year's GSoC
1. Pas2C is not completely worry-free. I need to patch a few places in the generated sources. But luckily, most of the issues have been addressed;
2. AI is running in main thread and may not be as "smart" as the native version. Using web worker or reworking the AI code could solve the problem;
3. Optimize math operations (esp. Rope);
4. Write a html frontend;
5. Add multiplayer for the web version (this could be fun!);
6. Add sound. This is not hard since sound files are not critical, but loading them when needed may also degrade the gaming experience (if you have a slow network). Preload all or load on-the-fly, that's the hard choice.
Finally, thanks to all developers and GSoCers working for hedgewars!
xymeng
The beginning of the adventure
The goal of the project is to port the game to web browsers so that people can enjoy it without installing and it runs on all platforms with a modern browser. Furthermore, web is the future and there will be more and more games that are web compatible. I'm proud that I can be one of the pioneers to try some new things and know how to get it to work.
Since the technology is not mature enough, there are a lot of problems that I can or cannot foresee. The project is not to "hardcode" the game using javascript but rather find a clever way to convert the game engine automatically, which facilitates update and generally is aimed to develop a workflow or framework to automate the conversion process. Pascal and javascript are two different languages; native and web are two different platforms; these differences in terms of language specification and API compatibilities makes the conversion challenging and is basically the problem my project is going to solve.
My proposal divides the project into three phases:
(1) Port run-time library functions that pascal uses into C, which can be converted into javascript using empscripten.
(2) Port SDL functions into C or javascript if needed.
(3) Port the OpenGL code into Web GL.
Phase 1 and phase 2 are pretty much project independent, i.e. I don't need to depend on others' work much. However, I still need to dig into existing tools like empscripten and pas2c to see how smart they are. Phase 3 depends on the optimized rendering system since WolfgangSt is going to rewrite it to make it ES 2.0 compatible, and without the migration, I cannot do the conversion either. Finally I will integrate all things together. If everything works neatly, then it is time to write a web front-end and invite people to play it!
I feel very lucky since I have an awesome mentor nemo who always gives me great help and inspires me a lot. Here I'd like to give my sincere thanks to him and all mentors in advance. And good luck to all participants!