projects
/
freeglut
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
shapes demo: added flat shading option (fixed-function only)
[freeglut]
/
progs
/
demos
/
shapes
/
shapes.c
diff --git
a/progs/demos/shapes/shapes.c
b/progs/demos/shapes/shapes.c
index
69c0a1a
..
09fb5ef
100644
(file)
--- 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 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
/*
* 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)");
shapesPrintf (row++, 1, "Perspective projection (p)");
else
shapesPrintf (row++, 1, "Orthographic projection (p)");
- if (useShader)
+ if (useShader) {
shapesPrintf (row++, 1, "Using shader (s)");
shapesPrintf (row++, 1, "Using shader (s)");
- else
+ } else {
shapesPrintf (row++, 1, "Using fixed function pipeline (s)");
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
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? */
glutSetOption(GLUT_GEOMETRY_VISUALIZE_NORMALS,visNormals); /* Normals visualized or not? */
+ glShadeModel(flat ? GL_FLAT : GL_SMOOTH); /* flat or gouraud shading */
+
if (useShader && !shaderReady)
initShader();
if (useShader && !shaderReady)
initShader();
@@
-820,6
+828,11
@@
key(unsigned char key, int x, int y)
function_index = 0;
break;
function_index = 0;
break;
+ case 'F':
+ case 'f':
+ flat ^= 1;
+ break;
+
case 'N':
case 'n': visNormals=!visNormals; break;
case 'N':
case 'n': visNormals=!visNormals; break;