How many vertices does a triangle fan use opengl

后端 未结 4 911
轮回少年
轮回少年 2021-01-03 01:44

I am learning openGL, and i have come across triangle fans using vertex buffer objects. If given an array of vertices to render, how does openGL decide how many of those ve

4条回答
  •  生来不讨喜
    2021-01-03 02:35

    Visually, this is how a triangle fan works:

    Each triangle shares the central vertex A, and re-uses the last vertex addressed. Thus after defining ABC each following triangle only requires 1 point (e.g. D, E, F).

    Indices:     A,B,C,D,E,F     [Count: 6]
    Triangles:  (A,B,C)
                (A) (C,D)
                (A)   (D,E)
                (A)     (E,F)    [N=4]  -->  4+2 = 6
    

    Another way of thinking about this is that each triangle shares an edge radiating from a central vertex with the prior triangle; literally like a folding a paper fan.

          Paper fan

    You need N+2 vertices, where N is the number of triangles in your fan.

提交回复
热议问题