<p>You can use OpenGl 4.x tessellation shaders to convert Bezier control points into polygons.</p>

<p>A google search for "tessellation shader bezier" found this outline describing the tessellation of Bezier surfaces and curves:</p>

<p><a href="http://web.engr.oregonstate.edu/~mjb/cs519/Handouts/tessellation.1pp.pdf" rel="nofollow">http://web.engr.oregonstate.edu/~mjb/cs519/Handouts/tessellation.1pp.pdf</a></p>

<p>This offloads the Bezier evaluation from the CPU to the GPU and reduces the data flow across the bus.</p>

CC BY-SA 3.0
2015-11-12T20:41:33.173Z
You could improve this answer by elaborating a bit, or even just linking to something that explains further.
Nathan Reed
CC BY-SA 3.0
2015-11-12T20:46:54.930Z
One way of expanding this answer would be to address the drawbacks the author mentions, and explain how your approach helps with those.
trichoplax is on Codidact now
CC BY-SA 3.0
2015-11-12T17:01:58.687Z
2015-11-13T19:53:20.723Z
2015-11-13T19:53:20.723Z
atb
<p>One can do curved drawing with hardware. There is a method described in <strong>GPU Gems 3</strong> that describes how to do this. User @yuriks actually comments this. I have actually made a quick a dirty demo for you to take a look at.</p>

<p><a href="https://i.sstatic.net/D9F9k.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/D9F9k.png" alt="curve"></a></p>

<p><strong>Image 1</strong>: HW accelerated curve shapen (drawn usung a triangle) and <a href="http://webglplayground.net/saved/9ZD4Uoi72Q" rel="nofollow noreferrer">webgl source</a></p>

CC BY-SA 3.0
2015-11-15T12:12:19.667Z
2015-11-15T12:17:42.913Z
2015-11-15T12:17:42.913Z
joojaa
<p>How to quickly draw a curved shape?</p>

<ul>
<li><p>by "quickly" I presume one should use hardware facilities as much as possible</p></li>
<li><p>by "curved" I mean boundaries defined by either quadratic or cubic Bezier curves</p></li>
<li><p>by "shape" I mean either a "fat" stroke (i.e. more than 1px wide) or even-odd/non-zero filled "2D curved polygon", possibly with holes (i.e. letter "O")</p></li>
</ul>

<p>I'm asking because the options I know of have several drawbacks:</p>

<ul>
<li><p>triangulating the shape and sending it to OpenGL - does the most difficult work on CPU and might use too many/few triangles (i.e. wasteful/coarse)</p></li>
<li><p>texture atlas - has to recompute/upload the texture on every change (shape, scale, rotation, ...)</p></li>
<li><p>Signed distance field - on large scales the details don't look pretty or has to recompute/upload the texture</p></li>
<li><p>NV_path_rendering - could be it, if it was not working only on Nvidia's cards</p></li>
<li><p>OpenVG - could be it, if it was not working only on mobile</p></li>
<li><p>?</p></li>
</ul>

<hr>

<p>* It seems to me that OpenVG is not exactly moving forward, to put it mildly. Does anyone know anything about its future prospects? Is it worth at all to keep an eye on in the present day?</p>

<p>** OpenGL 4+ provides means of on-fly tessellation of polygons. Could it be somehow used to refine the the mesh from the "triangulating" option so that the shape boundary at least wont look "angled"?</p>

CC BY-SA 3.0
2015-08-27T02:19:42.313Z
You should also look into signed distance fields and signed distance textures.
Alan Wolfe
CC BY-SA 3.0
2015-08-27T16:20:06.833Z
Something to keep an eye on: https://twitter.com/sheredom/status/636572086211903488
Ecir Hana
CC BY-SA 3.0
2015-08-10T20:41:47.357Z
This GPU Gems article rasterizes quadratic curves by identifying parts of the hull that are curved and analytically computing the coverage in the pixel shader, might be worth a look: https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch25.html
yuriks
CC BY-SA 3.0
2015-08-10T22:12:03.490Z
@yuriks Yeah, Loop & Blinn, totally forgot about it. But isn't it patented?
Ecir Hana
CC BY-SA 3.0
2015-08-20T01:24:20.347Z
See also [Massively-Parallel Vector Graphics](http://w3.impa.br/~diego/projects/GanEtAl14/), published in SIGGRAPH Asia 2014.
lhf
CC BY-SA 3.0
2015-08-20T05:41:34.620Z
Between the options you've listed in your question and the Loop and Blinn paper, I think you've pretty much exhausted all the possibilities.
Nathan Reed
CC BY-SA 3.0
2015-08-20T13:28:20.537Z
You can tessellate a line, like described [here](http://www.gamedev.net/page/resources/_/technical/directx-and-xna/d3d11-tessellation-in-depth-r3059). Or you can triangulate in a compute shader.
nikitablack
<drawing><2d><bezier-curve>
Hardware-accelerated drawing of curved shapes
Ecir Hana
# Hardware-accelerated drawing of curved shapes

(Asked by: username_0 on 2015-08-10)

How to quickly draw a curved shape?

* by "quickly" I presume one should use hardware facilities as much as possible
* by "curved" I mean boundaries defined by either quadratic or cubic Bezier curves
* by "shape" I mean either a "fat" stroke (i.e. more than 1px wide) or even-odd/non-zero filled "2D curved polygon", possibly with holes (i.e. letter "O")

I'm asking because the options I know of have several drawbacks:

* triangulating the shape and sending it to OpenGL - does the most difficult work on CPU and might use too many/few triangles (i.e. wasteful/coarse)
* texture atlas - has to recompute/upload the texture on every change (shape, scale, rotation, ...)
* Signed distance field - on large scales the details don't look pretty or has to recompute/upload the texture
* NV\_path\_rendering - could be it, if it was not working only on Nvidia's cards
* OpenVG - could be it, if it was not working only on mobile
* ?

---

\* It seems to me that OpenVG is not exactly moving forward, to put it mildly. Does anyone know anything about its future prospects? Is it worth at all to keep an eye on in the present day?

\*\* OpenGL 4+ provides means of on-fly tessellation of polygons. Could it be somehow used to refine the the mesh from the "triangulating" option so that the shape boundary at least wont look "angled"?

**Tags:** drawing, 2d, bezier-curve

> **Comments:**
> **username_2**: This GPU Gems article rasterizes quadratic curves by identifying parts of the hull that are curved and analytically computing the coverage in the pixel shader, might be worth a look: https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch25.html  
> **username_0**: @username_2 Yeah, Loop & Blinn, totally forgot about it. But isn't it patented?  
> **username_3**: See also [Massively-Parallel Vector Graphics](http://w3.impa.br/~diego/projects/GanEtAl14/), published in SIGGRAPH Asia 2014.  
> **username_4**: Between the options you've listed in your question and the Loop and Blinn paper, I think you've pretty much exhausted all the possibilities.  
> **username_5**: You can tessellate a line, like described [here](http://www.gamedev.net/page/resources/_/technical/directx-and-xna/d3d11-tessellation-in-depth-r3059). Or you can triangulate in a compute shader.  
> **username_1**: You should also look into signed distance fields and signed distance textures.  
> **username_0**: Something to keep an eye on: https://twitter.com/sheredom/status/636572086211903488  

---

## 2 answers

### Answer by username_6 on 2015-11-12. Score: 2

You can use OpenGl 4.x tessellation shaders to convert Bezier control points into polygons.

A google search for "tessellation shader bezier" found this outline describing the tessellation of Bezier surfaces and curves:

<http://web.engr.oregonstate.edu/~mjb/cs519/Handouts/tessellation.1pp.pdf>

This offloads the Bezier evaluation from the CPU to the GPU and reduces the data flow across the bus.

> **Comments:**
> **username_4**: You could improve this answer by elaborating a bit, or even just linking to something that explains further.  
> **username_7**: One way of expanding this answer would be to address the drawbacks the author mentions, and explain how your approach helps with those.  

---

### Answer by username_8 on 2015-11-15. Score: 0

One can do curved drawing with hardware. There is a method described in **GPU Gems 3** that describes how to do this. User @username_2 actually comments this. I have actually made a quick a dirty demo for you to take a look at.

[![curve](https://i.sstatic.net/D9F9k.png)](https://i.sstatic.net/D9F9k.png)

**Image 1**: HW accelerated curve shapen (drawn usung a triangle) and [webgl source](http://webglplayground.net/saved/9ZD4Uoi72Q)


---

