Displaying SVG in OpenGL without intermediate raster

前端 未结 5 1685
青春惊慌失措
青春惊慌失措 2020-12-01 04:03

I have some simple SVG artwork (icon and glyph kind of things) which I want to display in an OpenGL app (developing in C++ on Debian, using Qt).

The obvious solution

5条回答
  •  粉色の甜心
    2020-12-01 04:19

    I made a vector drawing program called Omber that has some ability to import SVG files, and it can export vector drawings to a "flattened" 3d model in glTF 2.0 format. The glTF format is pretty much just raw OpenGL data, so you can read it in and display it with minimal code. I wrote a little Pixi.js plugin for displaying glTF files containing vector art using WebGL.

    Blender also has support for importing SVG files. You can then export the result to a 3d file format, but the Blender support for SVG is intended more for importing simple curves rather than complex drawings.

    I'm sure there are other tools that can do stuff like this as well. One issue is that SVG predates modern graphics hardware, so a lot of its features are a real pain to implement with OpenGL, especially in an efficient way. Things like opacity on groups, gradients of irregular shapes, raster-based filter operations, etc. can get messy, so I'm not sure if the more esoteric features of SVG are generally supported by programs that can convert things to 3d formats.

提交回复
热议问题