3 ms·
That was my second option - canvas. WebGL is a type of HTML5 canvas context. Unfortunately, there are major drawbacks which I also outlined - it's too low leve
by bri3d 5y ago
That was my second option - canvas.
WebGL is a type of HTML5 canvas context. Unfortunately, there are major drawbacks which I also outlined - it's too low level and loses platform consistency, accessibility, usability, and really every affordance of an operating system - you're starting over from scratch and loading in dependencies or writing your own implementation of some immensely challenging concepts (font rendering on its own is usually several hundred kb of code and could fill textbook upon textbook).
If you're familiar with GL UI frameworks like dear-imgui, they do all work pretty well in WebAssembly. But again, they're compromised from the start because you lose all OS consistency and accessibility. And unlike in games, where these frameworks are often employed, OS consistency isn't expected, and accessibility is sadly ignored, the experience of a cross-platform UI framework appearing in a canvas element on the web becomes jarring very quickly.
There is an alternative approach, like Google Docs employs and the sibling poster linked - combining the DOM for input elements with custom rendering. But, this is really, really complex and challenging.
Every time I develop applications for the web, I yearn for an application-focused presentation layer which provides the expected fundamentals around accessibility, OS consistency, and rendering layout while ditching the hacks-on-hypertext minefield of CSS and the DOM.