Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including
Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Computer Graphics Stack Exchange is a question and answer site for computer graphics researchers and programmers. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
7 years, 9 months ago
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"?
Aug 10, 2015 at 10:05
Ecir Hana Ecir Hana
1,459 11 11 silver badges 20 20 bronze badges
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:
This offloads the Bezier evaluation from the CPU to the GPU and reduces the data flow across the bus.
Nov 12, 2015 at 17:01
121 4 4 bronze badges
One can do curved drawing with hardware. There is a method described in
GPU Gems 3 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.
Image 1: HW accelerated curve shapen (drawn usung a triangle) and webgl source
Nov 15, 2015 at 12:12
8,317 1 1 gold badge 22 22 silver badges 46 46 bronze badges
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our
Accept all cookies
Necessary cookies only