/**
* (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,
* 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
*/
/*
* fog.c
- * This program draws 5 red teapots, each at a different
- * z distance from the eye, in different types of fog.
- * Pressing the left mouse button chooses between 3 types of
- * fog: exponential, exponential squared, and linear.
- * In this program, there is a fixed density value, as well
+ * This program draws 5 red teapots, each at a different
+ * z distance from the eye, in different types of fog.
+ * Pressing the left mouse button chooses between 3 types of
+ * fog: exponential, exponential squared, and linear.
+ * In this program, there is a fixed density value, as well
* as fixed start and end values for the linear fog.
*/
#include <stdlib.h>
GLint fogMode;
-void
+void
selectFog(int mode)
{
switch(mode) {
/* falls through */
case GL_EXP2:
case GL_EXP:
- glFogi(GL_FOG_MODE, mode);
+ glFogi(GL_FOG_MODE, mode);
glutPostRedisplay();
break;
case 0:
}
}
-/* Initialize z-buffer, projection matrix, light source,
+/* Initialize z-buffer, projection matrix, light source,
* and lighting model. Do not specify a material property here.
*/
-void
+void
myinit(void)
{
GLfloat position[] =
}
}
-void
+void
renderRedTeapot(GLfloat x, GLfloat y, GLfloat z)
{
float mat[4];
/* display() draws 5 teapots at different z positions.
*/
-void
+void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glFlush();
}
-void
+void
myReshape(int w, int h)
{
glViewport(0, 0, w, 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);
glutAddMenuEntry("Fog LINEAR", GL_LINEAR);
glutAddMenuEntry("Quit", 0);
glutAttachMenu(GLUT_RIGHT_BUTTON);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}