summaryrefslogtreecommitdiff
path: root/progs/redbook/fogindex.c
diff options
context:
space:
mode:
Diffstat (limited to 'progs/redbook/fogindex.c')
-rw-r--r--progs/redbook/fogindex.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/progs/redbook/fogindex.c b/progs/redbook/fogindex.c
index b409c95ac9..b8bb691e28 100644
--- a/progs/redbook/fogindex.c
+++ b/progs/redbook/fogindex.c
@@ -3,14 +3,14 @@
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
@@ -24,8 +24,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
@@ -39,21 +39,21 @@
*/
/*
* fogindex.c
- * This program demonstrates fog in color index mode.
- * Three cones are drawn at different z values in a linear
- * fog. 32 contiguous colors (from 16 to 47) are loaded
+ * This program demonstrates fog in color index mode.
+ * Three cones are drawn at different z values in a linear
+ * fog. 32 contiguous colors (from 16 to 47) are loaded
* with a color ramp.
*/
#include <stdlib.h>
#include <GL/glut.h>
-/* Initialize color map and fog. Set screen clear color
+/* Initialize color map and fog. Set screen clear color
* to end of color ramp.
*/
#define NUM_COLORS 32
#define RAMPSTART 16
-void
+void
myinit(void)
{
int i;
@@ -77,7 +77,7 @@ myinit(void)
/* display() renders 3 cones at different z positions.
*/
-void
+void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -104,7 +104,7 @@ display(void)
glFlush();
}
-void
+void
myReshape(int w, int h)
{
glViewport(0, 0, w, h);
@@ -120,11 +120,24 @@ myReshape(int w, int h)
glLoadIdentity();
}
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
/* Main Loop
- * Open window with initial window size, title bar,
+ * Open window with initial window size, title bar,
* RGBA display mode, depth buffer, and handle input events.
*/
-int
+int
main(int argc, char **argv)
{
glutInit(&argc, argv);
@@ -133,6 +146,7 @@ main(int argc, char **argv)
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}