I'm not sure I understand how the triangle winding order works. I've been reading http://www.arcsynthesis.org/gltut/Positioning/Tutorial%2004.html but I don't quite understand how it works.

Specifically these lines, where the bolded I do not understand:

No matter what size or shape the triangle is, you can classify the ordering of a triangle in two ways: clockwise or counter-clockwise. That is, if the order of the vertices from 1 to 2 to 3 moves clockwise in a circle, relative to the triangle's center, then the triangle is

facing clockwise relative to the viewer. Otherwise, the triangle is counter-clockwise relative to the viewer.

For reference, I'm trying to make a cube using glDrawElements, and I want to know how I should order them and why. Below is a naive attempt:

const float vertexPositions[] = { // front vertices -0.5f, 0.5f, 0.0f, 0.5f, 0.5f, 0.0f, 0.5f, -0.5f, 0.0f, -0.5f, -0.5f, 0.0f, // back vertices -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f }; const GLshort indexData[] = { // back 4, 5, 6, 7, 4, 5, // right 1, 5, 6, 2, 1, 6, // left 4, 0, 3, 7, 4, 3, // top 4, 5, 1, 0, 4, 1, // bottom 7, 6, 2, 3, 7, 2, // front 0, 1, 2, 3, 0, 1 };