PolygonMode front and back fill

Hi folks, My question is on glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1.Is it possible to color on front and back faces of polygon triangle.
2.If yes how? give examples.

Advance thanks

I’m not quite sure what you mean.
With the given polygon mode, both, front and backfacing polygons will get rendered.
In GLSL you can check with gl_FrontFacing whether the fragment is from a front or backfacing polygon, so you can apply different materials this way.

If you’re talking about controlling whether triangles should be culled when they are facing away from the camera (according to whether triangle vertices appear clockwise on screen or anti-clockwise), you could use:


but the default value is disabled anyway. If you want to draw different colours on front + back, then you could use gl_FrontFacing in a shader as menzel said, or render twice with different values plugged into glCullFace.


#set up rendering properties for back faces#

#set up rendering properties for front faces#

Thank you very much Dan.