Question

In OpenGL, the default setup is:

  1. Co-ordinate system = right handed, with +x->right, +y->up, +z->towards-viewer.
  2. Therefore, a postive rotation around z will move the x basis vector to y (anti-clockwise).
  3. Front-facing polygons are defined as CCW vertices.
  4. Culling of backface faces is achieved by:
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);

Ok, we all know this. In Flash 11/Molehill/Stage3d, the defaults are supposed to be the same.

However, if I enable backface culling in step 4 via:

c3d.setCulling(Context3DTriangleFace.BACK);

my faces are culled. It seems the default is Context3DTriangleFace.FRONT. I created a sanity-check case in OpenGL and Stage3D which are otherwise identical. Same vertex/index list, leave defaults, same orthographic projection matrix, identity ModelView, yet I have to set culling to FRONT not BACK.

It's as if Stage3D has a different winding default. i.e. it's as if, under the hood, OpengGL has been set to: glFrontFace(GL_CW); instead of OpenGLs default: glFrontFace(GL_CCW);

Has anyone else come across this? It's driving me nuts...

Was it helpful?

Solution 2

I meant to answer this ages ago, but forgot, so I'll just answer it now.

I was right, Stage3D considers front-facing to be a CW winding in screen-space, as opposed to OpenGL's CCW. I hope this helps anyone coming from OpenGL. Just reverse the order of your index buffer indices, or change the culling mode to FRONT. I decided to change the index order.

Cheers,

Shane

OTHER TIPS

Perhaps one has a front face clockwise and the other counter-clockwise. glFrontFace(GL_CW); or glFrontFace(GL_CCW);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top