View Full Version : PolygonMode front and back fill
04-18-2012, 06:28 AM
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.
04-18-2012, 07:08 AM
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.
04-18-2012, 09:04 AM
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#
04-18-2012, 08:52 PM
Thank you very much Dan.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.