简体   繁体   English

如何在opengl中绘制2D平滑曲线

[英]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. 我搜索过在opengl中绘制样条曲线,我发现的解决方案使用了很多顶点来绘制它。 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? 在opengl中有没有正确的方法,或者它应该是软件渲染方式吗?

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 https://www.shadertoy.com/view/MlfSRN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM