Search code examples
openglcurve

How to draw 2D smooth curve in opengl


I've searched about drawing splines in opengl, and the solutions I found use many vertices to draw it. Obviously, they are broken when scaled.

How can I draw smooth curve independent of scaling, like vector graphics? Is there any proper way to do it in opengl, or should it be software-rendering way?


Solution

  • You render a quad and pass the spline as uniforms. You will need to use a shader program. Your vertex shader will transform the quad and generate any extra information from your uniforms and and your fragment shader will test if the pixel is on the line.

    https://www.shadertoy.com/view/MlfSRN