-/* $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
*/
/*
- * $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 $
*/
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[] )
{
glutIdleFunc( Idle );
glutReshapeFunc( Reshape );
glutDisplayFunc( Display );
+ glutKeyboardFunc(key);
glutCreateMenu(ModeMenu);
glutAddMenuEntry("Unscaled", UNSCALED);
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
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);
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);
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 ();
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],
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)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
#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)
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);
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)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
-
/**
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
{1.5, 1.5, -1.0}}
};
-void
+void
initlights(void)
{
GLfloat ambient[] =
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
}
-void
+void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glFlush();
}
-void
+void
myinit(void)
{
glClearColor(0.0, 0.0, 0.0, 1.0);
initlights(); /* for lighted version only */
}
-void
+void
myReshape(int w, int h)
{
glViewport(0, 0, w, 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);
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
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;
}
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);
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)
{
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
*/
/*
* 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.
*/
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)
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
-
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
/* 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);
}
/* 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;
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 };
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);
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);
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
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 */
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);
}
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)
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
-
/*
* 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,
* 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
glutPostRedisplay();
}
-void init(void)
+void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
}
/* 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:
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
*/
{
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. */
}
/**
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
*/
/*
* fog.c
- * This program draws 5 red teapots, each at a different
- * z distance from the eye, in different types of fog.
- * Pressing the left mouse button chooses between 3 types of
- * fog: exponential, exponential squared, and linear.
- * In this program, there is a fixed density value, as well
+ * This program draws 5 red teapots, each at a different
+ * z distance from the eye, in different types of fog.
+ * Pressing the left mouse button chooses between 3 types of
+ * fog: exponential, exponential squared, and linear.
+ * In this program, there is a fixed density value, as well
* as fixed start and end values for the linear fog.
*/
#include <stdlib.h>
GLint fogMode;
-void
+void
selectFog(int mode)
{
switch(mode) {
}
}
-/* Initialize z-buffer, projection matrix, light source,
+/* Initialize z-buffer, projection matrix, light source,
* and lighting model. Do not specify a material property here.
*/
-void
+void
myinit(void)
{
GLfloat position[] =
}
}
-void
+void
renderRedTeapot(GLfloat x, GLfloat y, GLfloat z)
{
float mat[4];
/* display() draws 5 teapots at different z positions.
*/
-void
+void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glFlush();
}
-void
+void
myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glLoadIdentity();
}
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
/* Main Loop
- * Open window with initial window size, title bar,
+ * Open window with initial window size, title bar,
* RGBA display mode, depth buffer, and handle input events.
*/
-int
+int
main(int argc, char **argv)
{
glutInit(&argc, argv);
glutAddMenuEntry("Fog LINEAR", GL_LINEAR);
glutAddMenuEntry("Quit", 0);
glutAttachMenu(GLUT_RIGHT_BUTTON);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
*/
/*
* 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;
/* display() renders 3 cones at different z positions.
*/
-void
+void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glFlush();
}
-void
+void
myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glLoadIdentity();
}
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
/* Main Loop
- * Open window with initial window size, title bar,
+ * Open window with initial window size, title bar,
* RGBA display mode, depth buffer, and handle input events.
*/
-int
+int
main(int argc, char **argv)
{
glutInit(&argc, argv);
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* 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,
* 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
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);
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);
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.
{
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. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
#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)
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.
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);
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);
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);
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)
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
-
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
void makeImages(void)
{
int i, j;
-
+
for (i = 0; i < 32; i++) {
for (j = 0; j < 32; j++) {
mipmapImage32[i][j][0] = 255;
}
void myinit(void)
-{
+{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glShadeModel(GL_FLAT);
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);
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);
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
-
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
#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
GLUnurbsObj *theNurb;
-/* Initialize material property, light source, lighting model,
+/* Initialize material property, light source, lighting model,
* and depth buffer.
*/
void myinit(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);
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)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
*/
/*
* 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);
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)
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;
}
}
-/* 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];
processHits(hits, selectBuf);
}
-void
+void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
-void
+void
myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glLoadIdentity();
}
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
/* Main Loop
- * Open window with initial window size, title bar,
+ * Open window with initial window size, title bar,
* RGBA display mode, depth buffer, and handle input events.
*/
int
glutMouseFunc(pickRects);
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
*/
/*
* 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>
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)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* 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,
* 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
}
/* specify initial properties
- * create display list with sphere
+ * create display list with sphere
* initialize lighting and depth buffer
*/
void gfxinit (void)
case GLUT_LEFT_BUTTON:
switch (state) {
case GLUT_DOWN:
- spinx = (spinx + 5) % 360;
+ spinx = (spinx + 5) % 360;
glutPostRedisplay();
break;
default:
case GLUT_MIDDLE_BUTTON:
switch (state) {
case GLUT_DOWN:
- spiny = (spiny + 5) % 360;
+ spiny = (spiny + 5) % 360;
glutPostRedisplay();
break;
default:
}
}
+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)
glutMouseFunc(mouse);
glutKeyboardFunc(keyboard);
gfxinit();
+ glutKeyboardFunc(key);
glutMainLoop();
return 0;
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
/* 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);
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)
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)
myinit ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
*/
/*
* 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>
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);
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 ();
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)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
/*
* 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>
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);
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 ();
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)
myinit ();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
*/
/*
* scenebamb.c
- * This program demonstrates use of a blue ambient light
+ * This program demonstrates use of a blue ambient light
* source.
*/
#include <stdlib.h>
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);
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 ();
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)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
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);
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 ();
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)
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
* 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>
#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 };
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)
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)
myinit ();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
* 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.
*/
} 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}
};
};
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}
};
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)
myinit ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/**
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
*/
/**
* 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>
else
ctlpoints[u][v][2] = -3.0;
}
- }
-}
-
+ }
+}
+
/* Initialize material property and depth buffer.
*/
void myinit(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);
glEnd();
glEnable(GL_LIGHTING);
}
-
+
glPopMatrix();
glutSwapBuffers();
}
}
}
+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)
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutMouseFunc(mouse);
glutMotionFunc(motion);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/**
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
/* Initialize light source and lighting model.
*/
-void
+void
myinit(void)
{
GLfloat light_ambient[] =
glEnable(GL_DEPTH_TEST);
}
-void
+void
display(void)
{
GLfloat low_ambient[] =
glFlush();
}
-void
+void
myReshape(int w, int h)
{
glViewport(0, 0, w, 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
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
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.
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
/*
* 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,
* 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
*/
/* texbind.c
- * This program demonstrates using glBindTexture() by
+ * This program demonstrates using glBindTexture() by
* creating and managing two textures.
*/
#include <GL/glut.h>
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;
}
void init(void)
-{
+{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);
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,
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);
}
glutDisplayFunc(display);
glutKeyboardFunc (keyboard);
glutMainLoop();
- return 0;
+ return 0;
}
#else
int main(int argc, char** argv)
return 0;
}
#endif
-
/*
* 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,
* 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
* 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>
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;
}
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;
}
void init(void)
-{
+{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);
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);
}
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
- return 0;
+ return 0;
}
#else
int main(int argc, char** argv)
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
+ * and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
- * written prior permission.
+ * written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
+ *
+ * US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
#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)
{
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++) {
{
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);
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);
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
+ glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}