From: John Tsiombikas Date: Wed, 29 Sep 2021 13:09:31 +0000 (+0000) Subject: shapes demo: added flat shading option (fixed-function only) X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=freeglut;a=commitdiff_plain;h=073805e06f3693e135f62ac0f999e2e31caa02f5 shapes demo: added flat shading option (fixed-function only) git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1866 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/progs/demos/shapes/shapes.c b/progs/demos/shapes/shapes.c index 69c0a1a..09fb5ef 100644 --- a/progs/demos/shapes/shapes.c +++ b/progs/demos/shapes/shapes.c @@ -425,6 +425,7 @@ static GLboolean persProject = GL_TRUE; static GLboolean animateXRot = GL_FALSE; static GLboolean useShader = GL_FALSE; static GLboolean visNormals = GL_FALSE; +static GLboolean flat; /* * Enum to tell drawSizeInfo what to draw for each object @@ -653,10 +654,15 @@ static void drawInfo() shapesPrintf (row++, 1, "Perspective projection (p)"); else shapesPrintf (row++, 1, "Orthographic projection (p)"); - if (useShader) + if (useShader) { shapesPrintf (row++, 1, "Using shader (s)"); - else + } else { shapesPrintf (row++, 1, "Using fixed function pipeline (s)"); + if (flat) + shapesPrintf (row++, 1, "Flat shading (f)"); + else + shapesPrintf (row++, 1, "Smooth shading (f)"); + } if (animateXRot) shapesPrintf (row++, 1, "2D rotation (r)"); else @@ -683,6 +689,8 @@ static void display(void) glutSetOption(GLUT_GEOMETRY_VISUALIZE_NORMALS,visNormals); /* Normals visualized or not? */ + glShadeModel(flat ? GL_FLAT : GL_SMOOTH); /* flat or gouraud shading */ + if (useShader && !shaderReady) initShader(); @@ -820,6 +828,11 @@ key(unsigned char key, int x, int y) function_index = 0; break; + case 'F': + case 'f': + flat ^= 1; + break; + case 'N': case 'n': visNormals=!visNormals; break;