문제

In openGL, I've got an object that I scale by -1 along an axis... this results in the object not rendering properly because all the front faces are now back faces. Short of disabling culling, how would I get this object to render right? Is there a way to do it without modifying the textured normal vertices that make up my model?

도움이 되었습니까?

해결책

You can simply switch the culling mode. You can use glCullFace(mode) to decide which triangles should be culled. Supplying a parameter of GL_BACK means that only front-facing polygons are rendered, while a parameter of GL_FRONT means that only backfacing polygons are rendered. So if your transformation means that the "backfacing" polygons are in fact frontfacing, calling glCullFace(GL_FRONT) should do the trick.

As an alternative you can also control which polygons are considered front/backfacing using glFrontFace(dir), with a parameter of GL_CW (clockwise) or GL_CCW (counterclockwise) (default is counterclockwise so if you set it to clocksie originaly backfacing polygons would be considered frontfacing).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top