
d3d9-webgl — Run Legacy D3D9 Code in the Browser Without Rewriting It
I ported a 2003 online game to the browser. The game was written in C++ with Direct3D 9. Emscripten handles the C++-to-Wasm part fine, but the moment you #include <d3d9.h> , the build dies — that header only ships with the Windows DirectX SDK. The obvious options all sucked: Approach Problem Rewrite the renderer in WebGL / Three.js You're basically rewriting the game Convert D3D9 calls to OpenGL one by one Still a massive rewrite Re-implement the D3D9 API itself, backed by WebGL The existing code doesn't need to change So I went with option 3 and built d3d9-webgl : a header + source file set that implements D3D9 interfaces on top of WebGL 2.0. You drop it into an Emscripten project, and your D3D9 code compiles and runs in the browser as-is. Does it actually work? The game I was porting is GunZ: The Duel (2003). The rendering code required almost no changes. You can play it at gunz.sigr.io . gunz.sigr.io How it works IDirect3D9 , IDirect3DDevice9 , IDirect3DTexture9 — all the COM interf
Continue reading on Dev.to Webdev
Opens in a new tab


