Brain Dump

Drawing Methods

Tags
opengl

OpenGL has a few drawing functions which're useful for different purpose.

glDrawArrays

This draws the vertices from a vertex-array-object from some start vertex to some end vertex. You can specify how the arrays are drawn. see here.

glDrawArrays(
  GL_TRIANGLES, // How the vertices are to be drawn
  0,            // Which vertex to start drawing from
  3             // How many vertices to draw
);

Note: This approach required 3 vertices, ommitting or supplying an incomplete triangle skips it drawing for it.

glDrawElements

Is used to draw element-buffer-objects. see here.

glDrawElements(
  GL_TRIANGLES,    // How the vertices are to be drawn
  6,               // The number of elements to render from the EBO.
  GL_UNSIGNED_INT, // How the indices are stored in the EBO.
  0                // Offset in the EBO from which to read indices.
);