azimuth icon indicating copy to clipboard operation
azimuth copied to clipboard

Web port

Open midzer opened this issue 1 year ago • 7 comments

Hi,

first of all, great game! :)

I try to port the game in the browser. But I am running into an issue using an OpenGL translation library https://github.com/ptitSeb/gl4es/issues/472

Basically, those alpha blended wall brown structures (which are destroyable with the first weapon upgrade) are not visible at all.

Perhaps there are some "special" OpenGL functions used which are not supported by gl4es?

Have a nice week midzer

midzer avatar Oct 09 '24 18:10 midzer

Thanks for the interest! It would be fun to see the game get ported.

Azimuth's graphics rendering is written in old-timey immediate-mode OpenGL, and uses some deprecated features that, to the best of my knowledge, aren't supported by GLES. In particular, the brown destructible girder-like walls are drawn using GL_QUADS, but I don't believe that's a supported draw mode in GLES, so perhaps the translation library can't handle it.

If glBegin(GL_QUADS) isn't supported, then porting may well require rewriting a bunch of the rendering code to draw those game objects with e.g. separate GL_TRIANGLE_STRIPS instead, which would be a fair bit of work to rewrite and test. I don't know whether or not there's an easier solution.

mdsteele avatar Oct 10 '24 14:10 mdsteele

Thanks for the reply @mdsteele

When linking azimuth with legacy GL emulation https://emscripten.org/docs/porting/multimedia_and_graphics/OpenGL-support.html#emulation-of-older-desktop-opengl-api-features there are undefined symbols like glGenLists, glNewList, glEndList and glVertex2d.

So, I have to rely on gl4es for now and investigate how solve this (minor) graphical issue described in first post.

midzer avatar Oct 10 '24 15:10 midzer

Finally, I got it working:

https://midzer.de/wasm/azimuth/

Thanks again for your detailed explanation @mdsteele

Relevat GL_QUADS -> GL_TRIANGLE_STRIPS changes in https://github.com/midzer/azimuth/tree/replaceQuads

Emscripten relevant changes in https://github.com/midzer/azimuth/tree/emscripten

P.S.: Some walls still appear to be invisible, after you got the Charge beam.

midzer avatar Apr 25 '25 08:04 midzer

This is so cool! I gave it a quick try, playing through the first boss. Really neat to be able to play the game in a browser.

A few notes while I'm thinking of them:

  • I see what you mean about the invisible walls. I believe those ones are drawn via GL_QUAD_STRIP. Changing that to GL_TRIANGLE_STRIP might fix it, not sure.
  • There were a few other graphics (like the player ship and the save stations) that didn't look 100% right; I'm guessing that's a consequence of turning GL_QUADS into GL_TRIANGLE_STRIP with no other code changes. Probably fixable case-by-case, but that would be more work.
  • On my machine at least, the game was dropping frames in a couple of rooms (the Charge Gun room and the first boss room, I think?). Not sure how to address that; maybe legacy GL emulation is just slow.
  • My saved game didn't seem to persist when reloading the page; is it expected to? If not, perhaps that could be hooked up to localStorage somehow.

mdsteele avatar Apr 26 '25 12:04 mdsteele

@midzer, is there a chance that the port will be up again? https://midzer.de/wasm/azimuth/ Sounds amazing.

zapalagrzegorz avatar Jun 07 '25 17:06 zapalagrzegorz

@zapalagrzegorz Link works for me.

midzer avatar Jun 07 '25 22:06 midzer

I needed time to recover from my embarrassment. I just didn't realise that I was supposed to click on 'Load'. Is there any perspective to save the state into browser memory? @midzer

zapalagrzegorz avatar Jul 03 '25 11:07 zapalagrzegorz