1

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?

genpfault
  • 51,148
  • 11
  • 85
  • 139
openfrog
  • 40,201
  • 65
  • 225
  • 373
  • Probably the only reason is if one has to calculate the windings/normals _manually_, then a right handed person can use his left hand as a guide. (Pun accidental) – Aki Suihkonen Dec 09 '13 at 18:15

1 Answers1

1

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.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • `gl.frontFace(gl.CW);` or `gl.frontFace(gl.CCW);` – Gavin Simpson Feb 13 '15 at 15:39
  • @GavinSimpson: Only in Python using PyOpenGL. In the OpenGL specs it's just `FrontFace(CW)` and `CCW` and in C code everything is prefixed with `gl…` and `GL_…` – datenwolf Feb 13 '15 at 17:38
  • I needed this cos in the app I wrote a few years back it exports into gl_cw. It was just easier to switch winding here than in an entire c++ app. The code I posted here works great in webgl, but with the lack of decent documentation I'm struggling a bit to find the 'easy' stuff, so just though I'd post it.... until I find a decent book or link that is. – Gavin Simpson Feb 13 '15 at 17:53
  • 1
    @GavinSimpson: Also WebGL then. Well, the important part here is, that the API bindings for different languages use different ways of namespacing the OpenGL functions. In C/C++ this is done by prefixing the symbols. In Python and Javascript/WebGL everything is placed in a object. The name of the instance in WebGL (`gl.`) in your case actually is freely choosen by the name of the variable to which the GL context manufacured by the Canvas object is assigned. – datenwolf Feb 13 '15 at 19:13