Reputation: 3081
In OpenGL, the default setup is:
+x->right, +y->up, +z->towards-viewer
.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...
Upvotes: 0
Views: 764
Reputation: 3081
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
Upvotes: 1
Reputation: 14678
Perhaps one has a front face clockwise and the other counter-clockwise. glFrontFace(GL_CW);
or glFrontFace(GL_CCW);
Upvotes: 0