Why is there no circle or ellipse primitive in OpenGL?

前端 未结 5 2254
执念已碎
执念已碎 2021-02-12 16:50

Circles are one of the basics geometric entities. Yet there is no primitives defined in OpenGL for this, like lines or polygons. Why so? It\'s a little annoying to include custo

相关标签:
5条回答
  • 2021-02-12 17:11

    While circles may be basic shapes they aren't as basic as points, lines or triangles when it comes to rasterisation. The first graphic cards with 3D acceleration were designed to do one thing very well, rasterise triangles (and lines and points because they were trivial to add). Adding any more complex shapes would have made the card a lot more expensive while adding only little functionality.

    But there's another reason for not including circles/ellipses. They don't connect. You can't build a 3D model out of them and you can't connect triangles to them without adding gaps or overlapping parts. So for circles to be useful you also need other shapes like curves and other more advanced surfaces (e.g. NURBS). Circles alone are only useful as "big points" which can also be done with a quad and a circle shaped texture, or triangles.

    If you are using "custom headers" for circles you should be aware that those probably create a triangle model that form your "circles".

    0 讨论(0)
  • 2021-02-12 17:13

    Because historically, video cards have rendered points, lines, and triangles.

    You calculate curves using short enough lines so the video card doesn't have to.

    0 讨论(0)
  • 2021-02-12 17:19

    Saying this depends on resolution

    0 讨论(0)
  • 2021-02-12 17:22

    Because graphic cards operate on 3-dimensional points, lines and triangles. A circle requires curves or splines. It cannot be perfectly represented by a "normal" 3D primitive, only approximated as an N-gon (so it will look like a circle at a certain distance). If you want a circle, write the routine yourself (it isn't hard to do). Either draw it as an N-gon, or make a square (2 triangles) and cut a circle out of it it using fragment shader (you can get a perfect circle this way).

    0 讨论(0)
  • 2021-02-12 17:33

    You could always use gluSphere (if a three-dimensional shape is what you're looking for).

    If you want to draw a two-dimensional circle you're stuck with custom methods. I'd go with a triangle fan.

    The primitives are called primitives for a reason :)

    0 讨论(0)
提交回复
热议问题