Two sided triangle?

Must one draw two triangles for it to have a different color on each side?
This must have to do with Culling?

For the fixed-function pipeline, you can have a different material on each side. The first parameter to glMaterial is the face to which the material applies: GL_FRONT, GL_BACK or GL_FRONT_AND_BACK. You need to enable GL_LIGHTING to have vertex colours calculated from the material, and you need glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,1) to enable separate front and back materials. Disabling all lights and setting GL_LIGHT_MODEL_AMBIENT to white will result in the polygon colour being equal to the ambient material colour. You can’t specify separate front and back colours directly using glColor. An alternative approach is to draw the geometry twice with front/back face culling enabled, using different colours or materials for the two passes.

When using shaders, the variable gl_FrontFacing is available in the fragment shader; this can be used to select different colours for front-facing and back-facing triangles.

1 Like