Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: PolygonMode front and back fill

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2011
    Location
    seoul, south korea
    Posts
    15

    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
    regards
    mmax

  2. #2
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    302

    Re: PolygonMode front and back fill

    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.

  3. #3
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    381

    Re: PolygonMode front and back fill

    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:
    Code :
    glDisable(GL_CULL_FACE);
    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.

    Code :
    glEnable(GL_CULL_FACE);
     
    glCullFace(GL_FRONT);
    #set up rendering properties for back faces#
    DrawModel();
     
    glCullFace(GL_BACK);
    #set up rendering properties for front faces#
    DrawModel();

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2011
    Location
    seoul, south korea
    Posts
    15

    Re: PolygonMode front and back fill

    Thank you very much Dan.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •