Why should I create vertices counter-clockwise and not clockwise?

3.1k views Asked by At

I found that OpenGL ES 1.1 works both ways. Here is example for a quad:

GLfloat verts[] = {
    0, height,      // left bottom
    width, height,  // right bottom
    0, 0,           // left top
    width, 0        // right top
};

Other direction:

GLfloat verts[] = {
    0, height,
    0, 0,
    width, height,
    width, 0
};

rendered with glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

Some people say you should create the vertices in counter-clockwise order. Why?

1

There are 1 answers

4
datenwolf On

OpenGL (and it's relatives -ES, WebGL, etc.) have a feature called "face culling", where the winding direction determined if the front or the back of the face is visible. Using face culling you can omit the rendering of front or back faces.

By default OpenGL assumes counter clock wise (CCW) winding for front faces (in agreement with right handed normal vector calculation). That can be changed though.