OpenGL appreciated three ways GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN drawing a triangle and other sequences


Function glDrawArrays ()

glDrawArrays(type, startIndex, count);Drawing a triangle
of which type is divided into:

  • GL_TRIANGLE
    This understanding is the simplest. Each drawing is a three vertices of a triangle. But this will be relatively large vertex array length.
  • GL_TRIANGLE_STRIP
  • GL_TRIANGLE_FAN

GL_TRIANGLE_STRIP

strip: strip, the strip means
to select it when drawing pattern extending in one direction.

N-number of set top set; the first three vertices constituting the first triangle counterclockwise.
Thereafter, the n vertices,

  • When n is an even number:
    (. 1-n, n-2, n) as n is 4, represents the four vertices, is to use a third time, the second and fourth vertices constituting a triangle counterclockwise
  • When n is odd:
    (n-2,. 1-n, n)

GL_TRIANGLE_FAN

fan: sector
select it in drawing fan circular.

The initial vertex needs to be the center of the sector, the first three vertices of a first triangle constituting counterclockwise.
From the third starting vertex satisfied, that is, (n, circle, n-1)


The initial vertex

In OpenGL, we need to draw counter-clockwise. Therefore, in the second type GL_TRIANGLE_STRIP, the vertex direction of the front three generally like this:

  • First and second vertex, from top to bottom; the second and third vertices from left to right.
    On the contrary it is also true, i.e., the first and second vertex, from the bottom up; the second and third vertex from right to left.
  • First and second vertex, left to right; the second and third vertex, from the bottom up.
    Also, conversely, the first and second vertex, from right to left; downwardly from the second and third vertex.

Published 400 original articles · won praise 364 · Views 1.62 million +

Guess you like

Origin blog.csdn.net/jjwwmlp456/article/details/94740685