Results 1 to 4 of 4

Thread: GLShadeMode

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    6

    GLShadeMode

    Iv been trying this:
    Code :
    if(key == 'p' || key == 'P')
    	{
    		wireframe = 1-wireframe;
    		if (wireframe) 
    		{
    			glShadeModel(GL_SMOOTH);
    		}
    		else
    		{	
    			glShadeModel(GL_FLAT);
    		}
    		glutPostRedisplay();
    	}

    But nothing seems to happens, what do i do?

    [wireframe = 1]

  2. #2
    Senior Member Regular Contributor
    Join Date
    Dec 2008
    Location
    USA
    Posts
    134

    Re: GLShadeMode

    glShadeModel controls how polygons are shaded. That is, whether they are shaded with a solid color or a different colors. For instance, if you specify a triangle with GL_FLAT, and one vertes is red, one green, and the last blue, the entire triangle will be blue. With GL_SMOOTH, the of a point on the triangle is blended between the threee based on its position.

    I think you're looking for glPolygonMode; see the man page.

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    6

    Re: GLShadeMode

    Well am looking to with the press of a button switch between:
    rendering in flat shaded polygonization
    or
    rendering in smooth shaded polygonization

    I dont know if glPolygonMode can do that?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Dec 2008
    Location
    USA
    Posts
    134

    Re: GLShadeMode

    If you want to swap the shading, then glShadeModel is what you want. I had thought that since you used the variable wireframe, you might want to display a wireframe instead of a solid.

    Are you using lighting? The spec (2.1) says that "A primitive may be flatshaded, meaning that all vertices of the primitive are assigned the same color index or the same primary and secondary colors."(section 2.14.7) It would seem that this does not stop lighting calculations from happening, so the resulting triangle could be smoothly shaded...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean