summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Jump <[email protected]>1999-09-17 02:40:51 +0000
committerTed Jump <[email protected]>1999-09-17 02:40:51 +0000
commit83c02efa520eb2f8b3f5430be47bcd9c9749b30f (patch)
tree7e64e011d244460c4c7f3c6e177727249070c81e
parent74783e9936c59b8098f769061c6b216cad73edcf (diff)
Added ESC key handling
-rw-r--r--progs/demos/renormal.c17
-rw-r--r--progs/redbook/accanti.c48
-rw-r--r--progs/redbook/anti.c35
-rw-r--r--progs/redbook/bezmesh.c36
-rw-r--r--progs/redbook/checker.c36
-rw-r--r--progs/redbook/depthcue.c29
-rw-r--r--progs/redbook/dof.c91
-rw-r--r--progs/redbook/double.c40
-rw-r--r--progs/redbook/fog.c52
-rw-r--r--progs/redbook/fogindex.c44
-rw-r--r--progs/redbook/hello.c40
-rw-r--r--progs/redbook/material.c43
-rw-r--r--progs/redbook/mipmap.c33
-rw-r--r--progs/redbook/nurbs.c38
-rw-r--r--progs/redbook/pickdepth.c60
-rw-r--r--progs/redbook/plane.c38
-rw-r--r--progs/redbook/polyoff.c34
-rw-r--r--progs/redbook/polys.c34
-rw-r--r--progs/redbook/sccolorlight.c50
-rw-r--r--progs/redbook/scene.c46
-rw-r--r--progs/redbook/scenebamb.c46
-rw-r--r--progs/redbook/sceneflat.c44
-rw-r--r--progs/redbook/stencil.c38
-rw-r--r--progs/redbook/stroke.c44
-rw-r--r--progs/redbook/surface.c40
-rw-r--r--progs/redbook/teaambient.c34
-rw-r--r--progs/redbook/teapots.c14
-rw-r--r--progs/redbook/texbind.c33
-rw-r--r--progs/redbook/texsub.c26
-rw-r--r--progs/redbook/texturesurf.c50
30 files changed, 799 insertions, 414 deletions
diff --git a/progs/demos/renormal.c b/progs/demos/renormal.c
index bd099dcdc80..8a86ac7cff6 100644
--- a/progs/demos/renormal.c
+++ b/progs/demos/renormal.c
@@ -1,4 +1,4 @@
-/* $Id: renormal.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
+/* $Id: renormal.c,v 1.2 1999/09/17 02:40:51 tjump Exp $ */
/*
* Test GL_EXT_rescale_normal extension
@@ -6,7 +6,7 @@
*/
/*
- * $Id: renormal.c,v 1.1 1999/08/19 00:55:40 jtg Exp $
+ * $Id: renormal.c,v 1.2 1999/09/17 02:40:51 tjump Exp $
*/
@@ -95,6 +95,18 @@ static void ModeMenu(int entry)
glutPostRedisplay();
}
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
int main( int argc, char *argv[] )
{
@@ -110,6 +122,7 @@ int main( int argc, char *argv[] )
glutIdleFunc( Idle );
glutReshapeFunc( Reshape );
glutDisplayFunc( Display );
+ glutKeyboardFunc(key);
glutCreateMenu(ModeMenu);
glutAddMenuEntry("Unscaled", UNSCALED);
diff --git a/progs/redbook/accanti.c b/progs/redbook/accanti.c
index d45cf9e64e3..12ca16f7a52 100644
--- a/progs/redbook/accanti.c
+++ b/progs/redbook/accanti.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
@@ -57,7 +57,7 @@ void myinit(void)
glMaterialf(GL_FRONT, GL_SHININESS, 50.0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lm_ambient);
-
+
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDepthFunc(GL_LESS);
@@ -68,25 +68,25 @@ void myinit(void)
glClearAccum(0.0, 0.0, 0.0, 0.0);
}
-void displayObjects(void)
+void displayObjects(void)
{
GLfloat torus_diffuse[] = { 0.7, 0.7, 0.0, 1.0 };
GLfloat cube_diffuse[] = { 0.0, 0.7, 0.7, 1.0 };
GLfloat sphere_diffuse[] = { 0.7, 0.0, 0.7, 1.0 };
GLfloat octa_diffuse[] = { 0.7, 0.4, 0.4, 1.0 };
-
+
glPushMatrix ();
glRotatef (30.0, 1.0, 0.0, 0.0);
glPushMatrix ();
- glTranslatef (-0.80, 0.35, 0.0);
+ glTranslatef (-0.80, 0.35, 0.0);
glRotatef (100.0, 1.0, 0.0, 0.0);
glMaterialfv(GL_FRONT, GL_DIFFUSE, torus_diffuse);
glutSolidTorus (0.275, 0.85, 16, 16);
glPopMatrix ();
glPushMatrix ();
- glTranslatef (-0.75, -0.50, 0.0);
+ glTranslatef (-0.75, -0.50, 0.0);
glRotatef (45.0, 0.0, 0.0, 1.0);
glRotatef (45.0, 1.0, 0.0, 0.0);
glMaterialfv(GL_FRONT, GL_DIFFUSE, cube_diffuse);
@@ -94,14 +94,14 @@ void displayObjects(void)
glPopMatrix ();
glPushMatrix ();
- glTranslatef (0.75, 0.60, 0.0);
+ glTranslatef (0.75, 0.60, 0.0);
glRotatef (30.0, 1.0, 0.0, 0.0);
glMaterialfv(GL_FRONT, GL_DIFFUSE, sphere_diffuse);
glutSolidSphere (1.0, 16, 16);
glPopMatrix ();
glPushMatrix ();
- glTranslatef (0.70, -0.90, 0.25);
+ glTranslatef (0.70, -0.90, 0.25);
glMaterialfv(GL_FRONT, GL_DIFFUSE, octa_diffuse);
glutSolidOctahedron ();
glPopMatrix ();
@@ -124,7 +124,7 @@ void display(void)
glPushMatrix ();
/* Note that 4.5 is the distance in world space between
* left and right and bottom and top.
- * This formula converts fractional pixel movement to
+ * This formula converts fractional pixel movement to
* world coordinates.
*/
glTranslatef (j8[jitter].x*4.5/viewport[2],
@@ -142,15 +142,28 @@ void myReshape(int w, int h)
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- if (w <= h)
+ if (w <= h)
glOrtho (-2.25, 2.25, -2.25*h/w, 2.25*h/w, -10.0, 10.0);
- else
+ else
glOrtho (-2.25*w/h, 2.25*w/h, -2.25, 2.25, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
}
+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, and handle input events.
*/
int main(int argc, char** argv)
@@ -163,6 +176,7 @@ int main(int argc, char** argv)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/anti.c b/progs/redbook/anti.c
index 12aa5f8a215..9eab0bc3511 100644
--- a/progs/redbook/anti.c
+++ b/progs/redbook/anti.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
@@ -45,8 +45,8 @@
#include <stdio.h>
#include <GL/glut.h>
-/* Initialize antialiasing for RGBA mode, including alpha
- * blending, hint, and line width. Print out implementation
+/* Initialize antialiasing for RGBA mode, including alpha
+ * blending, hint, and line width. Print out implementation
* specific info on line width granularity and width.
*/
void myinit(void)
@@ -56,7 +56,7 @@ void myinit(void)
printf ("GL_LINE_WIDTH_GRANULARITY value is %3.1f\n", values[0]);
glGetFloatv (GL_LINE_WIDTH_RANGE, values);
- printf ("GL_LINE_WIDTH_RANGE values are %3.1f %3.1f\n",
+ printf ("GL_LINE_WIDTH_RANGE values are %3.1f %3.1f\n",
values[0], values[1]);
glEnable (GL_LINE_SMOOTH);
@@ -93,8 +93,21 @@ void myReshape(int w, int h)
glTranslatef (0.0, 0.0, -4.0); /* move object into view */
}
+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, and handle input events.
*/
int main(int argc, char** argv)
@@ -105,7 +118,7 @@ int main(int argc, char** argv)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
-
diff --git a/progs/redbook/bezmesh.c b/progs/redbook/bezmesh.c
index eb7f0f7a845..55e7e827f2b 100644
--- a/progs/redbook/bezmesh.c
+++ b/progs/redbook/bezmesh.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
@@ -68,7 +68,7 @@ GLfloat ctrlpoints[4][4][3] =
{1.5, 1.5, -1.0}}
};
-void
+void
initlights(void)
{
GLfloat ambient[] =
@@ -93,7 +93,7 @@ initlights(void)
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
}
-void
+void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -104,7 +104,7 @@ display(void)
glFlush();
}
-void
+void
myinit(void)
{
glClearColor(0.0, 0.0, 0.0, 1.0);
@@ -118,7 +118,7 @@ myinit(void)
initlights(); /* for lighted version only */
}
-void
+void
myReshape(int w, int h)
{
glViewport(0, 0, w, h);
@@ -134,7 +134,20 @@ myReshape(int w, int h)
glLoadIdentity();
}
-int
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
+int
main(int argc, char **argv)
{
glutInit(&argc, argv);
@@ -143,6 +156,7 @@ main(int argc, char **argv)
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/checker.c b/progs/redbook/checker.c
index 34853b0c6ee..4b7695237fc 100644
--- a/progs/redbook/checker.c
+++ b/progs/redbook/checker.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
@@ -52,10 +52,10 @@ GLubyte checkImage[checkImageWidth][checkImageHeight][3];
void makeCheckImage(void)
{
int i, j, c;
-
+
for (i = 0; i < checkImageWidth; i++) {
for (j = 0; j < checkImageHeight; j++) {
- c = ((((i&0x8)==0)^((j&0x8))==0))*255;
+ c = ((((i&0x8)==0)^((j&0x8)==0)))*255;
checkImage[i][j][0] = (GLubyte) c;
checkImage[i][j][1] = (GLubyte) c;
checkImage[i][j][2] = (GLubyte) c;
@@ -64,15 +64,15 @@ void makeCheckImage(void)
}
void myinit(void)
-{
+{
glClearColor (0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
makeCheckImage();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexImage2D(GL_TEXTURE_2D, 0, 3, checkImageWidth,
- checkImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, checkImageWidth,
+ checkImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,
&checkImage[0][0][0]);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
@@ -111,6 +111,19 @@ void myReshape(int w, int h)
glTranslatef(0.0, 0.0, -3.6);
}
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
int
main(int argc, char** argv)
{
@@ -120,6 +133,7 @@ main(int argc, char** argv)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/depthcue.c b/progs/redbook/depthcue.c
index 41af19cf96e..a3e5b743aa7 100644
--- a/progs/redbook/depthcue.c
+++ b/progs/redbook/depthcue.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,7 +39,7 @@
*/
/*
* depthcue.c
- * This program draws a wireframe model, which uses
+ * This program draws a wireframe model, which uses
* intensity (brightness) to give clues to distance.
* Fog is used to achieve this effect.
*/
@@ -86,6 +86,19 @@ void myReshape(int w, int h)
glTranslatef (0.0, 0.0, -4.0); /* move object into view */
}
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
/* Main Loop
*/
int main(int argc, char** argv)
@@ -96,7 +109,7 @@ int main(int argc, char** argv)
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
-
diff --git a/progs/redbook/dof.c b/progs/redbook/dof.c
index 166ca9e62f8..6673dc2d54f 100644
--- a/progs/redbook/dof.c
+++ b/progs/redbook/dof.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
@@ -55,35 +55,35 @@
/* accFrustum()
* The first 6 arguments are identical to the glFrustum() call.
- *
- * pixdx and pixdy are anti-alias jitter in pixels.
+ *
+ * pixdx and pixdy are anti-alias jitter in pixels.
* Set both equal to 0.0 for no anti-alias jitter.
- * eyedx and eyedy are depth-of field jitter in pixels.
+ * eyedx and eyedy are depth-of field jitter in pixels.
* Set both equal to 0.0 for no depth of field effects.
*
- * focus is distance from eye to plane in focus.
+ * focus is distance from eye to plane in focus.
* focus must be greater than, but not equal to 0.0.
*
- * Note that accFrustum() calls glTranslatef(). You will
- * probably want to insure that your ModelView matrix has been
+ * Note that accFrustum() calls glTranslatef(). You will
+ * probably want to insure that your ModelView matrix has been
* initialized to identity before calling accFrustum().
*/
-void accFrustum(GLdouble left, GLdouble right, GLdouble bottom,
- GLdouble top, GLdouble nnear, GLdouble ffar, GLdouble pixdx,
+void accFrustum(GLdouble left, GLdouble right, GLdouble bottom,
+ GLdouble top, GLdouble nnear, GLdouble ffar, GLdouble pixdx,
GLdouble pixdy, GLdouble eyedx, GLdouble eyedy, GLdouble focus)
{
- GLdouble xwsize, ywsize;
+ GLdouble xwsize, ywsize;
GLdouble dx, dy;
GLint viewport[4];
glGetIntegerv (GL_VIEWPORT, viewport);
-
+
xwsize = right - left;
ywsize = top - bottom;
-
+
dx = -(pixdx*xwsize/(GLdouble) viewport[2] + eyedx*nnear/focus);
dy = -(pixdy*ywsize/(GLdouble) viewport[3] + eyedy*nnear/focus);
-
+
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum (left + dx, right + dx, bottom + dy, top + dy, nnear, ffar);
@@ -93,20 +93,20 @@ void accFrustum(GLdouble left, GLdouble right, GLdouble bottom,
}
/* accPerspective()
- *
+ *
* The first 4 arguments are identical to the gluPerspective() call.
- * pixdx and pixdy are anti-alias jitter in pixels.
+ * pixdx and pixdy are anti-alias jitter in pixels.
* Set both equal to 0.0 for no anti-alias jitter.
- * eyedx and eyedy are depth-of field jitter in pixels.
+ * eyedx and eyedy are depth-of field jitter in pixels.
* Set both equal to 0.0 for no depth of field effects.
*
- * focus is distance from eye to plane in focus.
+ * focus is distance from eye to plane in focus.
* focus must be greater than, but not equal to 0.0.
*
* Note that accPerspective() calls accFrustum().
*/
-void accPerspective(GLdouble fovy, GLdouble aspect,
- GLdouble nnear, GLdouble ffar, GLdouble pixdx, GLdouble pixdy,
+void accPerspective(GLdouble fovy, GLdouble aspect,
+ GLdouble nnear, GLdouble ffar, GLdouble pixdx, GLdouble pixdy,
GLdouble eyedx, GLdouble eyedy, GLdouble focus)
{
GLdouble fov2,left,right,bottom,top;
@@ -128,7 +128,7 @@ void myinit(void)
GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat position[] = { 0.0, 3.0, 3.0, 0.0 };
-
+
GLfloat lmodel_ambient[] = { 0.2, 0.2, 0.2, 1.0 };
GLfloat local_view[] = { 0.0 };
@@ -138,7 +138,7 @@ void myinit(void)
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, position);
-
+
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view);
@@ -155,18 +155,18 @@ void myinit(void)
glClearAccum(0.0, 0.0, 0.0, 0.0);
}
-void renderTeapot (GLfloat x, GLfloat y, GLfloat z,
- GLfloat ambr, GLfloat ambg, GLfloat ambb,
- GLfloat difr, GLfloat difg, GLfloat difb,
+void renderTeapot (GLfloat x, GLfloat y, GLfloat z,
+ GLfloat ambr, GLfloat ambg, GLfloat ambb,
+ GLfloat difr, GLfloat difg, GLfloat difb,
GLfloat specr, GLfloat specg, GLfloat specb, GLfloat shine)
{
float mat[4];
glPushMatrix();
glTranslatef (x, y, z);
- mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0;
+ mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0;
glMaterialfv (GL_FRONT, GL_AMBIENT, mat);
- mat[0] = difr; mat[1] = difg; mat[2] = difb;
+ mat[0] = difr; mat[1] = difg; mat[2] = difb;
glMaterialfv (GL_FRONT, GL_DIFFUSE, mat);
mat[0] = specr; mat[1] = specg; mat[2] = specb;
glMaterialfv (GL_FRONT, GL_SPECULAR, mat);
@@ -175,9 +175,9 @@ void renderTeapot (GLfloat x, GLfloat y, GLfloat z,
glPopMatrix();
}
-/* display() draws 5 teapots into the accumulation buffer
+/* display() draws 5 teapots into the accumulation buffer
* several times; each time with a jittered perspective.
- * The focal point is at z = 5.0, so the gold teapot will
+ * The focal point is at z = 5.0, so the gold teapot will
* stay in focus. The amount of jitter is adjusted by the
* magnitude of the accPerspective() jitter; in this example, 0.33.
* In this example, the teapots are drawn 8 times. See jitter.h
@@ -192,8 +192,8 @@ void display(void)
for (jitter = 0; jitter < 8; jitter++) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- accPerspective (45.0,
- (GLdouble) viewport[2]/(GLdouble) viewport[3],
+ accPerspective (45.0,
+ (GLdouble) viewport[2]/(GLdouble) viewport[3],
1.0, 15.0, 0.0, 0.0,
0.33*j8[jitter].x, 0.33*j8[jitter].y, 5.0);
/* ruby, gold, silver, emerald, and cyan teapots */
@@ -203,9 +203,9 @@ void display(void)
0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4);
renderTeapot (0.2, -0.5, -5.5, 0.19225, 0.19225, 0.19225,
0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4);
- renderTeapot (1.0, -0.5, -6.0, 0.0215, 0.1745, 0.0215,
+ renderTeapot (1.0, -0.5, -6.0, 0.0215, 0.1745, 0.0215,
0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6);
- renderTeapot (1.8, -0.5, -6.5, 0.0, 0.1, 0.06, 0.0, 0.50980392,
+ renderTeapot (1.8, -0.5, -6.5, 0.0, 0.1, 0.06, 0.0, 0.50980392,
0.50980392, 0.50196078, 0.50196078, 0.50196078, .25);
glAccum (GL_ACCUM, 0.125);
}
@@ -219,8 +219,21 @@ void myReshape(int w, int h)
glViewport(0, 0, w, h);
}
+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 main(int argc, char** argv)
@@ -232,7 +245,7 @@ int main(int argc, char** argv)
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
-
diff --git a/progs/redbook/double.c b/progs/redbook/double.c
index 65dfd4b2a3e..a41229d12fc 100644
--- a/progs/redbook/double.c
+++ b/progs/redbook/double.c
@@ -1,13 +1,13 @@
/*
* Copyright (c) 1993-1997, 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,
@@ -21,8 +21,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
@@ -66,7 +66,7 @@ void spinDisplay(void)
glutPostRedisplay();
}
-void init(void)
+void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
@@ -83,7 +83,7 @@ void reshape(int w, int h)
}
/* ARGSUSED2 */
-void mouse(int button, int state, int x, int y)
+void mouse(int button, int state, int x, int y)
{
switch (button) {
case GLUT_LEFT_BUTTON:
@@ -98,8 +98,21 @@ void mouse(int button, int state, int x, int y)
break;
}
}
-
-/*
+
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
+/*
* Request double buffer display mode.
* Register mouse input callback functions
*/
@@ -107,13 +120,14 @@ int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize (250, 250);
+ glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
- glutDisplayFunc(display);
- glutReshapeFunc(reshape);
+ glutDisplayFunc(display);
+ glutReshapeFunc(reshape);
glutMouseFunc(mouse);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/fog.c b/progs/redbook/fog.c
index 5f8a4e4e764..888ee138a49 100644
--- a/progs/redbook/fog.c
+++ b/progs/redbook/fog.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,11 +39,11 @@
*/
/*
* 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>
@@ -52,7 +52,7 @@
GLint fogMode;
-void
+void
selectFog(int mode)
{
switch(mode) {
@@ -70,10 +70,10 @@ selectFog(int mode)
}
}
-/* 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[] =
@@ -106,7 +106,7 @@ myinit(void)
}
}
-void
+void
renderRedTeapot(GLfloat x, GLfloat y, GLfloat z)
{
float mat[4];
@@ -133,7 +133,7 @@ renderRedTeapot(GLfloat x, GLfloat y, GLfloat z)
/* display() draws 5 teapots at different z positions.
*/
-void
+void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -145,7 +145,7 @@ display(void)
glFlush();
}
-void
+void
myReshape(int w, int h)
{
glViewport(0, 0, w, h);
@@ -161,11 +161,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);
@@ -181,6 +194,7 @@ main(int argc, char **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. */
}
diff --git a/progs/redbook/fogindex.c b/progs/redbook/fogindex.c
index b409c95ac91..b8bb691e288 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. */
}
diff --git a/progs/redbook/hello.c b/progs/redbook/hello.c
index 516c9ecc002..4f644a46a80 100644
--- a/progs/redbook/hello.c
+++ b/progs/redbook/hello.c
@@ -1,13 +1,13 @@
/*
* Copyright (c) 1993-1997, 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,
@@ -21,8 +21,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
@@ -47,7 +47,7 @@ void display(void)
glClear (GL_COLOR_BUFFER_BIT);
/* draw white polygon (rectangle) with corners at
- * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
+ * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/
glColor3f (1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
@@ -57,13 +57,13 @@ void display(void)
glVertex3f (0.25, 0.75, 0.0);
glEnd();
-/* don't wait!
- * start processing buffered OpenGL routines
+/* don't wait!
+ * start processing buffered OpenGL routines
*/
glFlush ();
}
-void init (void)
+void init (void)
{
/* select clearing color */
glClearColor (0.0, 0.0, 0.0, 0.0);
@@ -74,7 +74,20 @@ void init (void)
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
-/*
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
+/*
* Declare initial window size, position, and display mode
* (single buffer and RGBA). Open window with "hello"
* in its title bar. Call initialization routines.
@@ -85,11 +98,12 @@ int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize (250, 250);
+ glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
- glutDisplayFunc(display);
+ glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/material.c b/progs/redbook/material.c
index f8d6a918f47..f9a4fc59288 100644
--- a/progs/redbook/material.c
+++ b/progs/redbook/material.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
@@ -46,7 +46,7 @@
#include <stdlib.h>
#include <GL/glut.h>
-/* 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 myinit(void)
@@ -72,7 +72,7 @@ void myinit(void)
glClearColor(0.0, 0.1, 0.1, 0.0);
}
-/* Draw twelve spheres in 3 rows with 4 columns.
+/* Draw twelve spheres in 3 rows with 4 columns.
* The spheres in the first row have materials with no ambient reflection.
* The second row has materials with significant ambient reflection.
* The third row has materials with colored ambient reflection.
@@ -102,7 +102,7 @@ void display(void)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* draw sphere in first row, first column
- * diffuse reflection only; no ambient or specular
+ * diffuse reflection only; no ambient or specular
*/
glPushMatrix();
glTranslatef (-3.75, 3.0, 0.0);
@@ -154,7 +154,7 @@ void display(void)
glPopMatrix();
/* draw sphere in second row, first column
- * ambient and diffuse reflection; no specular
+ * ambient and diffuse reflection; no specular
*/
glPushMatrix();
glTranslatef (-3.75, 0.0, 0.0);
@@ -206,7 +206,7 @@ void display(void)
glPopMatrix();
/* draw sphere in third row, first column
- * colored ambient and diffuse reflection; no specular
+ * colored ambient and diffuse reflection; no specular
*/
glPushMatrix();
glTranslatef (-3.75, -3.0, 0.0);
@@ -266,16 +266,29 @@ void myReshape(int w, int h)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= (h * 2))
- glOrtho (-6.0, 6.0, -3.0*((GLfloat)h*2)/(GLfloat)w,
+ glOrtho (-6.0, 6.0, -3.0*((GLfloat)h*2)/(GLfloat)w,
3.0*((GLfloat)h*2)/(GLfloat)w, -10.0, 10.0);
else
- glOrtho (-6.0*(GLfloat)w/((GLfloat)h*2),
+ glOrtho (-6.0*(GLfloat)w/((GLfloat)h*2),
6.0*(GLfloat)w/((GLfloat)h*2), -3.0, 3.0, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
}
+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, and handle input events.
*/
int main(int argc, char** argv)
@@ -287,7 +300,7 @@ int main(int argc, char** argv)
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
-
diff --git a/progs/redbook/mipmap.c b/progs/redbook/mipmap.c
index 96ef394f60e..d32dd725f4b 100644
--- a/progs/redbook/mipmap.c
+++ b/progs/redbook/mipmap.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
@@ -57,7 +57,7 @@ GLubyte mipmapImage1[1][1][3];
void makeImages(void)
{
int i, j;
-
+
for (i = 0; i < 32; i++) {
for (j = 0; j < 32; j++) {
mipmapImage32[i][j][0] = 255;
@@ -99,7 +99,7 @@ void makeImages(void)
}
void myinit(void)
-{
+{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glShadeModel(GL_FLAT);
@@ -122,7 +122,7 @@ void myinit(void)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST_MIPMAP_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glEnable(GL_TEXTURE_2D);
@@ -150,6 +150,19 @@ void 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();
+}
+
int main(int argc, char** argv)
{
glutInit(&argc, argv);
@@ -159,7 +172,7 @@ int main(int argc, char** argv)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
-
diff --git a/progs/redbook/nurbs.c b/progs/redbook/nurbs.c
index 513868e7d17..a7c6f0c696e 100644
--- a/progs/redbook/nurbs.c
+++ b/progs/redbook/nurbs.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
@@ -46,10 +46,10 @@
#include <GL/glut.h>
#define S_NUMPOINTS 13
-#define S_ORDER 3
+#define S_ORDER 3
#define S_NUMKNOTS (S_NUMPOINTS + S_ORDER)
#define T_NUMPOINTS 3
-#define T_ORDER 3
+#define T_ORDER 3
#define T_NUMKNOTS (T_NUMPOINTS + T_ORDER)
#define SQRT2 1.41421356237309504880
@@ -86,7 +86,7 @@ GLfloat ctlpoints[S_NUMPOINTS][T_NUMPOINTS][4] = {
GLUnurbsObj *theNurb;
-/* Initialize material property, light source, lighting model,
+/* Initialize material property, light source, lighting model,
* and depth buffer.
*/
void myinit(void)
@@ -133,12 +133,12 @@ void display(void)
glTranslatef (-4., -4.5, -2.5);
gluBeginSurface(theNurb);
- gluNurbsSurface(theNurb,
+ gluNurbsSurface(theNurb,
S_NUMKNOTS, sknots,
T_NUMKNOTS, tknots,
4 * T_NUMPOINTS,
4,
- &ctlpoints[0][0][0],
+ &ctlpoints[0][0][0],
S_ORDER, T_ORDER,
GL_MAP2_VERTEX_4);
gluEndSurface(theNurb);
@@ -159,8 +159,21 @@ void myReshape(int w, int h)
gluLookAt(7.0,4.5,4.0, 4.5,4.5,2.0, 6.0,-3.0,2.0);
}
+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, and handle input events.
*/
int main(int argc, char** argv)
@@ -171,6 +184,7 @@ int main(int argc, char** argv)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/pickdepth.c b/progs/redbook/pickdepth.c
index c6d50a91d96..4b95d245ceb 100644
--- a/progs/redbook/pickdepth.c
+++ b/progs/redbook/pickdepth.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,19 +39,19 @@
*/
/*
* pickdepth.c
- * Picking is demonstrated in this program. In
- * rendering mode, three overlapping rectangles are
- * drawn. When the left mouse button is pressed,
- * selection mode is entered with the picking matrix.
+ * Picking is demonstrated in this program. In
+ * rendering mode, three overlapping rectangles are
+ * drawn. When the left mouse button is pressed,
+ * selection mode is entered with the picking matrix.
* Rectangles which are drawn under the cursor position
- * are "picked." Pay special attention to the depth
+ * are "picked." Pay special attention to the depth
* value range, which is returned.
*/
#include <stdlib.h>
#include <stdio.h>
#include <GL/glut.h>
-void
+void
myinit(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
@@ -61,11 +61,11 @@ myinit(void)
glDepthRange(0.0, 1.0); /* The default z mapping */
}
-/* The three rectangles are drawn. In selection mode,
- * each rectangle is given the same name. Note that
+/* The three rectangles are drawn. In selection mode,
+ * each rectangle is given the same name. Note that
* each rectangle is drawn with a different z value.
*/
-void
+void
drawRects(GLenum mode)
{
if (mode == GL_SELECT)
@@ -97,10 +97,10 @@ drawRects(GLenum mode)
glEnd();
}
-/* processHits() prints out the contents of the
+/* processHits() prints out the contents of the
* selection array.
*/
-void
+void
processHits(GLint hits, GLuint buffer[])
{
unsigned int i, j;
@@ -125,13 +125,13 @@ processHits(GLint hits, GLuint buffer[])
}
}
-/* pickRects() sets up selection mode, name stack,
- * and projection matrix for picking. Then the objects
+/* pickRects() sets up selection mode, name stack,
+ * and projection matrix for picking. Then the objects
* are drawn.
*/
#define BUFSIZE 512
-void
+void
pickRects(int button, int state, int x, int y)
{
GLuint selectBuf[BUFSIZE];
@@ -164,7 +164,7 @@ pickRects(int button, int state, int x, int y)
processHits(hits, selectBuf);
}
-void
+void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -172,7 +172,7 @@ display(void)
glutSwapBuffers();
}
-void
+void
myReshape(int w, int h)
{
glViewport(0, 0, w, h);
@@ -183,8 +183,21 @@ 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
@@ -198,6 +211,7 @@ main(int argc, char **argv)
glutMouseFunc(pickRects);
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/plane.c b/progs/redbook/plane.c
index 2b0cca06faf..dc17f7b2386 100644
--- a/progs/redbook/plane.c
+++ b/progs/redbook/plane.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,7 +39,7 @@
*/
/*
* plane.c
- * This program demonstrates the use of local versus
+ * This program demonstrates the use of local versus
* infinite lighting on a flat plane.
*/
#include <stdlib.h>
@@ -130,17 +130,30 @@ void myReshape(int w, int h)
glViewport (0, 0, w, h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
- if (w <= h)
- glOrtho (-1.5, 1.5, -1.5*(GLdouble)h/(GLdouble)w,
+ if (w <= h)
+ glOrtho (-1.5, 1.5, -1.5*(GLdouble)h/(GLdouble)w,
1.5*(GLdouble)h/(GLdouble)w, -10.0, 10.0);
- else
- glOrtho (-1.5*(GLdouble)w/(GLdouble)h,
+ else
+ glOrtho (-1.5*(GLdouble)w/(GLdouble)h,
1.5*(GLdouble)w/(GLdouble)h, -1.5, 1.5, -10.0, 10.0);
glMatrixMode (GL_MODELVIEW);
}
+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, and handle input events.
*/
int main(int argc, char** argv)
@@ -152,6 +165,7 @@ int main(int argc, char** argv)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/polyoff.c b/progs/redbook/polyoff.c
index 42887c9e0c8..280eb165ecb 100644
--- a/progs/redbook/polyoff.c
+++ b/progs/redbook/polyoff.c
@@ -1,13 +1,13 @@
/*
* Copyright (c) 1993-1997, 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,
@@ -21,8 +21,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
@@ -89,7 +89,7 @@ void display (void)
}
/* specify initial properties
- * create display list with sphere
+ * create display list with sphere
* initialize lighting and depth buffer
*/
void gfxinit (void)
@@ -137,7 +137,7 @@ void mouse(int button, int state, int x, int y) {
case GLUT_LEFT_BUTTON:
switch (state) {
case GLUT_DOWN:
- spinx = (spinx + 5) % 360;
+ spinx = (spinx + 5) % 360;
glutPostRedisplay();
break;
default:
@@ -147,7 +147,7 @@ void mouse(int button, int state, int x, int y) {
case GLUT_MIDDLE_BUTTON:
switch (state) {
case GLUT_DOWN:
- spiny = (spiny + 5) % 360;
+ spiny = (spiny + 5) % 360;
glutPostRedisplay();
break;
default:
@@ -209,8 +209,21 @@ void keyboard (unsigned char key, int x, int y)
}
}
+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, and handle input events.
*/
int main(int argc, char** argv)
@@ -223,6 +236,7 @@ int main(int argc, char** argv)
glutMouseFunc(mouse);
glutKeyboardFunc(keyboard);
gfxinit();
+ glutKeyboardFunc(key);
glutMainLoop();
return 0;
}
diff --git a/progs/redbook/polys.c b/progs/redbook/polys.c
index 2983bc5cc3d..17c1cfbff2b 100644
--- a/progs/redbook/polys.c
+++ b/progs/redbook/polys.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
@@ -76,7 +76,7 @@ void display(void)
/* draw all polygons in white */
glColor3f (1.0, 1.0, 1.0);
-/* draw one solid, unstippled rectangle, */
+/* draw one solid, unstippled rectangle, */
/* then two stippled rectangles */
glRectf (25.0, 25.0, 125.0, 125.0);
glEnable (GL_POLYGON_STIPPLE);
@@ -89,11 +89,11 @@ void display(void)
glFlush ();
}
-void myinit (void)
+void myinit (void)
{
/* clear background to black */
glClearColor (0.0, 0.0, 0.0, 0.0);
- glShadeModel (GL_FLAT);
+ glShadeModel (GL_FLAT);
}
static void reshape(GLsizei w, GLsizei h)
@@ -106,8 +106,21 @@ static void reshape(GLsizei w, GLsizei 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, and handle input events.
*/
int main(int argc, char** argv)
@@ -119,6 +132,7 @@ int main(int argc, char** argv)
myinit ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/sccolorlight.c b/progs/redbook/sccolorlight.c
index 191f2660437..0ea750e5846 100644
--- a/progs/redbook/sccolorlight.c
+++ b/progs/redbook/sccolorlight.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,9 +39,9 @@
*/
/*
* sccolorlight.c
- * This program demonstrates the use of a colored
- * (magenta, in this example) light source. Objects
- * are drawn using a grey material characteristic.
+ * This program demonstrates the use of a colored
+ * (magenta, in this example) light source. Objects
+ * are drawn using a grey material characteristic.
* A single light source illuminates the objects.
*/
#include <stdlib.h>
@@ -61,7 +61,7 @@ void myinit(void)
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
-
+
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDepthFunc(GL_LESS);
@@ -75,19 +75,19 @@ void display(void)
glRotatef (20.0, 1.0, 0.0, 0.0);
glPushMatrix ();
- glTranslatef (-0.75, 0.5, 0.0);
+ glTranslatef (-0.75, 0.5, 0.0);
glRotatef (90.0, 1.0, 0.0, 0.0);
glutSolidTorus (0.275, 0.85, 20, 20);
glPopMatrix ();
glPushMatrix ();
- glTranslatef (-0.75, -0.5, 0.0);
+ glTranslatef (-0.75, -0.5, 0.0);
glRotatef (270.0, 1.0, 0.0, 0.0);
glutSolidCone (1.0, 2.0, 20, 20);
glPopMatrix ();
glPushMatrix ();
- glTranslatef (0.75, 0.0, -1.0);
+ glTranslatef (0.75, 0.0, -1.0);
glutSolidSphere (1.0, 20, 20);
glPopMatrix ();
@@ -100,17 +100,30 @@ void myReshape(int w, int h)
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- if (w <= h)
- glOrtho (-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w,
+ if (w <= h)
+ glOrtho (-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w,
2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0);
- else
- glOrtho (-2.5*(GLfloat)w/(GLfloat)h,
+ else
+ glOrtho (-2.5*(GLfloat)w/(GLfloat)h,
2.5*(GLfloat)w/(GLfloat)h, -2.5, 2.5, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
}
+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, and handle input events.
*/
int main(int argc, char** argv)
@@ -122,6 +135,7 @@ int main(int argc, char** argv)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/scene.c b/progs/redbook/scene.c
index 428e8bd7a18..c3abc727b78 100644
--- a/progs/redbook/scene.c
+++ b/progs/redbook/scene.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
@@ -40,7 +40,7 @@
/*
* scene.c
* This program demonstrates the use of the GL lighting model.
- * Objects are drawn using a grey material characteristic.
+ * Objects are drawn using a grey material characteristic.
* A single light source illuminates the objects.
*/
#include <stdlib.h>
@@ -60,7 +60,7 @@ void myinit (void)
glLightfv (GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv (GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv (GL_LIGHT0, GL_POSITION, light_position);
-
+
glEnable (GL_LIGHTING);
glEnable (GL_LIGHT0);
glDepthFunc(GL_LESS);
@@ -75,19 +75,19 @@ void display (void)
glRotatef (20.0, 1.0, 0.0, 0.0);
glPushMatrix ();
- glTranslatef (-0.75, 0.5, 0.0);
+ glTranslatef (-0.75, 0.5, 0.0);
glRotatef (90.0, 1.0, 0.0, 0.0);
glutSolidTorus (0.275, 0.85, 15, 15);
glPopMatrix ();
glPushMatrix ();
- glTranslatef (-0.75, -0.5, 0.0);
+ glTranslatef (-0.75, -0.5, 0.0);
glRotatef (270.0, 1.0, 0.0, 0.0);
glutSolidCone (1.0, 2.0, 15, 15);
glPopMatrix ();
glPushMatrix ();
- glTranslatef (0.75, 0.0, -1.0);
+ glTranslatef (0.75, 0.0, -1.0);
glutSolidSphere (1.0, 15, 15);
glPopMatrix ();
@@ -100,17 +100,30 @@ void myReshape(int w, int h)
glViewport (0, 0, w, h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
- if (w <= h)
- glOrtho (-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w,
+ if (w <= h)
+ glOrtho (-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w,
2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0);
- else
- glOrtho (-2.5*(GLfloat)w/(GLfloat)h,
+ else
+ glOrtho (-2.5*(GLfloat)w/(GLfloat)h,
2.5*(GLfloat)w/(GLfloat)h, -2.5, 2.5, -10.0, 10.0);
glMatrixMode (GL_MODELVIEW);
}
+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, and handle input events.
*/
int main(int argc, char** argv)
@@ -122,6 +135,7 @@ int main(int argc, char** argv)
myinit ();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/scenebamb.c b/progs/redbook/scenebamb.c
index a3449b58096..e7264d2003f 100644
--- a/progs/redbook/scenebamb.c
+++ b/progs/redbook/scenebamb.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,7 +39,7 @@
*/
/*
* scenebamb.c
- * This program demonstrates use of a blue ambient light
+ * This program demonstrates use of a blue ambient light
* source.
*/
#include <stdlib.h>
@@ -59,7 +59,7 @@ void myinit(void)
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
-
+
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDepthFunc(GL_LESS);
@@ -74,19 +74,19 @@ void display(void)
glRotatef (20.0, 1.0, 0.0, 0.0);
glPushMatrix ();
- glTranslatef (-0.75, 0.5, 0.0);
+ glTranslatef (-0.75, 0.5, 0.0);
glRotatef (90.0, 1.0, 0.0, 0.0);
glutSolidTorus (0.275, 0.85, 15, 15);
glPopMatrix ();
glPushMatrix ();
- glTranslatef (-0.75, -0.5, 0.0);
+ glTranslatef (-0.75, -0.5, 0.0);
glRotatef (270.0, 1.0, 0.0, 0.0);
glutSolidCone (1.0, 2.0, 15, 15);
glPopMatrix ();
glPushMatrix ();
- glTranslatef (0.75, 0.0, -1.0);
+ glTranslatef (0.75, 0.0, -1.0);
glutSolidSphere (1.0, 15, 15);
glPopMatrix ();
@@ -99,17 +99,30 @@ void myReshape(int w, int h)
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- if (w <= h)
- glOrtho (-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w,
+ if (w <= h)
+ glOrtho (-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w,
2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0);
- else
- glOrtho (-2.5*(GLfloat)w/(GLfloat)h,
+ else
+ glOrtho (-2.5*(GLfloat)w/(GLfloat)h,
2.5*(GLfloat)w/(GLfloat)h, -2.5, 2.5, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
}
+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, and handle input events.
*/
int main(int argc, char** argv)
@@ -121,6 +134,7 @@ int main(int argc, char** argv)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/sceneflat.c b/progs/redbook/sceneflat.c
index 5ab2037e4c6..10891fb9977 100644
--- a/progs/redbook/sceneflat.c
+++ b/progs/redbook/sceneflat.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
@@ -58,7 +58,7 @@ void myinit(void)
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
-
+
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDepthFunc(GL_LESS);
@@ -74,19 +74,19 @@ void display(void)
glRotatef (20.0, 1.0, 0.0, 0.0);
glPushMatrix ();
- glTranslatef (-0.75, 0.5, 0.0);
+ glTranslatef (-0.75, 0.5, 0.0);
glRotatef (90.0, 1.0, 0.0, 0.0);
glutSolidTorus (0.275, 0.85, 15, 15);
glPopMatrix ();
glPushMatrix ();
- glTranslatef (-0.75, -0.5, 0.0);
+ glTranslatef (-0.75, -0.5, 0.0);
glRotatef (270.0, 1.0, 0.0, 0.0);
glutSolidCone (1.0, 2.0, 15, 15);
glPopMatrix ();
glPushMatrix ();
- glTranslatef (0.75, 0.0, -1.0);
+ glTranslatef (0.75, 0.0, -1.0);
glutSolidSphere (1.0, 15, 15);
glPopMatrix ();
@@ -99,17 +99,30 @@ void myReshape(int w, int h)
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- if (w <= h)
- glOrtho (-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w,
+ if (w <= h)
+ glOrtho (-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w,
2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0);
- else
- glOrtho (-2.5*(GLfloat)w/(GLfloat)h,
+ else
+ glOrtho (-2.5*(GLfloat)w/(GLfloat)h,
2.5*(GLfloat)w/(GLfloat)h, -2.5, 2.5, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
}
+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, and handle input events.
*/
int main(int argc, char** argv)
@@ -121,6 +134,7 @@ int main(int argc, char** argv)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/stencil.c b/progs/redbook/stencil.c
index 958cf85c8ea..5626d55be6b 100644
--- a/progs/redbook/stencil.c
+++ b/progs/redbook/stencil.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
@@ -38,9 +38,9 @@
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
/* stencil.c
- * This program draws two rotated tori in a window.
- * A diamond in the center of the window masks out part
- * of the scene. Within this mask, a different model
+ * This program draws two rotated tori in a window.
+ * A diamond in the center of the window masks out part
+ * of the scene. Within this mask, a different model
* (a sphere) is drawn in a different color.
*/
#include <stdlib.h>
@@ -49,7 +49,7 @@
#define YELLOWMAT 1
#define BLUEMAT 2
-void myinit (void)
+void myinit (void)
{
GLfloat yellow_diffuse[] = { 0.7, 0.7, 0.0, 1.0 };
GLfloat yellow_specular[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -112,7 +112,7 @@ void display(void)
glFlush();
}
-/* Whenever the window is reshaped, redefine the
+/* Whenever the window is reshaped, redefine the
* coordinate system and redraw the stencil area.
*/
void myReshape(int w, int h)
@@ -144,8 +144,21 @@ void myReshape(int w, int h)
glTranslatef(0.0, 0.0, -5.0);
}
+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, and handle input events.
*/
int main(int argc, char** argv)
@@ -157,6 +170,7 @@ int main(int argc, char** argv)
myinit ();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/stroke.c b/progs/redbook/stroke.c
index d8c75c89fec..19b0391cbae 100644
--- a/progs/redbook/stroke.c
+++ b/progs/redbook/stroke.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
@@ -38,10 +38,10 @@
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
/*
- * stroke.c
- * This program demonstrates some characters of a
+ * stroke.c
+ * This program demonstrates some characters of a
* stroke (vector) font. The characters are represented
- * by display lists, which are given numbers which
+ * by display lists, which are given numbers which
* correspond to the ASCII values of the characters.
* Use of glCallLists() is demonstrated.
*/
@@ -59,7 +59,7 @@ typedef struct charpoint {
} CP;
CP Adata[] = {
- { 0, 0, PT}, {0, 9, PT}, {1, 10, PT}, {4, 10, PT},
+ { 0, 0, PT}, {0, 9, PT}, {1, 10, PT}, {4, 10, PT},
{5, 9, PT}, {5, 0, STROKE}, {0, 5, PT}, {5, 5, END}
};
@@ -69,18 +69,18 @@ CP Edata[] = {
};
CP Pdata[] = {
- {0, 0, PT}, {0, 10, PT}, {4, 10, PT}, {5, 9, PT}, {5, 6, PT},
+ {0, 0, PT}, {0, 10, PT}, {4, 10, PT}, {5, 9, PT}, {5, 6, PT},
{4, 5, PT}, {0, 5, END}
};
CP Rdata[] = {
- {0, 0, PT}, {0, 10, PT}, {4, 10, PT}, {5, 9, PT}, {5, 6, PT},
+ {0, 0, PT}, {0, 10, PT}, {4, 10, PT}, {5, 9, PT}, {5, 6, PT},
{4, 5, PT}, {0, 5, STROKE}, {3, 5, PT}, {5, 0, END}
};
CP Sdata[] = {
- {0, 1, PT}, {1, 0, PT}, {4, 0, PT}, {5, 1, PT}, {5, 4, PT},
- {4, 5, PT}, {1, 5, PT}, {0, 6, PT}, {0, 9, PT}, {1, 10, PT},
+ {0, 1, PT}, {1, 0, PT}, {4, 0, PT}, {5, 1, PT}, {5, 4, PT},
+ {4, 5, PT}, {1, 5, PT}, {0, 6, PT}, {0, 9, PT}, {1, 10, PT},
{4, 10, PT}, {5, 9, END}
};
@@ -163,8 +163,21 @@ static void reshape(GLsizei w, GLsizei 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, and handle input events.
*/
int main(int argc, char** argv)
@@ -176,6 +189,7 @@ int main(int argc, char** argv)
myinit ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/surface.c b/progs/redbook/surface.c
index fb2691eb7c5..8ff15741889 100644
--- a/progs/redbook/surface.c
+++ b/progs/redbook/surface.c
@@ -2,14 +2,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,
@@ -23,8 +23,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
@@ -38,7 +38,7 @@
*/
/**
* surface.c
- * This program draws a NURBS surface in the shape of a
+ * This program draws a NURBS surface in the shape of a
* symmetrical hill.
*/
#include <GL/glut.h>
@@ -65,9 +65,9 @@ void init_surface(void)
else
ctlpoints[u][v][2] = -3.0;
}
- }
-}
-
+ }
+}
+
/* Initialize material property and depth buffer.
*/
void myinit(void)
@@ -111,12 +111,12 @@ void display(void)
glScalef (0.25, 0.25, 0.25);
gluBeginSurface(theNurb);
- gluNurbsSurface(theNurb,
+ gluNurbsSurface(theNurb,
8, knots,
8, knots,
4 * 3,
3,
- &ctlpoints[0][0][0],
+ &ctlpoints[0][0][0],
4, 4,
GL_MAP2_VERTEX_3);
gluEndSurface(theNurb);
@@ -134,7 +134,7 @@ void display(void)
glEnd();
glEnable(GL_LIGHTING);
}
-
+
glPopMatrix();
glutSwapBuffers();
}
@@ -194,6 +194,19 @@ mouse(int button, int state, int x, int y)
}
}
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
/* Main Loop */
int
main(int argc, char** argv)
@@ -212,6 +225,7 @@ main(int argc, char** argv)
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutMouseFunc(mouse);
glutMotionFunc(motion);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/teaambient.c b/progs/redbook/teaambient.c
index 62c091c70a6..53b5111752f 100644
--- a/progs/redbook/teaambient.c
+++ b/progs/redbook/teaambient.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
@@ -47,7 +47,7 @@
/* Initialize light source and lighting model.
*/
-void
+void
myinit(void)
{
GLfloat light_ambient[] =
@@ -78,7 +78,7 @@ myinit(void)
glEnable(GL_DEPTH_TEST);
}
-void
+void
display(void)
{
GLfloat low_ambient[] =
@@ -114,7 +114,7 @@ display(void)
glFlush();
}
-void
+void
myReshape(int w, int h)
{
glViewport(0, 0, w, h);
@@ -129,8 +129,21 @@ myReshape(int w, int h)
glMatrixMode(GL_MODELVIEW);
}
+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, and handle input events.
*/
int
@@ -143,6 +156,7 @@ main(int argc, char **argv)
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/teapots.c b/progs/redbook/teapots.c
index 2431cae7350..edca5441ece 100644
--- a/progs/redbook/teapots.c
+++ b/progs/redbook/teapots.c
@@ -188,6 +188,19 @@ myReshape(int w, int h)
glMatrixMode(GL_MODELVIEW);
}
+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, RGBA display
* mode, and handle input events.
@@ -201,6 +214,7 @@ main(int argc, char **argv)
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
diff --git a/progs/redbook/texbind.c b/progs/redbook/texbind.c
index 92c226fbdb4..6a828ab2bdf 100644
--- a/progs/redbook/texbind.c
+++ b/progs/redbook/texbind.c
@@ -1,13 +1,13 @@
/*
* Copyright (c) 1993-1997, 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,
@@ -21,8 +21,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
@@ -36,7 +36,7 @@
*/
/* texbind.c
- * This program demonstrates using glBindTexture() by
+ * This program demonstrates using glBindTexture() by
* creating and managing two textures.
*/
#include <GL/glut.h>
@@ -55,15 +55,15 @@ static GLuint texName[2];
void makeCheckImages(void)
{
int i, j, c;
-
+
for (i = 0; i < checkImageHeight; i++) {
for (j = 0; j < checkImageWidth; j++) {
- c = ((((i&0x8)==0)^((j&0x8))==0))*255;
+ c = ((((i&0x8)==0)^((j&0x8)==0)))*255;
checkImage[i][j][0] = (GLubyte) c;
checkImage[i][j][1] = (GLubyte) c;
checkImage[i][j][2] = (GLubyte) c;
checkImage[i][j][3] = (GLubyte) 255;
- c = ((((i&0x10)==0)^((j&0x10))==0))*255;
+ c = ((((i&0x10)==0)^((j&0x10)==0)))*255;
otherImage[i][j][0] = (GLubyte) c;
otherImage[i][j][1] = (GLubyte) 0;
otherImage[i][j][2] = (GLubyte) 0;
@@ -73,7 +73,7 @@ void makeCheckImages(void)
}
void init(void)
-{
+{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);
@@ -85,9 +85,9 @@ void init(void)
glBindTexture(GL_TEXTURE_2D, texName[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth,
checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
@@ -99,8 +99,8 @@ void init(void)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth,
- checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth,
+ checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
otherImage);
glEnable(GL_TEXTURE_2D);
}
@@ -158,7 +158,7 @@ int main(int argc, char** argv)
glutDisplayFunc(display);
glutKeyboardFunc (keyboard);
glutMainLoop();
- return 0;
+ return 0;
}
#else
int main(int argc, char** argv)
@@ -169,4 +169,3 @@ int main(int argc, char** argv)
return 0;
}
#endif
-
diff --git a/progs/redbook/texsub.c b/progs/redbook/texsub.c
index 5dc36ec4e7c..4e829675aba 100644
--- a/progs/redbook/texsub.c
+++ b/progs/redbook/texsub.c
@@ -1,13 +1,13 @@
/*
* Copyright (c) 1993-1997, 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,
@@ -21,8 +21,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
@@ -40,7 +40,7 @@
* two rectangles. This program clamps the texture, if
* the texture coordinates fall outside 0.0 and 1.0.
* If the s key is pressed, a texture subimage is used to
- * alter the original texture. If the r key is pressed,
+ * alter the original texture. If the r key is pressed,
* the original texture is restored.
*/
#include <GL/glut.h>
@@ -61,10 +61,10 @@ static GLuint texName;
void makeCheckImages(void)
{
int i, j, c;
-
+
for (i = 0; i < checkImageHeight; i++) {
for (j = 0; j < checkImageWidth; j++) {
- c = ((((i&0x8)==0)^((j&0x8))==0))*255;
+ c = ((((i&0x8)==0)^((j&0x8)==0)))*255;
checkImage[i][j][0] = (GLubyte) c;
checkImage[i][j][1] = (GLubyte) c;
checkImage[i][j][2] = (GLubyte) c;
@@ -73,7 +73,7 @@ void makeCheckImages(void)
}
for (i = 0; i < subImageHeight; i++) {
for (j = 0; j < subImageWidth; j++) {
- c = ((((i&0x4)==0)^((j&0x4))==0))*255;
+ c = ((((i&0x4)==0)^((j&0x4)==0)))*255;
subImage[i][j][0] = (GLubyte) c;
subImage[i][j][1] = (GLubyte) 0;
subImage[i][j][2] = (GLubyte) 0;
@@ -83,7 +83,7 @@ void makeCheckImages(void)
}
void init(void)
-{
+{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);
@@ -98,7 +98,7 @@ void init(void)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight,
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight,
0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage);
}
@@ -174,7 +174,7 @@ int main(int argc, char** argv)
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
- return 0;
+ return 0;
}
#else
int main(int argc, char** argv)
diff --git a/progs/redbook/texturesurf.c b/progs/redbook/texturesurf.c
index 89cdbcc6526..0170070eaa5 100644
--- a/progs/redbook/texturesurf.c
+++ b/progs/redbook/texturesurf.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
@@ -47,17 +47,17 @@
#include <math.h>
GLfloat ctrlpoints[4][4][3] = {
- {{ -1.5, -1.5, 4.0}, { -0.5, -1.5, 2.0},
- {0.5, -1.5, -1.0}, {1.5, -1.5, 2.0}},
- {{ -1.5, -0.5, 1.0}, { -0.5, -0.5, 3.0},
- {0.5, -0.5, 0.0}, {1.5, -0.5, -1.0}},
- {{ -1.5, 0.5, 4.0}, { -0.5, 0.5, 0.0},
- {0.5, 0.5, 3.0}, {1.5, 0.5, 4.0}},
- {{ -1.5, 1.5, -2.0}, { -0.5, 1.5, -2.0},
+ {{ -1.5, -1.5, 4.0}, { -0.5, -1.5, 2.0},
+ {0.5, -1.5, -1.0}, {1.5, -1.5, 2.0}},
+ {{ -1.5, -0.5, 1.0}, { -0.5, -0.5, 3.0},
+ {0.5, -0.5, 0.0}, {1.5, -0.5, -1.0}},
+ {{ -1.5, 0.5, 4.0}, { -0.5, 0.5, 0.0},
+ {0.5, 0.5, 3.0}, {1.5, 0.5, 4.0}},
+ {{ -1.5, 1.5, -2.0}, { -0.5, 1.5, -2.0},
{0.5, 1.5, 0.0}, {1.5, 1.5, -1.0}}
};
-GLfloat texpts[2][2][2] = {{{0.0, 0.0}, {0.0, 1.0}},
+GLfloat texpts[2][2][2] = {{{0.0, 0.0}, {0.0, 1.0}},
{{1.0, 0.0}, {1.0, 1.0}}};
void display(void)
@@ -76,7 +76,7 @@ void makeImage(void)
{
int i, j;
float ti, tj;
-
+
for (i = 0; i < imageWidth; i++) {
ti = 2.0*3.14159265*i/imageWidth;
for (j = 0; j < imageHeight; j++) {
@@ -93,7 +93,7 @@ void myinit(void)
{
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4,
0, 1, 12, 4, &ctrlpoints[0][0][0]);
- glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2,
+ glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2,
0, 1, 4, 2, &texpts[0][0][0]);
glEnable(GL_MAP2_TEXTURE_COORD_2);
glEnable(GL_MAP2_VERTEX_3);
@@ -118,16 +118,29 @@ void myReshape(int w, int h)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
- glOrtho(-4.0, 4.0, -4.0*(GLfloat)h/(GLfloat)w,
+ glOrtho(-4.0, 4.0, -4.0*(GLfloat)h/(GLfloat)w,
4.0*(GLfloat)h/(GLfloat)w, -4.0, 4.0);
else
- glOrtho(-4.0*(GLfloat)w/(GLfloat)h,
+ glOrtho(-4.0*(GLfloat)w/(GLfloat)h,
4.0*(GLfloat)w/(GLfloat)h, -4.0, 4.0, -4.0, 4.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(85.0, 1.0, 1.0, 1.0);
}
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
int main(int argc, char** argv)
{
glutInit(&argc, argv);
@@ -136,6 +149,7 @@ int main(int argc, char** argv)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}