3 ms·
Why not? I'm pretty ignorant about SVG (and about writing 3D/vector games in general), so I don't immediately see a reason why SVG wouldn't be well-suited to ga
by glhaynes 14y ago
Why not? I'm pretty ignorant about SVG (and about writing 3D/vector games in general), so I don't immediately see a reason why SVG wouldn't be well-suited to games. Is it just because browsers aren't as performance-optimized for it as they are for <canvas> and WebGL? I suppose for a "modern" game you'd want to have all sorts of textures and shaders which maybe aren't part of SVG?
Edit: Or perhaps it's because the other technologies "carve out" a piece of the page just for themselves whereas SVG doesn't and so browser reflow/layout code has to be invoked more often when SVG elements are being used?
- Wilya 14y agoGenerally speaking, SVG is more integrated to the DOM than canvas or WebGL. Every shape you draw is a DOM node, which means you can easily interact with it (mouseover events, ...), but also that it's rather "heavy". It doesn't scale for effects as well as canvas and WebGL, you can't really display more than a couple thousand nodes without risking major slowdown. It's nice for very interactive demos and lightweight visualizations, not for rendering-heavy things like games.
- pmelendez 14y agoYour point is very valid but only on the realm of web games using browser's native support of svg. For instance, you would not have DOM-related problems if you use svg files in a native mobile game. The downside of using SVG in a game is that the render is slower in comparison with a rasterized image. However, all graphics formats have pros and consts, so it always depends on how are you going to use them.