diff options
Diffstat (limited to 'progs/redbook')
85 files changed, 0 insertions, 14236 deletions
diff --git a/progs/redbook/.gitignore b/progs/redbook/.gitignore deleted file mode 100644 index 60a77523e27..00000000000 --- a/progs/redbook/.gitignore +++ /dev/null @@ -1,77 +0,0 @@ -.cvsignore -aaindex -aapoly -aargb -accanti -accpersp -alpha -alpha3D -anti -bezcurve -bezmesh -checker -clip -colormat -combiner -convolution -cube -cubemap -depthcue -dof -double -drawf -feedback -fog -fogcoord -fogindex -font -hello -histogram -image -light -lines -list -material -minmax -mipmap -model -movelight -multisamp -multitex -mvarray -nurbs -pickdepth -picksquare -plane -planet -pointp -polyoff -polys -quadric -robot -sccolorlight -scene -scenebamb -sceneflat -select -shadowmap -smooth -stencil -stroke -surface -surfpoints -teaambient -teapots -tess -tesswind -texbind -texgen -texprox -texsub -texture3d -texturesurf -torus -trim -unproject -varray -wrap diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile deleted file mode 100644 index b41e488729b..00000000000 --- a/progs/redbook/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# progs/redbook/Makefile - -TOP = ../.. -include $(TOP)/configs/current - -INCDIR = $(TOP)/include - -LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME) - -LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) - -PROGS = aaindex \ - aapoly \ - aargb \ - accanti \ - accpersp \ - alpha \ - alpha3D \ - anti \ - bezcurve \ - bezmesh \ - checker \ - clip \ - colormat \ - combiner \ - convolution \ - cube \ - cubemap \ - depthcue \ - dof \ - double \ - drawf \ - feedback \ - fog \ - fogcoord \ - fogindex \ - font \ - hello \ - histogram \ - image \ - light \ - lines \ - list \ - material \ - minmax \ - mipmap \ - model \ - movelight \ - multitex \ - multisamp \ - mvarray \ - nurbs \ - pickdepth \ - picksquare \ - plane \ - planet \ - pointp \ - polyoff \ - polys \ - quadric \ - robot \ - sccolorlight \ - scene \ - scenebamb \ - sceneflat \ - select \ - shadowmap \ - smooth \ - stencil \ - stroke \ - surface \ - surfpoints \ - teaambient \ - teapots \ - tess \ - tesswind \ - texbind \ - texgen \ - texprox \ - texsub \ - texturesurf \ - texture3d \ - torus \ - trim \ - unproject \ - varray \ - wrap - - - -##### RULES ##### - -.SUFFIXES: -.SUFFIXES: .c - -.c: $(LIB_DEP) - $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ - - - -##### TARGETS ###### - -default: $(PROGS) - - -clean: - -rm -f $(PROGS) - -rm -f *.o *~ - diff --git a/progs/redbook/Makefile.win b/progs/redbook/Makefile.win deleted file mode 100644 index 7e57b8e47f8..00000000000 --- a/progs/redbook/Makefile.win +++ /dev/null @@ -1,78 +0,0 @@ -# Makefile for Win32 - -TOP = .. -INCDIR = ..\include -LIBDIR = ..\lib - -!include <win32.mak> - -SRCS= \ - aaindex.c \ - aapoly.c \ - aargb.c \ - accanti.c \ - accpersp.c \ - alpha.c \ - alpha3D.c \ - anti.c \ - bezcurve.c \ - bezmesh.c \ - checker.c \ - clip.c \ - colormat.c \ - cube.c \ - depthcue.c \ - dof.c \ - double.c \ - drawf.c \ - feedback.c \ - fog.c \ - fogindex.c \ - font.c \ - hello.c \ - image.c \ - light.c \ - lines.c \ - list.c \ - material.c \ - mipmap.c \ - model.c \ - movelight.c \ - nurbs.c \ - pickdepth.c \ - picksquare.c \ - plane.c \ - planet.c \ - polyoff.c \ - polys.c \ - quadric.c \ - robot.c \ - sccolorlight.c \ - scene.c \ - scenebamb.c \ - sceneflat.c \ - select.c \ - smooth.c \ - stencil.c \ - stroke.c \ - surface.c \ - teaambient.c \ - teapots.c \ - tess.c \ - tesswind.c \ - texbind.c \ - texgen.c \ - texprox.c \ - texsub.c \ - texturesurf.c \ - torus.c \ - trim.c \ - unproject.c \ - varray.c \ - wrap.c - -!include "$(TOP)/mesawin32.mak" - -$(EXES) : $*.obj - @echo $@ - $(link) -out:$@ $* /LIBPATH:$(LIBDIR) $(LIBS)
\ No newline at end of file diff --git a/progs/redbook/README b/progs/redbook/README deleted file mode 100644 index 4c8d5a74c9a..00000000000 --- a/progs/redbook/README +++ /dev/null @@ -1,41 +0,0 @@ -/* - * For the software in this directory - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ - -The source code examples in this directory accompany the examples -printed in the _OpenGL Programming Guide_, published by Addison-Wesley; -ISBN 0-201-63274-8. diff --git a/progs/redbook/SConscript b/progs/redbook/SConscript deleted file mode 100644 index 750ad36fe01..00000000000 --- a/progs/redbook/SConscript +++ /dev/null @@ -1,86 +0,0 @@ -Import('*') - -progs = [ - 'aaindex', - 'aapoly', - 'aargb', - 'accanti', - 'accpersp', - 'alpha3D', - 'alpha', - 'anti', - 'bezcurve', - 'bezmesh', - 'checker', - 'clip', - 'colormat', - 'combiner', - 'convolution', - 'cube', - 'cubemap', - 'depthcue', - 'dof', - 'double', - 'drawf', - 'feedback', - 'fog', - 'fogcoord', - 'fogindex', - 'font', - 'hello', - 'histogram', - 'image', - 'light', - 'lines', - 'list', - 'material', - 'minmax', - 'mipmap', - 'model', - 'movelight', - 'multisamp', - 'multitex', - 'mvarray', - 'nurbs', - 'pickdepth', - 'picksquare', - 'plane', - 'planet', - 'pointp', - 'polyoff', - 'polys', - 'quadric', - 'robot', - 'sccolorlight', - 'scenebamb', - 'scene', - 'sceneflat', - 'select', - 'shadowmap', - 'smooth', - 'stencil', - 'stroke', - 'surface', - 'surfpoints', - 'teaambient', - 'teapots', - 'tess', - 'tesswind', - 'texbind', - 'texgen', - 'texprox', - 'texsub', - 'texturesurf', - 'texture3d', - 'torus', - 'trim', - 'unproject', - 'varray', - 'wrap', -] - -for prog in progs: - progs_env.Program( - target = prog, - source = prog + '.c', - ) diff --git a/progs/redbook/Windows/redbook.dsw b/progs/redbook/Windows/redbook.dsw deleted file mode 100644 index a739af4a4e6..00000000000 --- a/progs/redbook/Windows/redbook.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "teapots"=".\teapots.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/progs/redbook/Windows/teapots.dsp b/progs/redbook/Windows/teapots.dsp deleted file mode 100644 index b74ed089254..00000000000 --- a/progs/redbook/Windows/teapots.dsp +++ /dev/null @@ -1,112 +0,0 @@ -# Microsoft Developer Studio Project File - Name="teapots" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=teapots - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "teapots.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "teapots.mak" CFG="teapots - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "teapots - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "teapots - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "teapots - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../teapots.exe" -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Desc=Copy DLLs -PostBuild_Cmds=copy ..\..\..\lib\*.dll .. -# End Special Build Tool - -!ELSEIF "$(CFG)" == "teapots - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../teapots.exe" /pdbtype:sept -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Desc=Copy DLLs -PostBuild_Cmds=copy ..\..\..\lib\*.dll .. -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "teapots - Win32 Release" -# Name "teapots - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\teapots.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/progs/redbook/aaindex.c b/progs/redbook/aaindex.c deleted file mode 100644 index 6011ec44b67..00000000000 --- a/progs/redbook/aaindex.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * aaindex.c - * This program draws shows how to draw anti-aliased lines in color - * index mode. It draws two diagonal lines to form an X; when 'r' - * is typed in the window, the lines are rotated in opposite - * directions. - */ -#include <GL/glut.h> -#include "stdlib.h" - -#define RAMPSIZE 16 -#define RAMP1START 32 -#define RAMP2START 48 - -static float rotAngle = 0.; - -/* Initialize antialiasing for color index mode, - * including loading a green color ramp starting - * at RAMP1START, and a blue color ramp starting - * at RAMP2START. The ramps must be a multiple of 16. - */ -static void init(void) -{ - int i; - - for (i = 0; i < RAMPSIZE; i++) { - GLfloat shade; - shade = (GLfloat) i/(GLfloat) RAMPSIZE; - glutSetColor(RAMP1START+(GLint)i, 0., shade, 0.); - glutSetColor(RAMP2START+(GLint)i, 0., 0., shade); - } - - glEnable (GL_LINE_SMOOTH); - glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); - glLineWidth (1.5); - - glClearIndex ((GLfloat) RAMP1START); -} - -/* Draw 2 diagonal lines to form an X - */ -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - glIndexi(RAMP1START); - glPushMatrix(); - glRotatef(-rotAngle, 0.0, 0.0, 0.1); - glBegin (GL_LINES); - glVertex2f (-0.5, 0.5); - glVertex2f (0.5, -0.5); - glEnd (); - glPopMatrix(); - - glIndexi(RAMP2START); - glPushMatrix(); - glRotatef(rotAngle, 0.0, 0.0, 0.1); - glBegin (GL_LINES); - glVertex2f (0.5, 0.5); - glVertex2f (-0.5, -0.5); - glEnd (); - glPopMatrix(); - - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - gluOrtho2D (-1.0, 1.0, - -1.0*(GLfloat)h/(GLfloat)w, 1.0*(GLfloat)h/(GLfloat)w); - else - gluOrtho2D (-1.0*(GLfloat)w/(GLfloat)h, - 1.0*(GLfloat)w/(GLfloat)h, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 'r': - case 'R': - rotAngle += 20.; - if (rotAngle >= 360.) rotAngle = 0.; - glutPostRedisplay(); - break; - case 27: /* Escape Key */ - exit(0); - break; - default: - break; - } -} - -/* Main Loop - * Open window with initial window size, title bar, - * color index display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_INDEX); - glutInitWindowSize (200, 200); - glutCreateWindow (argv[0]); - init(); - glutReshapeFunc (reshape); - glutKeyboardFunc (keyboard); - glutDisplayFunc (display); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/aapoly.c b/progs/redbook/aapoly.c deleted file mode 100644 index 64d06b7b3da..00000000000 --- a/progs/redbook/aapoly.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * aapoly.c - * This program draws filled polygons with antialiased - * edges. The special GL_SRC_ALPHA_SATURATE blending - * function is used. - * Pressing the 't' key turns the antialiasing on and off. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -GLboolean polySmooth = GL_TRUE; - -static void init(void) -{ - glCullFace (GL_BACK); - glEnable (GL_CULL_FACE); - glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE); - glClearColor (0.0, 0.0, 0.0, 0.0); -} - -#define NFACE 6 -#define NVERT 8 -static void drawCube(GLdouble x0, GLdouble x1, GLdouble y0, GLdouble y1, - GLdouble z0, GLdouble z1) -{ - static GLfloat v[8][3]; - static GLfloat c[8][4] = { - {0.0, 0.0, 0.0, 1.0}, {1.0, 0.0, 0.0, 1.0}, - {0.0, 1.0, 0.0, 1.0}, {1.0, 1.0, 0.0, 1.0}, - {0.0, 0.0, 1.0, 1.0}, {1.0, 0.0, 1.0, 1.0}, - {0.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0} - }; - -/* indices of front, top, left, bottom, right, back faces */ - static GLubyte indices[NFACE][4] = { - {4, 5, 6, 7}, {2, 3, 7, 6}, {0, 4, 7, 3}, - {0, 1, 5, 4}, {1, 5, 6, 2}, {0, 3, 2, 1} - }; - - v[0][0] = v[3][0] = v[4][0] = v[7][0] = x0; - v[1][0] = v[2][0] = v[5][0] = v[6][0] = x1; - v[0][1] = v[1][1] = v[4][1] = v[5][1] = y0; - v[2][1] = v[3][1] = v[6][1] = v[7][1] = y1; - v[0][2] = v[1][2] = v[2][2] = v[3][2] = z0; - v[4][2] = v[5][2] = v[6][2] = v[7][2] = z1; - -#ifdef GL_VERSION_1_1 - glEnableClientState (GL_VERTEX_ARRAY); - glEnableClientState (GL_COLOR_ARRAY); - glVertexPointer (3, GL_FLOAT, 0, v); - glColorPointer (4, GL_FLOAT, 0, c); - glDrawElements (GL_QUADS, NFACE*4, GL_UNSIGNED_BYTE, indices); - glDisableClientState (GL_VERTEX_ARRAY); - glDisableClientState (GL_COLOR_ARRAY); -#else - printf ("If this is GL Version 1.0, "); - printf ("vertex arrays are not supported.\n"); - exit(1); -#endif -} - -/* Note: polygons must be drawn from front to back - * for proper blending. - */ -static void display(void) -{ - if (polySmooth) { - glClear (GL_COLOR_BUFFER_BIT); - glEnable (GL_BLEND); - glEnable (GL_POLYGON_SMOOTH); - glDisable (GL_DEPTH_TEST); - } - else { - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glDisable (GL_BLEND); - glDisable (GL_POLYGON_SMOOTH); - glEnable (GL_DEPTH_TEST); - } - - glPushMatrix (); - glTranslatef (0.0, 0.0, -8.0); - glRotatef (30.0, 1.0, 0.0, 0.0); - glRotatef (60.0, 0.0, 1.0, 0.0); - drawCube(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5); - glPopMatrix (); - - glFlush (); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(30.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 't': - case 'T': - polySmooth = !polySmooth; - glutPostRedisplay(); - break; - case 27: - exit(0); /* Escape key */ - break; - default: - break; - } -} - -/* Main Loop - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB - | GLUT_ALPHA | GLUT_DEPTH); - glutInitWindowSize(200, 200); - glutCreateWindow(argv[0]); - init (); - glutReshapeFunc (reshape); - glutKeyboardFunc (keyboard); - glutDisplayFunc (display); - glutMainLoop(); - return 0; -} - diff --git a/progs/redbook/aargb.c b/progs/redbook/aargb.c deleted file mode 100644 index 0021b549c2e..00000000000 --- a/progs/redbook/aargb.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * aargb.c - * This program draws shows how to draw anti-aliased lines. It draws - * two diagonal lines to form an X; when 'r' is typed in the window, - * the lines are rotated in opposite directions. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -static float rotAngle = 0.; - -/* Initialize antialiasing for RGBA mode, including alpha - * blending, hint, and line width. Print out implementation - * specific info on line width granularity and width. - */ -static void init(void) -{ - GLfloat values[2]; - glGetFloatv (GL_LINE_WIDTH_GRANULARITY, values); - 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", - values[0], values[1]); - - glEnable (GL_LINE_SMOOTH); - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); - glLineWidth (1.5); - - glClearColor(0.0, 0.0, 0.0, 0.0); -} - -/* Draw 2 diagonal lines to form an X - */ -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - glColor3f (0.0, 1.0, 0.0); - glPushMatrix(); - glRotatef(-rotAngle, 0.0, 0.0, 0.1); - glBegin (GL_LINES); - glVertex2f (-0.5, 0.5); - glVertex2f (0.5, -0.5); - glEnd (); - glPopMatrix(); - - glColor3f (0.0, 0.0, 1.0); - glPushMatrix(); - glRotatef(rotAngle, 0.0, 0.0, 0.1); - glBegin (GL_LINES); - glVertex2f (0.5, 0.5); - glVertex2f (-0.5, -0.5); - glEnd (); - glPopMatrix(); - - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - gluOrtho2D (-1.0, 1.0, - -1.0*(GLfloat)h/(GLfloat)w, 1.0*(GLfloat)h/(GLfloat)w); - else - gluOrtho2D (-1.0*(GLfloat)w/(GLfloat)h, - 1.0*(GLfloat)w/(GLfloat)h, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 'r': - case 'R': - rotAngle += 20.; - if (rotAngle >= 360.) rotAngle = 0.; - glutPostRedisplay(); - break; - case 27: /* Escape Key */ - exit(0); - break; - default: - break; - } -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (200, 200); - glutCreateWindow (argv[0]); - init(); - glutReshapeFunc (reshape); - glutKeyboardFunc (keyboard); - glutDisplayFunc (display); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/accanti.c b/progs/redbook/accanti.c deleted file mode 100644 index d1b25678419..00000000000 --- a/progs/redbook/accanti.c +++ /dev/null @@ -1,182 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* accanti.c - */ -#include <stdlib.h> -#include <GL/glut.h> -#include "jitter.h" - -/* Initialize lighting and other values. - */ -static void myinit(void) -{ - GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat light_position[] = { 0.0, 0.0, 10.0, 1.0 }; - GLfloat lm_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; - - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - 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); - glEnable(GL_DEPTH_TEST); - glShadeModel (GL_FLAT); - - glClearColor(0.0, 0.0, 0.0, 0.0); - glClearAccum(0.0, 0.0, 0.0, 0.0); -} - -static 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); - 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); - 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); - glutSolidCube (1.5); - glPopMatrix (); - - glPushMatrix (); - 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); - glMaterialfv(GL_FRONT, GL_DIFFUSE, octa_diffuse); - glutSolidOctahedron (); - glPopMatrix (); - - glPopMatrix (); -} - -#define ACSIZE 8 - -static void display(void) -{ - GLint viewport[4]; - int jitter; - - glGetIntegerv (GL_VIEWPORT, viewport); - - glClear(GL_ACCUM_BUFFER_BIT); - for (jitter = 0; jitter < ACSIZE; jitter++) { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - 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 - * world coordinates. - */ - glTranslatef (j8[jitter].x*4.5/viewport[2], - j8[jitter].y*4.5/viewport[3], 0.0); - displayObjects (); - glPopMatrix (); - glAccum(GL_ACCUM, 1.0/ACSIZE); - } - glAccum (GL_RETURN, 1.0); - glFlush(); -} - -static void myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - glOrtho (-2.25, 2.25, -2.25*h/w, 2.25*h/w, -10.0, 10.0); - 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, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB - | GLUT_ACCUM | GLUT_DEPTH); - glutInitWindowSize (250, 250); - glutCreateWindow (argv[0]); - myinit(); - glutReshapeFunc (myReshape); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/accpersp.c b/progs/redbook/accpersp.c deleted file mode 100644 index e172d0a917f..00000000000 --- a/progs/redbook/accpersp.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* accpersp.c - * Use the accumulation buffer to do full-scene antialiasing - * on a scene with perspective projection, using the special - * routines accFrustum() and accPerspective(). - */ -#include <stdlib.h> -#include <math.h> -#include <GL/glut.h> -#include "jitter.h" - -#define PI_ 3.14159265358979323846 - -/* accFrustum() - * The first 6 arguments are identical to the glFrustum() call. - * - * 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. - * Set both equal to 0.0 for no depth of field effects. - * - * 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 - * initialized to identity before calling accFrustum(). - */ -static 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 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); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef (-eyedx, -eyedy, 0.0); -} - -/* accPerspective() - * - * The first 4 arguments are identical to the gluPerspective() call. - * 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. - * Set both equal to 0.0 for no depth of field effects. - * - * 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(). - */ -static 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; - - fov2 = ((fovy*PI_) / 180.0) / 2.0; - - top = nnear / (cos(fov2) / sin(fov2)); - bottom = -top; - - right = top * aspect; - left = -right; - - accFrustum (left, right, bottom, top, nnear, ffar, - pixdx, pixdy, eyedx, eyedy, focus); -} - -/* Initialize lighting and other values. - */ -static void init(void) -{ - GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat light_position[] = { 0.0, 0.0, 10.0, 1.0 }; - GLfloat lm_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; - - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - 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); - glEnable(GL_DEPTH_TEST); - glShadeModel (GL_FLAT); - - glClearColor(0.0, 0.0, 0.0, 0.0); - glClearAccum(0.0, 0.0, 0.0, 0.0); -} - -static 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 (); - glTranslatef (0.0, 0.0, -5.0); - glRotatef (30.0, 1.0, 0.0, 0.0); - - glPushMatrix (); - 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); - 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); - glutSolidCube (1.5); - glPopMatrix (); - - glPushMatrix (); - 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); - glMaterialfv(GL_FRONT, GL_DIFFUSE, octa_diffuse); - glutSolidOctahedron (); - glPopMatrix (); - - glPopMatrix (); -} - -#define ACSIZE 8 - -static void display(void) -{ - GLint viewport[4]; - int jitter; - - glGetIntegerv (GL_VIEWPORT, viewport); - - glClear(GL_ACCUM_BUFFER_BIT); - for (jitter = 0; jitter < ACSIZE; jitter++) { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - accPerspective (50.0, - (GLdouble) viewport[2]/(GLdouble) viewport[3], - 1.0, 15.0, j8[jitter].x, j8[jitter].y, 0.0, 0.0, 1.0); - displayObjects (); - glAccum(GL_ACCUM, 1.0/ACSIZE); - } - glAccum (GL_RETURN, 1.0); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -/* Main Loop - * Be certain you request an accumulation buffer. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB - | GLUT_ACCUM | GLUT_DEPTH); - glutInitWindowSize (250, 250); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init(); - glutReshapeFunc(reshape); - glutDisplayFunc(display); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/alpha.c b/progs/redbook/alpha.c deleted file mode 100644 index b77c65e2c83..00000000000 --- a/progs/redbook/alpha.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * alpha.c - * This program draws several overlapping filled polygons - * to demonstrate the effect order has on alpha blending results. - * Use the 't' key to toggle the order of drawing polygons. - */ -#include <GL/glut.h> -#include <stdlib.h> - -static int leftFirst = GL_TRUE; - -/* Initialize alpha blending function. - */ -static void init(void) -{ - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glShadeModel (GL_FLAT); - glClearColor (0.0, 0.0, 0.0, 0.0); -} - -static void drawLeftTriangle(void) -{ - /* draw yellow triangle on LHS of screen */ - - glBegin (GL_TRIANGLES); - glColor4f(1.0, 1.0, 0.0, 0.75); - glVertex3f(0.1, 0.9, 0.0); - glVertex3f(0.1, 0.1, 0.0); - glVertex3f(0.7, 0.5, 0.0); - glEnd(); -} - -static void drawRightTriangle(void) -{ - /* draw cyan triangle on RHS of screen */ - - glBegin (GL_TRIANGLES); - glColor4f(0.0, 1.0, 1.0, 0.75); - glVertex3f(0.9, 0.9, 0.0); - glVertex3f(0.3, 0.5, 0.0); - glVertex3f(0.9, 0.1, 0.0); - glEnd(); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - if (leftFirst) { - drawLeftTriangle(); - drawRightTriangle(); - } - else { - drawRightTriangle(); - drawLeftTriangle(); - } - - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - gluOrtho2D (0.0, 1.0, 0.0, 1.0*(GLfloat)h/(GLfloat)w); - else - gluOrtho2D (0.0, 1.0*(GLfloat)w/(GLfloat)h, 0.0, 1.0); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 't': - case 'T': - leftFirst = !leftFirst; - glutPostRedisplay(); - break; - case 27: /* Escape key */ - exit(0); - break; - default: - break; - } -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (200, 200); - glutCreateWindow (argv[0]); - init(); - glutReshapeFunc (reshape); - glutKeyboardFunc (keyboard); - glutDisplayFunc (display); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/alpha3D.c b/progs/redbook/alpha3D.c deleted file mode 100644 index 494b1879d22..00000000000 --- a/progs/redbook/alpha3D.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * alpha3D.c - * This program demonstrates how to intermix opaque and - * alpha blended polygons in the same scene, by using - * glDepthMask. Press the 'a' key to animate moving the - * transparent object through the opaque object. Press - * the 'r' key to reset the scene. - */ -#include <stdlib.h> -#include <stdio.h> -#include <GL/glut.h> - -#define MAXZ 8.0 -#define MINZ -8.0 -#define ZINC 4. - -static float solidZ = MAXZ; -static float transparentZ = MINZ; -static GLuint sphereList, cubeList; - -static void init(void) -{ - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 0.15 }; - GLfloat mat_shininess[] = { 100.0 }; - GLfloat position[] = { 0.5, 0.5, 1.0, 0.0 }; - - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); - glLightfv(GL_LIGHT0, GL_POSITION, position); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); - - sphereList = glGenLists(1); - glNewList(sphereList, GL_COMPILE); - glutSolidSphere (0.4, 16, 16); - glEndList(); - - cubeList = glGenLists(1); - glNewList(cubeList, GL_COMPILE); - glutSolidCube (0.6); - glEndList(); -} - -static void display(void) -{ - GLfloat mat_solid[] = { 0.75, 0.75, 0.0, 1.0 }; - GLfloat mat_zero[] = { 0.0, 0.0, 0.0, 1.0 }; - GLfloat mat_transparent[] = { 0.0, 0.8, 0.8, 0.6 }; - GLfloat mat_emission[] = { 0.0, 0.3, 0.3, 0.6 }; - - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix (); - glTranslatef (-0.15, -0.15, solidZ); - glMaterialfv(GL_FRONT, GL_EMISSION, mat_zero); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_solid); - glCallList (sphereList); - glPopMatrix (); - - glPushMatrix (); - glTranslatef (0.15, 0.15, transparentZ); - glRotatef (15.0, 1.0, 1.0, 0.0); - glRotatef (30.0, 0.0, 1.0, 0.0); - glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_transparent); - glEnable (GL_BLEND); - glDepthMask (GL_FALSE); - glBlendFunc (GL_SRC_ALPHA, GL_ONE); - glCallList (cubeList); - glDepthMask (GL_TRUE); - glDisable (GL_BLEND); - glPopMatrix (); - - glutSwapBuffers(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLint) w, (GLint) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w, - 1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); - else - glOrtho (-1.5*(GLfloat)w/(GLfloat)h, - 1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -static void animate(void) -{ - static double t0 = -1.; - if (solidZ <= MINZ || transparentZ >= MAXZ) - { - glutIdleFunc(NULL); - t0 = -1.; - } - else { - double t, dt; - t = glutGet(GLUT_ELAPSED_TIME) / 1000.; - if (t0 < 0.) - t0 = t; - dt = t - t0; - t0 = t; - solidZ -= ZINC*dt; - transparentZ += ZINC*dt; - glutPostRedisplay(); - } -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 'a': - case 'A': - solidZ = MAXZ; - transparentZ = MINZ; - glutIdleFunc(animate); - break; - case 'r': - case 'R': - solidZ = MAXZ; - transparentZ = MINZ; - glutPostRedisplay(); - break; - case 27: - exit(0); - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(500, 500); - glutCreateWindow(argv[0]); - init(); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutDisplayFunc(display); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/anti.c b/progs/redbook/anti.c deleted file mode 100644 index a97a3ebc948..00000000000 --- a/progs/redbook/anti.c +++ /dev/null @@ -1,124 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * anti.c - * This program draws antialiased lines in RGBA mode. - */ -#include <stdlib.h> -#include <stdio.h> -#include <GL/glut.h> - -/* Initialize antialiasing for RGBA mode, including alpha - * blending, hint, and line width. Print out implementation - * specific info on line width granularity and width. - */ -static void myinit(void) -{ - GLfloat values[2]; - glGetFloatv (GL_LINE_WIDTH_GRANULARITY, values); - 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", - values[0], values[1]); - - glEnable (GL_LINE_SMOOTH); - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); - glLineWidth (1.5); - - glShadeModel(GL_FLAT); - glClearColor(0.0, 0.0, 0.0, 0.0); - glDepthFunc(GL_LESS); - glEnable(GL_DEPTH_TEST); -} - -/* display() draws an icosahedron with a large alpha value, 1.0. - */ -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glColor4f (1.0, 1.0, 1.0, 1.0); - glutWireIcosahedron(); - glFlush(); -} - -static void myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective (45.0, (GLfloat) w/(GLfloat) h, 3.0, 5.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity (); - 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, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutCreateWindow (argv[0]); - myinit(); - glutReshapeFunc (myReshape); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/bezcurve.c b/progs/redbook/bezcurve.c deleted file mode 100644 index 60a9c680802..00000000000 --- a/progs/redbook/bezcurve.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* bezcurve.c - * This program uses evaluators to draw a Bezier curve. - */ -#include <stdlib.h> -#include <GL/glut.h> - -GLfloat ctrlpoints[4][3] = { - { -4.0, -4.0, 0.0}, { -2.0, 4.0, 0.0}, - {2.0, -4.0, 0.0}, {4.0, 4.0, 0.0}}; - -static void init(void) -{ - glClearColor(0.0, 0.0, 0.0, 0.0); - glShadeModel(GL_FLAT); - glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]); - glEnable(GL_MAP1_VERTEX_3); -} - -static void display(void) -{ - int i; - - glClear(GL_COLOR_BUFFER_BIT); - glColor3f(1.0, 1.0, 1.0); - glBegin(GL_LINE_STRIP); - for (i = 0; i <= 30; i++) - glEvalCoord1f((GLfloat) i/30.0); - glEnd(); - /* The following code displays the control points as dots. */ - glPointSize(5.0); - glColor3f(1.0, 1.0, 0.0); - glBegin(GL_POINTS); - for (i = 0; i < 4; i++) - glVertex3fv(&ctrlpoints[i][0]); - glEnd(); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - glOrtho(-5.0, 5.0, -5.0*(GLfloat)h/(GLfloat)w, - 5.0*(GLfloat)h/(GLfloat)w, -5.0, 5.0); - else - glOrtho(-5.0*(GLfloat)w/(GLfloat)h, - 5.0*(GLfloat)w/(GLfloat)h, -5.0, 5.0, -5.0, 5.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/bezmesh.c b/progs/redbook/bezmesh.c deleted file mode 100644 index 1abc7488bcb..00000000000 --- a/progs/redbook/bezmesh.c +++ /dev/null @@ -1,162 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/** - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* bezsurf.c - * This program renders a lighted, filled Bezier surface, - * using two-dimensional evaluators. - */ -#include <stdlib.h> -#include <GL/glut.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}, - {0.5, 1.5, 0.0}, - {1.5, 1.5, -1.0}} -}; - -static void -initlights(void) -{ - GLfloat ambient[] = - {0.2, 0.2, 0.2, 1.0}; - GLfloat position[] = - {0.0, 0.0, 2.0, 1.0}; - GLfloat mat_diffuse[] = - {0.6, 0.6, 0.6, 1.0}; - GLfloat mat_specular[] = - {1.0, 1.0, 1.0, 1.0}; - GLfloat mat_shininess[] = - {50.0}; - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - - glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); - glLightfv(GL_LIGHT0, GL_POSITION, position); - - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); -} - -static void -display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glPushMatrix(); - glRotatef(85.0, 1.0, 1.0, 1.0); - glEvalMesh2(GL_FILL, 0, 20, 0, 20); - glPopMatrix(); - glFlush(); -} - -static void -myinit(void) -{ - glClearColor(0.0, 0.0, 0.0, 1.0); - glEnable(GL_DEPTH_TEST); - glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, - 0, 1, 12, 4, &ctrlpoints[0][0][0]); - glEnable(GL_MAP2_VERTEX_3); - glEnable(GL_AUTO_NORMAL); - glEnable(GL_NORMALIZE); - glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0); - initlights(); /* for lighted version only */ -} - -static void -myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - 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, - 4.0 * (GLfloat) w / (GLfloat) h, -4.0, 4.0, -4.0, 4.0); - glMatrixMode(GL_MODELVIEW); - 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); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutCreateWindow(argv[0]); - 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 deleted file mode 100644 index 60e6f7b60c8..00000000000 --- a/progs/redbook/checker.c +++ /dev/null @@ -1,140 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* checker.c - * This program texture maps a checkerboard image onto - * two rectangles. This program clamps the texture, if - * the texture coordinates fall outside 0.0 and 1.0. - */ -#include <stdlib.h> -#include <GL/glut.h> - -/* Create checkerboard texture */ -#define checkImageWidth 64 -#define checkImageHeight 64 -GLubyte checkImage[checkImageWidth][checkImageHeight][3]; - -static 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; - checkImage[i][j][0] = (GLubyte) c; - checkImage[i][j][1] = (GLubyte) c; - checkImage[i][j][2] = (GLubyte) c; - } - } -} - -static 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, - &checkImage[0][0][0]); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); - glEnable(GL_TEXTURE_2D); - glShadeModel(GL_FLAT); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); - glTexCoord2f(0.0, 1.0); glVertex3f(-2.0, 1.0, 0.0); - glTexCoord2f(1.0, 1.0); glVertex3f(0.0, 1.0, 0.0); - glTexCoord2f(1.0, 0.0); glVertex3f(0.0, -1.0, 0.0); - - glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); - glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 1.0, 0.0); - glTexCoord2f(1.0, 1.0); glVertex3f(2.41421, 1.0, -1.41421); - glTexCoord2f(1.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); - glEnd(); - glutSwapBuffers(); -} - -static void myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - 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) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); - glutCreateWindow("checker"); - myinit(); - glutReshapeFunc (myReshape); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/clip.c b/progs/redbook/clip.c deleted file mode 100644 index 85c464720db..00000000000 --- a/progs/redbook/clip.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * clip.c - * This program demonstrates arbitrary clipping planes. - */ -#include <GL/glut.h> -#include <stdlib.h> - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_FLAT); -} - -static void display(void) -{ - GLdouble eqn[4] = {0.0, 1.0, 0.0, 0.0}; - GLdouble eqn2[4] = {1.0, 0.0, 0.0, 0.0}; - - glClear(GL_COLOR_BUFFER_BIT); - - glColor3f (1.0, 1.0, 1.0); - glPushMatrix(); - glTranslatef (0.0, 0.0, -5.0); - -/* clip lower half -- y < 0 */ - glClipPlane (GL_CLIP_PLANE0, eqn); - glEnable (GL_CLIP_PLANE0); -/* clip left half -- x < 0 */ - glClipPlane (GL_CLIP_PLANE1, eqn2); - glEnable (GL_CLIP_PLANE1); - - glRotatef (90.0, 1.0, 0.0, 0.0); - glutWireSphere(1.0, 20, 16); - glPopMatrix(); - - glFlush (); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); - glMatrixMode (GL_MODELVIEW); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/colormat.c b/progs/redbook/colormat.c deleted file mode 100644 index d77fcb1ed46..00000000000 --- a/progs/redbook/colormat.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * colormat.c - * After initialization, the program will be in - * ColorMaterial mode. Interaction: pressing the - * mouse buttons will change the diffuse reflection values. - */ -#include <GL/glut.h> -#include <stdlib.h> - -GLfloat diffuseMaterial[4] = { 0.5, 0.5, 0.5, 1.0 }; - -/* Initialize material property, light source, lighting model, - * and depth buffer. - */ -static void init(void) -{ - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; - - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_SMOOTH); - glEnable(GL_DEPTH_TEST); - glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseMaterial); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialf(GL_FRONT, GL_SHININESS, 25.0); - glLightfv(GL_LIGHT0, GL_POSITION, light_position); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - - glColorMaterial(GL_FRONT, GL_DIFFUSE); - glEnable(GL_COLOR_MATERIAL); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glutSolidSphere(1.0, 20, 16); - glFlush (); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w, - 1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); - else - glOrtho (-1.5*(GLfloat)w/(GLfloat)h, - 1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED2 */ -static void mouse(int button, int state, int x, int y) -{ - switch (button) { - case GLUT_LEFT_BUTTON: - if (state == GLUT_DOWN) { - diffuseMaterial[0] += 0.1; - if (diffuseMaterial[0] > 1.0) - diffuseMaterial[0] = 0.0; - glColor4fv(diffuseMaterial); - glutPostRedisplay(); - } - break; - case GLUT_MIDDLE_BUTTON: - if (state == GLUT_DOWN) { - diffuseMaterial[1] += 0.1; - if (diffuseMaterial[1] > 1.0) - diffuseMaterial[1] = 0.0; - glColor4fv(diffuseMaterial); - glutPostRedisplay(); - } - break; - case GLUT_RIGHT_BUTTON: - if (state == GLUT_DOWN) { - diffuseMaterial[2] += 0.1; - if (diffuseMaterial[2] > 1.0) - diffuseMaterial[2] = 0.0; - glColor4fv(diffuseMaterial); - glutPostRedisplay(); - } - break; - default: - break; - } -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutMouseFunc(mouse); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/combiner.c b/progs/redbook/combiner.c deleted file mode 100644 index 7682e0c0324..00000000000 --- a/progs/redbook/combiner.c +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* combiner.c - * This program renders a variety of quads showing different - * effects of texture combiner functions. - * - * The first row renders an untextured polygon (so you can - * compare the fragment colors) and then the 2 textures. - * The second row shows several different combiner functions - * on a single texture: replace, modulate, add, add-signed, - * and subtract. - * The third row shows the interpolate combiner function - * on a single texture with a constant color/alpha value, - * varying the amount of interpolation. - * The fourth row uses multitexturing with two textures - * and different combiner functions. - * The fifth row are some combiner experiments: using the - * scaling factor and reversing the order of subtraction - * for a combination function. - */ -#include <GL/glew.h> -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -#define imageWidth 8 -#define imageHeight 8 -/* arrays for two textures */ -static GLubyte image0[imageHeight][imageWidth][4]; -static GLubyte image1[imageHeight][imageWidth][4]; - -static GLuint texName[4]; - -static void makeImages(void) -{ - int i, j, c; - for (i = 0; i < imageHeight; i++) { - for (j = 0; j < imageWidth; j++) { - c = ((i&2)==0)*255; /* horiz b & w stripes */ - image0[i][j][0] = (GLubyte) c; - image0[i][j][1] = (GLubyte) c; - image0[i][j][2] = (GLubyte) c; - image0[i][j][3] = (GLubyte) 255; - c = ((j&4)!=0)*128; /* wider vertical 50% cyan and black stripes */ - image1[i][j][0] = (GLubyte) 0; - image1[i][j][1] = (GLubyte) c; - image1[i][j][2] = (GLubyte) c; - image1[i][j][3] = (GLubyte) 255; - } - } -} - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel(GL_SMOOTH); - - makeImages(); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glGenTextures(4, texName); - - glBindTexture(GL_TEXTURE_2D, texName[0]); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - 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, imageWidth, imageHeight, - 0, GL_RGBA, GL_UNSIGNED_BYTE, image0); - - glBindTexture(GL_TEXTURE_2D, texName[1]); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - 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, imageWidth, imageHeight, - 0, GL_RGBA, GL_UNSIGNED_BYTE, image1); - -/* smooth-shaded polygon with multiple texture coordinates */ - glNewList (1, GL_COMPILE); - glBegin(GL_QUADS); - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0); - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0); - glColor3f (0.5, 1.0, 0.25); - glVertex3f(0.0, 0.0, 0.0); - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 2.0); - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 2.0); - glColor3f (1.0, 1.0, 1.0); - glVertex3f(0.0, 1.0, 0.0); - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 2.0, 2.0); - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 2.0, 2.0); - glColor3f (1.0, 1.0, 1.0); - glVertex3f(1.0, 1.0, 0.0); - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 2.0, 0.0); - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 2.0, 0.0); - glColor3f (1.0, 0.5, 0.25); - glVertex3f(1.0, 0.0, 0.0); - glEnd(); - glEndList (); -} - -static void display(void) -{ - static GLfloat constColor[4] = {0.0, 0.0, 0.0, 0.0}; /* for use as constant texture color */ - - glClear(GL_COLOR_BUFFER_BIT); - - glDisable(GL_TEXTURE_2D); /* untextured polygon--see the "fragment" colors */ - glPushMatrix(); - glTranslatef(0.0, 5.0, 0.0); - glCallList(1); - glPopMatrix(); - - glEnable(GL_TEXTURE_2D); -/* draw ordinary textured polys; 1 texture unit; combine mode disabled */ - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glPushMatrix(); - glBindTexture(GL_TEXTURE_2D, texName[0]); - glTranslatef(1.0, 5.0, 0.0); - glCallList(1); - glPopMatrix(); - - glPushMatrix(); - glBindTexture(GL_TEXTURE_2D, texName[1]); - glTranslatef(2.0, 5.0, 0.0); - glCallList(1); - glPopMatrix(); - -/* different combine modes enabled; 1 texture unit - * defaults are: - * glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); - * glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); - * glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB); - * glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); - */ - glBindTexture(GL_TEXTURE_2D, texName[0]); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); - glPushMatrix(); - glTranslatef(1.0, 4.0, 0.0); - glCallList(1); - glPopMatrix(); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB); - glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); - glPushMatrix(); - glTranslatef(2.0, 4.0, 0.0); - glCallList(1); - glPopMatrix(); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD); - glPushMatrix(); - glTranslatef(3.0, 4.0, 0.0); - glCallList(1); - glPopMatrix(); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB); - glPushMatrix(); - glTranslatef(4.0, 4.0, 0.0); - glCallList(1); - glPopMatrix(); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_SUBTRACT_ARB); - glPushMatrix(); - glTranslatef(5.0, 4.0, 0.0); - glCallList(1); - glPopMatrix(); - -/* interpolate combine with constant color; 1 texture unit - * use different alpha values for constant color - * defaults are: - * glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); - * glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); - * glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB); - * glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); - * glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_CONSTANT_ARB); - * glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA); - */ - constColor[3] = 0.2; - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constColor); - glBindTexture(GL_TEXTURE_2D, texName[0]); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB); - glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_CONSTANT_ARB); - glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA); - glPushMatrix(); - glTranslatef(1.0, 3.0, 0.0); - glCallList(1); - glPopMatrix(); - - constColor[3] = 0.4; - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constColor); - glPushMatrix(); - glTranslatef(2.0, 3.0, 0.0); - glCallList(1); - glPopMatrix(); - - constColor[3] = 0.6; - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constColor); - glPushMatrix(); - glTranslatef(3.0, 3.0, 0.0); - glCallList(1); - glPopMatrix(); - - constColor[3] = 0.8; - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constColor); - glPushMatrix(); - glTranslatef(4.0, 3.0, 0.0); - glCallList(1); - glPopMatrix(); - -/* combine textures 0 & 1 - * defaults are: - * glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); - * glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); - * glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB); - * glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); - */ - - glActiveTextureARB (GL_TEXTURE0_ARB); - glEnable (GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texName[0]); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - glActiveTextureARB (GL_TEXTURE1_ARB); - glEnable (GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texName[1]); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); - glPushMatrix(); - glTranslatef(1.0, 2.0, 0.0); - glCallList(1); - glPopMatrix(); - - /* try different combiner modes of texture unit 1 */ - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); - glPushMatrix(); - glTranslatef(2.0, 2.0, 0.0); - glCallList(1); - glPopMatrix(); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD); - glPushMatrix(); - glTranslatef(3.0, 2.0, 0.0); - glCallList(1); - glPopMatrix(); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB); - glPushMatrix(); - glTranslatef(4.0, 2.0, 0.0); - glCallList(1); - glPopMatrix(); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_SUBTRACT_ARB); - glPushMatrix(); - glTranslatef(5.0, 2.0, 0.0); - glCallList(1); - glPopMatrix(); - -/* some experiments */ - -/* see the effect of RGB_SCALE */ - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); - glPushMatrix(); - glTranslatef(1.0, 1.0, 0.0); - glCallList(1); - glPopMatrix(); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); - glPushMatrix(); - glTranslatef(2.0, 1.0, 0.0); - glCallList(1); - glPopMatrix(); - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0); - -/* using SOURCE0 and SOURCE1, reverse the order of subtraction Arg1-Arg0 */ - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_SUBTRACT_ARB); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); - glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); - glPushMatrix(); - glTranslatef(5.0, 1.0, 0.0); - glCallList(1); - glPopMatrix(); - - glActiveTextureARB (GL_TEXTURE1_ARB); /* deactivate multitexturing */ - glDisable (GL_TEXTURE_2D); - glActiveTextureARB (GL_TEXTURE0_ARB); /* activate single texture unit */ - - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluOrtho2D(0.0, 7.0, 0.0, 7.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -static void keyboard (unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - default: - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize(400, 400); - glutInitWindowPosition(100, 100); - glutCreateWindow(argv[0]); - glewInit(); - init(); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/convolution.c b/progs/redbook/convolution.c deleted file mode 100644 index c04a8727a71..00000000000 --- a/progs/redbook/convolution.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * convolution.c - * Use various 2D convolutions filters to find edges in an image. - * - */ -#include <GL/glew.h> -#include <GL/glut.h> -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> - - -static GLuint bswap(GLuint x) -{ - const GLuint ui = 1; - const GLubyte *ubp = (const GLubyte *) &ui; - if (*ubp == 1) { - /* we're on little endiang so byteswap x */ - GLsizei y = ((x >> 24) - | ((x >> 8) & 0xff00) - | ((x << 8) & 0xff0000) - | ((x << 24) & 0xff000000)); - return y; - } - else { - return x; - } -} - - -static GLubyte * -readImage( const char* filename, GLsizei* width, GLsizei *height ) -{ - int n; - GLubyte* pixels; - size_t num_read; - - FILE* infile = fopen( filename, "rb" ); - - if ( !infile ) { - fprintf( stderr, "Unable to open file '%s'\n", filename ); - exit(1); - } - - num_read = fread( width, sizeof( GLsizei ), 1, infile ); - assert(num_read == 1); - num_read = fread( height, sizeof( GLsizei ), 1, infile ); - assert(num_read == 1); - - *width = bswap(*width); - *height = bswap(*height); - - assert(*width > 0); - assert(*height > 0); - - n = 3 * (*width) * (*height); - - pixels = (GLubyte *) malloc( n * sizeof( GLubyte )); - if ( !pixels ) { - fprintf( stderr, "Unable to malloc() bytes for pixels\n" ); - fclose( infile ); - return NULL; - } - - num_read = fread( pixels, sizeof( GLubyte ), n, infile ); - assert(num_read == n); - - fclose( infile ); - - return pixels; -} - - -GLubyte *pixels; -GLsizei width, height; - -GLfloat horizontal[3][3] = { - { 0, -1, 0 }, - { 0, 1, 0 }, - { 0, 0, 0 } -}; - -GLfloat vertical[3][3] = { - { 0, 0, 0 }, - { -1, 1, 0 }, - { 0, 0, 0 } -}; - -GLfloat laplacian[3][3] = { - { -0.125, -0.125, -0.125 }, - { -0.125, 1.0 , -0.125 }, - { -0.125, -0.125, -0.125 }, -}; - - -static void init(void) -{ - if (!glutExtensionSupported("GL_ARB_imaging")) { - fprintf(stderr, "Sorry, this program requires GL_ARB_imaging.\n"); - exit(1); - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glClearColor(0.0, 0.0, 0.0, 0.0); - - printf("Using the horizontal filter\n"); - glConvolutionFilter2D(GL_CONVOLUTION_2D, GL_LUMINANCE, - 3, 3, GL_LUMINANCE, GL_FLOAT, horizontal); - glEnable(GL_CONVOLUTION_2D); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - glRasterPos2i( 1, 1); - glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, w, 0, h, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); -} - -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 'h' : - printf("Using a horizontal filter\n"); - glConvolutionFilter2D(GL_CONVOLUTION_2D, GL_LUMINANCE, 3, 3, - GL_LUMINANCE, GL_FLOAT, horizontal); - break; - - case 'v' : - printf("Using the vertical filter\n"); - glConvolutionFilter2D(GL_CONVOLUTION_2D, GL_LUMINANCE, 3, 3, - GL_LUMINANCE, GL_FLOAT, vertical); - break; - - case 'l' : - printf("Using the laplacian filter\n"); - glConvolutionFilter2D(GL_CONVOLUTION_2D, GL_LUMINANCE, 3, 3, - GL_LUMINANCE, GL_FLOAT, laplacian); - break; - - case 27: - exit(0); - } - glutPostRedisplay(); -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - pixels = readImage("leeds.bin", &width, &height); - - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA); - glutInitWindowSize(width, height); - glutInitWindowPosition(100, 100); - glutCreateWindow(argv[0]); - glewInit(); - init(); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutDisplayFunc(display); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/cube.c b/progs/redbook/cube.c deleted file mode 100644 index 3c6becb2157..00000000000 --- a/progs/redbook/cube.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * cube.c - * This program demonstrates a single modeling transformation, - * glScalef() and a single viewing transformation, gluLookAt(). - * A wireframe cube is rendered. - */ -#include <GL/glut.h> -#include <stdlib.h> - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_FLAT); -} - -static void display(void) -{ - glClear (GL_COLOR_BUFFER_BIT); - glColor3f (1.0, 1.0, 1.0); - glLoadIdentity (); /* clear the matrix */ - /* viewing transformation */ - gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); - glScalef (1.0, 2.0, 1.0); /* modeling transformation */ - glutWireCube (1.0); - glFlush (); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0); - glMatrixMode (GL_MODELVIEW); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/cubemap.c b/progs/redbook/cubemap.c deleted file mode 100644 index 92026c70897..00000000000 --- a/progs/redbook/cubemap.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* cubemap.c - * - * This program demonstrates cube map textures. - * Six different colored checker board textures are - * created and applied to a lit sphere. - * - * Pressing the 'f' and 'b' keys translate the viewer - * forward and backward. - */ - -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -#define imageSize 4 -static GLubyte image1[imageSize][imageSize][4]; -static GLubyte image2[imageSize][imageSize][4]; -static GLubyte image3[imageSize][imageSize][4]; -static GLubyte image4[imageSize][imageSize][4]; -static GLubyte image5[imageSize][imageSize][4]; -static GLubyte image6[imageSize][imageSize][4]; - -static GLdouble ztrans = 0.0; - -static void makeImages(void) -{ - int i, j, c; - - for (i = 0; i < imageSize; i++) { - for (j = 0; j < imageSize; j++) { - c = ( ((i & 0x1) == 0) ^ ((j & 0x1) == 0) ) * 255; - image1[i][j][0] = (GLubyte) c; - image1[i][j][1] = (GLubyte) c; - image1[i][j][2] = (GLubyte) c; - image1[i][j][3] = (GLubyte) 255; - - image2[i][j][0] = (GLubyte) c; - image2[i][j][1] = (GLubyte) c; - image2[i][j][2] = (GLubyte) 0; - image2[i][j][3] = (GLubyte) 255; - - image3[i][j][0] = (GLubyte) c; - image3[i][j][1] = (GLubyte) 0; - image3[i][j][2] = (GLubyte) c; - image3[i][j][3] = (GLubyte) 255; - - image4[i][j][0] = (GLubyte) 0; - image4[i][j][1] = (GLubyte) c; - image4[i][j][2] = (GLubyte) c; - image4[i][j][3] = (GLubyte) 255; - - image5[i][j][0] = (GLubyte) 255; - image5[i][j][1] = (GLubyte) c; - image5[i][j][2] = (GLubyte) c; - image5[i][j][3] = (GLubyte) 255; - - image6[i][j][0] = (GLubyte) c; - image6[i][j][1] = (GLubyte) c; - image6[i][j][2] = (GLubyte) 255; - image6[i][j][3] = (GLubyte) 255; - } - } -} - -static void init(void) -{ - GLfloat diffuse[4] = {1.0, 1.0, 1.0, 1.0}; - - glClearColor (0.0, 0.0, 0.0, 0.0); - glEnable(GL_DEPTH_TEST); - glShadeModel(GL_SMOOTH); - - makeImages(); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_R, GL_REPEAT); - glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT, 0, GL_RGBA, imageSize, - imageSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, image1); - glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT, 0, GL_RGBA, imageSize, - imageSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, image4); - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT, 0, GL_RGBA, imageSize, - imageSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, image2); - glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT, 0, GL_RGBA, imageSize, - imageSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, image5); - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT, 0, GL_RGBA, imageSize, - imageSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, image3); - glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT, 0, GL_RGBA, imageSize, - imageSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, image6); - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_EXT); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_EXT); - glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_EXT); - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - glEnable(GL_TEXTURE_GEN_R); - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - glEnable(GL_TEXTURE_CUBE_MAP_EXT); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_AUTO_NORMAL); - glEnable(GL_NORMALIZE); - glMaterialfv (GL_FRONT, GL_DIFFUSE, diffuse); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix (); - glTranslatef (0.0, 0.0, ztrans); - glutSolidSphere (5.0, 20, 10); - glPopMatrix (); - glutSwapBuffers(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(40.0, (GLfloat) w/(GLfloat) h, 1.0, 300.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -20.0); -} - -static void keyboard (unsigned char key, int x, int y) -{ - switch (key) { - case 'f': - ztrans = ztrans - 0.2; - glutPostRedisplay(); - break; - case 'b': - ztrans = ztrans + 0.2; - glutPostRedisplay(); - break; - case 27: - exit(0); - break; - default: - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(400, 400); - glutInitWindowPosition(100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/depthcue.c b/progs/redbook/depthcue.c deleted file mode 100644 index d4b604baf13..00000000000 --- a/progs/redbook/depthcue.c +++ /dev/null @@ -1,115 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * depthcue.c - * This program draws a wireframe model, which uses - * intensity (brightness) to give clues to distance. - * Fog is used to achieve this effect. - */ -#include <stdlib.h> -#include <GL/glut.h> - -/* Initialize linear fog for depth cueing. - */ -static void myinit(void) -{ - GLfloat fogColor[4] = {0.0, 0.0, 0.0, 1.0}; - - glEnable(GL_FOG); - glFogi (GL_FOG_MODE, GL_LINEAR); - glHint (GL_FOG_HINT, GL_NICEST); /* per pixel */ - glFogf (GL_FOG_START, 3.0); - glFogf (GL_FOG_END, 5.0); - glFogfv (GL_FOG_COLOR, fogColor); - glClearColor(0.0, 0.0, 0.0, 1.0); - - glDepthFunc(GL_LESS); - glEnable(GL_DEPTH_TEST); - glShadeModel(GL_FLAT); -} - -/* display() draws an icosahedron. - */ -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glColor3f (1.0, 1.0, 1.0); - glutWireIcosahedron(); - glFlush(); -} - -static void myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective (45.0, (GLfloat) w/(GLfloat) h, 3.0, 5.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity (); - 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) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutCreateWindow(argv[0]); - 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 deleted file mode 100644 index 8558f02deea..00000000000 --- a/progs/redbook/dof.c +++ /dev/null @@ -1,251 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * dof.c - * This program demonstrates use of the accumulation buffer to - * create an out-of-focus depth-of-field effect. The teapots - * are drawn several times into the accumulation buffer. The - * viewing volume is jittered, except at the focal point, where - * the viewing volume is at the same position, each time. In - * this case, the gold teapot remains in focus. - */ -#include <stdlib.h> -#include <math.h> -#include <GL/glut.h> -#include "jitter.h" - -#define PI_ 3.14159265358979323846 - -/* accFrustum() - * The first 6 arguments are identical to the glFrustum() call. - * - * 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. - * Set both equal to 0.0 for no depth of field effects. - * - * 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 - * initialized to identity before calling accFrustum(). - */ -static 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 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); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef (-eyedx, -eyedy, 0.0); -} - -/* accPerspective() - * - * The first 4 arguments are identical to the gluPerspective() call. - * 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. - * Set both equal to 0.0 for no depth of field effects. - * - * 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(). - */ -static 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; - - fov2 = ((fovy*PI_) / 180.0) / 2.0; - - top = nnear / (cos(fov2) / sin(fov2)); - bottom = -top; - - right = top * aspect; - left = -right; - - accFrustum (left, right, bottom, top, nnear, ffar, - pixdx, pixdy, eyedx, eyedy, focus); -} - -static 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 }; - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - - 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); - - glFrontFace (GL_CW); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_AUTO_NORMAL); - glEnable(GL_NORMALIZE); - - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - - glClearColor(0.0, 0.0, 0.0, 0.0); - glClearAccum(0.0, 0.0, 0.0, 0.0); -} - -static 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; - glMaterialfv (GL_FRONT, GL_AMBIENT, mat); - 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); - glMaterialf (GL_FRONT, GL_SHININESS, shine*128.0); - glutSolidTeapot(0.5); - glPopMatrix(); -} - -/* 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 - * 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 - */ -static void display(void) -{ - int jitter; - GLint viewport[4]; - - glGetIntegerv (GL_VIEWPORT, viewport); - glClear(GL_ACCUM_BUFFER_BIT); - - for (jitter = 0; jitter < 8; jitter++) { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - 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 */ - renderTeapot (-1.1, -0.5, -4.5, 0.1745, 0.01175, 0.01175, - 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6); - renderTeapot (-0.5, -0.5, -5.0, 0.24725, 0.1995, 0.0745, - 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, - 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, - 0.50980392, 0.50196078, 0.50196078, 0.50196078, .25); - glAccum (GL_ACCUM, 0.125); - } - - glAccum (GL_RETURN, 1.0); - glFlush(); -} - -static 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, - * RGBA display mode, depth buffer, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB - | GLUT_ACCUM | GLUT_DEPTH); - glutCreateWindow (argv[0]); - 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 deleted file mode 100644 index c4ead224dc8..00000000000 --- a/progs/redbook/double.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * double.c - * This is a simple double buffered program. - * Pressing the left mouse button rotates the rectangle. - * Pressing the middle mouse button stops the rotation. - */ -#include <GL/glut.h> -#include <stdlib.h> - -static GLfloat spin = 0.0; -static GLdouble t0 = 0.; - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - glPushMatrix(); - glRotatef(spin, 0.0, 0.0, 1.0); - glColor3f(1.0, 1.0, 1.0); - glRectf(-25.0, -25.0, 25.0, 25.0); - glPopMatrix(); - - glutSwapBuffers(); -} - -static GLdouble gettime(void) -{ - return (GLdouble)(glutGet(GLUT_ELAPSED_TIME)) / 1000.; -} - -static void spinDisplay(void) -{ - GLdouble t, dt; - t = gettime(); - dt = t - t0; - t0 = t; - spin = spin + 120.0*dt; - if (spin > 360.0) - spin = spin - 360.0; - glutPostRedisplay(); -} - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_FLAT); -} - -static void reshape(int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED2 */ -static void mouse(int button, int state, int x, int y) -{ - switch (button) { - case GLUT_LEFT_BUTTON: - if (state == GLUT_DOWN) - { - t0 = gettime(); - glutIdleFunc(spinDisplay); - } - break; - case GLUT_MIDDLE_BUTTON: - if (state == GLUT_DOWN) - glutIdleFunc(NULL); - break; - default: - 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 - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); - glutInitWindowSize (250, 250); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutMouseFunc(mouse); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/drawf.c b/progs/redbook/drawf.c deleted file mode 100644 index 6c048be7844..00000000000 --- a/progs/redbook/drawf.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * drawf.c - * Draws the bitmapped letter F on the screen (several times). - * This demonstrates use of the glBitmap() call. - */ -#include <GL/glut.h> -#include <stdlib.h> - -GLubyte rasters[24] = { - 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, - 0xff, 0x00, 0xff, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, - 0xff, 0xc0, 0xff, 0xc0}; - -static void init(void) -{ - glPixelStorei (GL_UNPACK_ALIGNMENT, 1); - glClearColor (0.0, 0.0, 0.0, 0.0); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - glColor3f (1.0, 1.0, 1.0); - glRasterPos2i (20, 20); - glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters); - glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters); - glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho (0, w, 0, h, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - } -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize(100, 100); - glutInitWindowPosition(100, 100); - glutCreateWindow(argv[0]); - init(); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutDisplayFunc(display); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/feedback.c b/progs/redbook/feedback.c deleted file mode 100644 index 3c8c8cc7eaf..00000000000 --- a/progs/redbook/feedback.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * feedback.c - * This program demonstrates use of OpenGL feedback. First, - * a lighting environment is set up and a few lines are drawn. - * Then feedback mode is entered, and the same lines are - * drawn. The results in the feedback buffer are printed. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -/* Initialize lighting. - */ -static void init(void) -{ - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); -} - -/* Draw a few lines and two points, one of which will - * be clipped. If in feedback mode, a passthrough token - * is issued between the each primitive. - */ -static void drawGeometry (GLenum mode) -{ - glBegin (GL_LINE_STRIP); - glNormal3f (0.0, 0.0, 1.0); - glVertex3f (30.0, 30.0, 0.0); - glVertex3f (50.0, 60.0, 0.0); - glVertex3f (70.0, 40.0, 0.0); - glEnd (); - if (mode == GL_FEEDBACK) - glPassThrough (1.0); - glBegin (GL_POINTS); - glVertex3f (-100.0, -100.0, -100.0); /* will be clipped */ - glEnd (); - if (mode == GL_FEEDBACK) - glPassThrough (2.0); - glBegin (GL_POINTS); - glNormal3f (0.0, 0.0, 1.0); - glVertex3f (50.0, 50.0, 0.0); - glEnd (); -} - -/* Write contents of one vertex to stdout. */ -static void print3DcolorVertex (GLint size, GLint *count, - GLfloat *buffer) -{ - int i; - - printf (" "); - for (i = 0; i < 7; i++) { - printf ("%4.2f ", buffer[size-(*count)]); - *count = *count - 1; - } - printf ("\n"); -} - -/* Write contents of entire buffer. (Parse tokens!) */ -static void printBuffer(GLint size, GLfloat *buffer) -{ - GLint count; - GLfloat token; - - count = size; - while (count) { - token = buffer[size-count]; count--; - if (token == GL_PASS_THROUGH_TOKEN) { - printf ("GL_PASS_THROUGH_TOKEN\n"); - printf (" %4.2f\n", buffer[size-count]); - count--; - } - else if (token == GL_POINT_TOKEN) { - printf ("GL_POINT_TOKEN\n"); - print3DcolorVertex (size, &count, buffer); - } - else if (token == GL_LINE_TOKEN) { - printf ("GL_LINE_TOKEN\n"); - print3DcolorVertex (size, &count, buffer); - print3DcolorVertex (size, &count, buffer); - } - else if (token == GL_LINE_RESET_TOKEN) { - printf ("GL_LINE_RESET_TOKEN\n"); - print3DcolorVertex (size, &count, buffer); - print3DcolorVertex (size, &count, buffer); - } - } -} - -static void display(void) -{ - GLfloat feedBuffer[1024]; - GLint size; - - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - glOrtho (0.0, 100.0, 0.0, 100.0, 0.0, 1.0); - - glClearColor (0.0, 0.0, 0.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - drawGeometry (GL_RENDER); - - glFeedbackBuffer (1024, GL_3D_COLOR, feedBuffer); - (void) glRenderMode (GL_FEEDBACK); - drawGeometry (GL_FEEDBACK); - - size = glRenderMode (GL_RENDER); - printBuffer (size, feedBuffer); - - glFinish(); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -/* Main Loop */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (100, 100); - glutInitWindowPosition (100, 100); - glutCreateWindow(argv[0]); - init(); - glutDisplayFunc(display); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/fog.c b/progs/redbook/fog.c deleted file mode 100644 index 4f4b8e3cc0a..00000000000 --- a/progs/redbook/fog.c +++ /dev/null @@ -1,200 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/** - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * 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 - * as fixed start and end values for the linear fog. - */ -#include <stdlib.h> -#include <math.h> -#include <GL/glut.h> - -GLint fogMode; - -static void -selectFog(int mode) -{ - switch(mode) { - case GL_LINEAR: - glFogf(GL_FOG_START, 1.0); - glFogf(GL_FOG_END, 5.0); - /* falls through */ - case GL_EXP2: - case GL_EXP: - glFogi(GL_FOG_MODE, mode); - glutPostRedisplay(); - break; - case 0: - exit(0); - } -} - -/* Initialize z-buffer, projection matrix, light source, - * and lighting model. Do not specify a material property here. - */ -static void -myinit(void) -{ - GLfloat position[] = - {0.0, 3.0, 3.0, 0.0}; - GLfloat local_view[] = - {0.0}; - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - - glLightfv(GL_LIGHT0, GL_POSITION, position); - glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); - - glFrontFace(GL_CW); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_AUTO_NORMAL); - glEnable(GL_NORMALIZE); - glEnable(GL_FOG); - { - GLfloat fogColor[4] = - {0.5, 0.5, 0.5, 1.0}; - - fogMode = GL_EXP; - glFogi(GL_FOG_MODE, fogMode); - glFogfv(GL_FOG_COLOR, fogColor); - glFogf(GL_FOG_DENSITY, 0.35); - glHint(GL_FOG_HINT, GL_DONT_CARE); - glClearColor(0.5, 0.5, 0.5, 1.0); - } -} - -static void -renderRedTeapot(GLfloat x, GLfloat y, GLfloat z) -{ - float mat[4]; - - glPushMatrix(); - glTranslatef(x, y, z); - mat[0] = 0.1745; - mat[1] = 0.01175; - mat[2] = 0.01175; - mat[3] = 1.0; - glMaterialfv(GL_FRONT, GL_AMBIENT, mat); - mat[0] = 0.61424; - mat[1] = 0.04136; - mat[2] = 0.04136; - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); - mat[0] = 0.727811; - mat[1] = 0.626959; - mat[2] = 0.626959; - glMaterialfv(GL_FRONT, GL_SPECULAR, mat); - glMaterialf(GL_FRONT, GL_SHININESS, 0.6 * 128.0); - glutSolidTeapot(1.0); - glPopMatrix(); -} - -/* display() draws 5 teapots at different z positions. - */ -static void -display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - renderRedTeapot(-4.0, -0.5, -1.0); - renderRedTeapot(-2.0, -0.5, -2.0); - renderRedTeapot(0.0, -0.5, -3.0); - renderRedTeapot(2.0, -0.5, -4.0); - renderRedTeapot(4.0, -0.5, -5.0); - glFlush(); -} - -static void -myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= (h * 3)) - glOrtho(-6.0, 6.0, -2.0 * ((GLfloat) h * 3) / (GLfloat) w, - 2.0 * ((GLfloat) h * 3) / (GLfloat) w, 0.0, 10.0); - else - glOrtho(-6.0 * (GLfloat) w / ((GLfloat) h * 3), - 6.0 * (GLfloat) w / ((GLfloat) h * 3), -2.0, 2.0, 0.0, 10.0); - glMatrixMode(GL_MODELVIEW); - 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, - * RGBA display mode, depth buffer, and handle input events. - */ -int -main(int argc, char **argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(450, 150); - glutCreateWindow(argv[0]); - myinit(); - glutReshapeFunc(myReshape); - glutDisplayFunc(display); - glutCreateMenu(selectFog); - glutAddMenuEntry("Fog EXP", GL_EXP); - glutAddMenuEntry("Fog EXP2", GL_EXP2); - 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/fogcoord.c b/progs/redbook/fogcoord.c deleted file mode 100644 index 17ef7ae5f3a..00000000000 --- a/progs/redbook/fogcoord.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * fogcoord.c - * - * This program demonstrates the use of explicit fog - * coordinates. You can press the keyboard and change - * the fog coordinate value at any vertex. You can - * also switch between using explicit fog coordinates - * and the default fog generation mode. - * - * Pressing the 'f' and 'b' keys move the viewer forward - * and backwards. - * Pressing 'c' initiates the default fog generation. - * Pressing capital 'C' restores explicit fog coordinates. - * Pressing '1', '2', '3', '8', '9', and '0' add or - * subtract from the fog coordinate values at one of the - * three vertices of the triangle. - */ - -#include <GL/glew.h> -#include <GL/glut.h> -#include <math.h> -#include <stdlib.h> -#include <stdio.h> - -static GLfloat f1, f2, f3; - -/* Initialize fog - */ -static void init(void) -{ - GLfloat fogColor[4] = {0.0, 0.25, 0.25, 1.0}; - f1 = 1.0f; - f2 = 5.0f; - f3 = 10.0f; - - glEnable(GL_FOG); - glFogi (GL_FOG_MODE, GL_EXP); - glFogfv (GL_FOG_COLOR, fogColor); - glFogf (GL_FOG_DENSITY, 0.25); - glHint (GL_FOG_HINT, GL_DONT_CARE); - glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT); - glClearColor(0.0, 0.25, 0.25, 1.0); /* fog color */ -} - -/* display() draws a triangle at an angle. - */ -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - glColor3f (1.0f, 0.75f, 0.0f); - glBegin (GL_TRIANGLES); - glFogCoordfEXT (f1); - glVertex3f (2.0f, -2.0f, 0.0f); - glFogCoordfEXT (f2); - glVertex3f (-2.0f, 0.0f, -5.0f); - glFogCoordfEXT (f3); - glVertex3f (0.0f, 2.0f, -10.0f); - glEnd(); - - glutSwapBuffers(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective (45.0, 1.0, 0.25, 25.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity (); - glTranslatef (0.0, 0.0, -5.0); -} - -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 'c': - glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT); - glutPostRedisplay(); - break; - case 'C': - glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT); - glutPostRedisplay(); - break; - case '1': - f1 = f1 + 0.25; - glutPostRedisplay(); - break; - case '2': - f2 = f2 + 0.25; - glutPostRedisplay(); - break; - case '3': - f3 = f3 + 0.25; - glutPostRedisplay(); - break; - case '8': - if (f1 > 0.25) { - f1 = f1 - 0.25; - glutPostRedisplay(); - } - break; - case '9': - if (f2 > 0.25) { - f2 = f2 - 0.25; - glutPostRedisplay(); - } - break; - case '0': - if (f3 > 0.25) { - f3 = f3 - 0.25; - glutPostRedisplay(); - } - break; - case 'b': - glMatrixMode (GL_MODELVIEW); - glTranslatef (0.0, 0.0, -0.25); - glutPostRedisplay(); - break; - case 'f': - glMatrixMode (GL_MODELVIEW); - glTranslatef (0.0, 0.0, 0.25); - glutPostRedisplay(); - break; - case 27: - exit(0); - break; - default: - break; - } -} - - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, depth buffer, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); - glutInitWindowSize(500, 500); - glutCreateWindow(argv[0]); - glewInit(); - init(); - glutReshapeFunc (reshape); - glutKeyboardFunc (keyboard); - glutDisplayFunc (display); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/fogindex.c b/progs/redbook/fogindex.c deleted file mode 100644 index 6b5aa353caa..00000000000 --- a/progs/redbook/fogindex.c +++ /dev/null @@ -1,152 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * 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 - * with a color ramp. - */ -#include <stdlib.h> -#include <GL/glut.h> - -/* Initialize color map and fog. Set screen clear color - * to end of color ramp. - */ -#define NUM_COLORS 32 -#define RAMPSTART 16 - -static void -myinit(void) -{ - int i; - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - for (i = 0; i < NUM_COLORS; i++) { - GLfloat shade; - shade = (GLfloat) (NUM_COLORS - i) / (GLfloat) NUM_COLORS; - glutSetColor(16 + i, shade, shade, shade); - } - glEnable(GL_FOG); - - glFogi(GL_FOG_MODE, GL_LINEAR); - glFogi(GL_FOG_INDEX, NUM_COLORS); - glFogf(GL_FOG_START, 0.0); - glFogf(GL_FOG_END, 4.0); - glHint(GL_FOG_HINT, GL_NICEST); - glClearIndex((GLfloat) (NUM_COLORS + RAMPSTART - 1)); -} - -/* display() renders 3 cones at different z positions. - */ -static void -display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glPushMatrix(); - glTranslatef(-1.0, -1.0, -1.0); - glRotatef(-90.0, 1.0, 0.0, 0.0); - glIndexi(RAMPSTART); - glutSolidCone(1.0, 2.0, 10, 10); - glPopMatrix(); - - glPushMatrix(); - glTranslatef(0.0, -1.0, -2.25); - glRotatef(-90.0, 1.0, 0.0, 0.0); - glIndexi(RAMPSTART); - glutSolidCone(1.0, 2.0, 10, 10); - glPopMatrix(); - - glPushMatrix(); - glTranslatef(1.0, -1.0, -3.5); - glRotatef(-90.0, 1.0, 0.0, 0.0); - glIndexi(RAMPSTART); - glutSolidCone(1.0, 2.0, 10, 10); - glPopMatrix(); - glFlush(); -} - -static void -myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - glOrtho(-2.0, 2.0, -2.0 * (GLfloat) h / (GLfloat) w, - 2.0 * (GLfloat) h / (GLfloat) w, 0.0, 10.0); - else - glOrtho(-2.0 * (GLfloat) w / (GLfloat) h, - 2.0 * (GLfloat) w / (GLfloat) h, -2.0, 2.0, 0.0, 10.0); - glMatrixMode(GL_MODELVIEW); - 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, - * RGBA display mode, depth buffer, and handle input events. - */ -int -main(int argc, char **argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_INDEX | GLUT_DEPTH); - glutCreateWindow(argv[0]); - myinit(); - glutReshapeFunc(myReshape); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/font.c b/progs/redbook/font.c deleted file mode 100644 index c7a1035aa99..00000000000 --- a/progs/redbook/font.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * font.c - * - * Draws some text in a bitmapped font. Uses glBitmap() - * and other pixel routines. Also demonstrates use of - * display lists. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <string.h> - -GLubyte space[] = -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -GLubyte letters[][13] = { -{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18}, -{0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, -{0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e}, -{0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc}, -{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff}, -{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff}, -{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e}, -{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, -{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e}, -{0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06}, -{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3}, -{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0}, -{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3}, -{0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf, 0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3}, -{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e}, -{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, -{0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c}, -{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, -{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e}, -{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff}, -{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, -{0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, -{0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, -{0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3}, -{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3}, -{0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff} -}; - -GLuint fontOffset; - -static void makeRasterFont(void) -{ - GLuint i, j; - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - fontOffset = glGenLists (128); - for (i = 0,j = 'A'; i < 26; i++,j++) { - glNewList(fontOffset + j, GL_COMPILE); - glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, letters[i]); - glEndList(); - } - glNewList(fontOffset + ' ', GL_COMPILE); - glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, space); - glEndList(); -} - -static void init(void) -{ - glShadeModel (GL_FLAT); - makeRasterFont(); -} - -static void printString(char *s) -{ - glPushAttrib (GL_LIST_BIT); - glListBase(fontOffset); - glCallLists((GLsizei) strlen(s), GL_UNSIGNED_BYTE, (GLubyte *) s); - glPopAttrib (); -} - -/* Everything above this line could be in a library - * that defines a font. To make it work, you've got - * to call makeRasterFont() before you start making - * calls to printString(). - */ -static void display(void) -{ - GLfloat white[3] = { 1.0, 1.0, 1.0 }; - - glClear(GL_COLOR_BUFFER_BIT); - glColor3fv(white); - - glRasterPos2i(20, 60); - printString("THE QUICK BROWN FOX JUMPS"); - glRasterPos2i(20, 40); - printString("OVER A LAZY DOG"); - glFlush (); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho (0.0, w, 0.0, h, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - } -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize(300, 100); - glutInitWindowPosition (100, 100); - glutCreateWindow(argv[0]); - init(); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutDisplayFunc(display); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/hello.c b/progs/redbook/hello.c deleted file mode 100644 index 84183b25b9f..00000000000 --- a/progs/redbook/hello.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * hello.c - * This is a simple, introductory OpenGL program. - */ -#include <stdlib.h> -#include <GL/glut.h> - -static void display(void) -{ -/* clear all pixels */ - 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) - */ - glColor3f (1.0, 1.0, 1.0); - glBegin(GL_POLYGON); - glVertex3f (0.25, 0.25, 0.0); - glVertex3f (0.75, 0.25, 0.0); - glVertex3f (0.75, 0.75, 0.0); - glVertex3f (0.25, 0.75, 0.0); - glEnd(); - -/* don't wait! - * start processing buffered OpenGL routines - */ - glFlush (); -} - -static void init (void) -{ -/* select clearing color */ - glClearColor (0.0, 0.0, 0.0, 0.0); - -/* initialize viewing values */ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - 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. - * Register callback function to display graphics. - * Enter main loop and process events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (250, 250); - glutInitWindowPosition (100, 100); - glutCreateWindow ("hello"); - init (); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/histogram.c b/progs/redbook/histogram.c deleted file mode 100644 index 12b0e315ca1..00000000000 --- a/progs/redbook/histogram.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * histogram.c - * Compute the histogram of the image. This program illustrates the - * use of the glHistogram() function. - */ - -#include <GL/glew.h> -#include <GL/glut.h> -#include <assert.h> -#include <stdlib.h> -#include <stdio.h> - -#define HISTOGRAM_SIZE 256 /* Must be a power of 2 */ - - -static GLubyte *pixels; -static GLsizei width, height; - - - -static GLuint bswap(GLuint x) -{ - const GLuint ui = 1; - const GLubyte *ubp = (const GLubyte *) &ui; - if (*ubp == 1) { - /* we're on little endiang so byteswap x */ - GLsizei y = ((x >> 24) - | ((x >> 8) & 0xff00) - | ((x << 8) & 0xff0000) - | ((x << 24) & 0xff000000)); - return y; - } - else { - return x; - } -} - - -static GLubyte* -readImage( const char* filename, GLsizei* width, GLsizei *height ) -{ - int n; - GLubyte* pixels; - size_t num_read; - - FILE* infile = fopen( filename, "rb" ); - - if ( !infile ) { - fprintf( stderr, "Unable to open file '%s'\n", filename ); - exit(1); - } - - num_read = fread( width, sizeof( GLsizei ), 1, infile ); - assert(num_read == 1); - num_read = fread( height, sizeof( GLsizei ), 1, infile ); - assert(num_read == 1); - - *width = bswap(*width); - *height = bswap(*height); - - n = 3 * (*width) * (*height); - - pixels = (GLubyte *) malloc( n * sizeof( GLubyte )); - if ( !pixels ) { - fprintf( stderr, "Unable to malloc() bytes for pixels\n" ); - fclose( infile ); - return NULL; - } - - num_read = fread( pixels, sizeof( GLubyte ), n, infile ); - assert(num_read == n); - - fclose( infile ); - - return pixels; -} - -static void init(void) -{ - if (!glutExtensionSupported("GL_ARB_imaging")) { - fprintf(stderr, "Sorry, this program requires GL_ARB_imaging.\n"); - exit(1); - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glClearColor(0.0, 0.0, 0.0, 0.0); - - glHistogram(GL_HISTOGRAM, HISTOGRAM_SIZE, GL_RGB, GL_FALSE); - glEnable(GL_HISTOGRAM); -} - -static void display(void) -{ - int i; - GLushort values[HISTOGRAM_SIZE][3]; - - glClear(GL_COLOR_BUFFER_BIT); - glRasterPos2i(1, 1); - glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels); - - glGetHistogram(GL_HISTOGRAM, GL_TRUE, GL_RGB, GL_UNSIGNED_SHORT, values); - - /* Plot histogram */ - - glBegin(GL_LINE_STRIP); - glColor3f(1.0, 0.0, 0.0); - for ( i = 0; i < HISTOGRAM_SIZE; i++ ) - glVertex2s(i, values[i][0]); - glEnd(); - - glBegin(GL_LINE_STRIP); - glColor3f(0.0, 1.0, 0.0); - for ( i = 0; i < HISTOGRAM_SIZE; i++ ) - glVertex2s(i, values[i][1]); - glEnd(); - - glBegin(GL_LINE_STRIP); - glColor3f(0.0, 0.0, 1.0); - for ( i = 0; i < HISTOGRAM_SIZE; i++ ) - glVertex2s(i, values[i][2]); - glEnd(); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, 256, 0, 10000, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); -} - -static void keyboard(unsigned char key, int x, int y) -{ - static GLboolean sink = GL_FALSE; - - switch (key) { - case 's' : - sink = !sink; - glHistogram(GL_HISTOGRAM, HISTOGRAM_SIZE, GL_RGB, sink); - break; - - case 27: - exit(0); - } - glutPostRedisplay(); - -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - pixels = readImage("leeds.bin", &width, &height); - - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize(width, height); - glutInitWindowPosition(100, 100); - glutCreateWindow(argv[0]); - glewInit(); - init(); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutDisplayFunc(display); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/image.c b/progs/redbook/image.c deleted file mode 100644 index fa3b46f5ed4..00000000000 --- a/progs/redbook/image.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* image.c - * This program demonstrates drawing pixels and shows the effect - * of glDrawPixels(), glCopyPixels(), and glPixelZoom(). - * Interaction: moving the mouse while pressing the mouse button - * will copy the image in the lower-left corner of the window - * to the mouse position, using the current pixel zoom factors. - * There is no attempt to prevent you from drawing over the original - * image. If you press the 'r' key, the original image and zoom - * factors are reset. If you press the 'z' or 'Z' keys, you change - * the zoom factors. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -/* Create checkerboard image */ -#define checkImageWidth 64 -#define checkImageHeight 64 -GLubyte checkImage[checkImageHeight][checkImageWidth][3]; - -static GLdouble zoomFactor = 1.0; -static GLint height; - -static void makeCheckImage(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; - checkImage[i][j][0] = (GLubyte) c; - checkImage[i][j][1] = (GLubyte) c; - checkImage[i][j][2] = (GLubyte) c; - } - } -} - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel(GL_FLAT); - makeCheckImage(); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - glRasterPos2i(0, 0); - glDrawPixels(checkImageWidth, checkImageHeight, GL_RGB, - GL_UNSIGNED_BYTE, checkImage); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - height = (GLint) h; - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluOrtho2D(0.0, (GLdouble) w, 0.0, (GLdouble) h); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -static void motion(int x, int y) -{ - static GLint screeny; - - screeny = height - (GLint) y; - glRasterPos2i (x, screeny); - glPixelZoom (zoomFactor, zoomFactor); - glCopyPixels (0, 0, checkImageWidth, checkImageHeight, GL_COLOR); - glPixelZoom (1.0, 1.0); - glFlush (); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 'r': - case 'R': - zoomFactor = 1.0; - glutPostRedisplay(); - printf ("zoomFactor reset to 1.0\n"); - break; - case 'z': - zoomFactor += 0.5; - if (zoomFactor >= 3.0) - zoomFactor = 3.0; - printf ("zoomFactor is now %4.1f\n", zoomFactor); - break; - case 'Z': - zoomFactor -= 0.5; - if (zoomFactor <= 0.5) - zoomFactor = 0.5; - printf ("zoomFactor is now %4.1f\n", zoomFactor); - break; - case 27: - exit(0); - break; - default: - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize(250, 250); - glutInitWindowPosition(100, 100); - glutCreateWindow(argv[0]); - init(); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMotionFunc(motion); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/jitter.h b/progs/redbook/jitter.h deleted file mode 100644 index 1ec08c87fd4..00000000000 --- a/progs/redbook/jitter.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* -jitter.h - -This file contains jitter point arrays for 2,3,4,8,15,24 and 66 jitters. - -The arrays are named j2, j3, etc. Each element in the array has the form, -for example, j8[0].x and j8[0].y - -Values are floating point in the range -.5 < x < .5, -.5 < y < .5, and -have a gaussian distribution around the origin. - -Use these to do model jittering for scene anti-aliasing and view volume -jittering for depth of field effects. Use in conjunction with the -accwindow() routine. -*/ - -typedef struct -{ - GLfloat x, y; -} jitter_point; - -#define MAX_SAMPLES 66 - - -/* 2 jitter points */ -jitter_point j2[] = -{ - { 0.246490, 0.249999}, - {-0.246490, -0.249999} -}; - - -/* 3 jitter points */ -jitter_point j3[] = -{ - {-0.373411, -0.250550}, - { 0.256263, 0.368119}, - { 0.117148, -0.117570} -}; - - -/* 4 jitter points */ -jitter_point j4[] = -{ - {-0.208147, 0.353730}, - { 0.203849, -0.353780}, - {-0.292626, -0.149945}, - { 0.296924, 0.149994} -}; - - -/* 8 jitter points */ -jitter_point j8[] = -{ - {-0.334818, 0.435331}, - { 0.286438, -0.393495}, - { 0.459462, 0.141540}, - {-0.414498, -0.192829}, - {-0.183790, 0.082102}, - {-0.079263, -0.317383}, - { 0.102254, 0.299133}, - { 0.164216, -0.054399} -}; - - -/* 15 jitter points */ -jitter_point j15[] = -{ - { 0.285561, 0.188437}, - { 0.360176, -0.065688}, - {-0.111751, 0.275019}, - {-0.055918, -0.215197}, - {-0.080231, -0.470965}, - { 0.138721, 0.409168}, - { 0.384120, 0.458500}, - {-0.454968, 0.134088}, - { 0.179271, -0.331196}, - {-0.307049, -0.364927}, - { 0.105354, -0.010099}, - {-0.154180, 0.021794}, - {-0.370135, -0.116425}, - { 0.451636, -0.300013}, - {-0.370610, 0.387504} -}; - - -/* 24 jitter points */ -jitter_point j24[] = -{ - { 0.030245, 0.136384}, - { 0.018865, -0.348867}, - {-0.350114, -0.472309}, - { 0.222181, 0.149524}, - {-0.393670, -0.266873}, - { 0.404568, 0.230436}, - { 0.098381, 0.465337}, - { 0.462671, 0.442116}, - { 0.400373, -0.212720}, - {-0.409988, 0.263345}, - {-0.115878, -0.001981}, - { 0.348425, -0.009237}, - {-0.464016, 0.066467}, - {-0.138674, -0.468006}, - { 0.144932, -0.022780}, - {-0.250195, 0.150161}, - {-0.181400, -0.264219}, - { 0.196097, -0.234139}, - {-0.311082, -0.078815}, - { 0.268379, 0.366778}, - {-0.040601, 0.327109}, - {-0.234392, 0.354659}, - {-0.003102, -0.154402}, - { 0.297997, -0.417965} -}; - - -/* 66 jitter points */ -jitter_point j66[] = -{ - { 0.266377, -0.218171}, - {-0.170919, -0.429368}, - { 0.047356, -0.387135}, - {-0.430063, 0.363413}, - {-0.221638, -0.313768}, - { 0.124758, -0.197109}, - {-0.400021, 0.482195}, - { 0.247882, 0.152010}, - {-0.286709, -0.470214}, - {-0.426790, 0.004977}, - {-0.361249, -0.104549}, - {-0.040643, 0.123453}, - {-0.189296, 0.438963}, - {-0.453521, -0.299889}, - { 0.408216, -0.457699}, - { 0.328973, -0.101914}, - {-0.055540, -0.477952}, - { 0.194421, 0.453510}, - { 0.404051, 0.224974}, - { 0.310136, 0.419700}, - {-0.021743, 0.403898}, - {-0.466210, 0.248839}, - { 0.341369, 0.081490}, - { 0.124156, -0.016859}, - {-0.461321, -0.176661}, - { 0.013210, 0.234401}, - { 0.174258, -0.311854}, - { 0.294061, 0.263364}, - {-0.114836, 0.328189}, - { 0.041206, -0.106205}, - { 0.079227, 0.345021}, - {-0.109319, -0.242380}, - { 0.425005, -0.332397}, - { 0.009146, 0.015098}, - {-0.339084, -0.355707}, - {-0.224596, -0.189548}, - { 0.083475, 0.117028}, - { 0.295962, -0.334699}, - { 0.452998, 0.025397}, - { 0.206511, -0.104668}, - { 0.447544, -0.096004}, - {-0.108006, -0.002471}, - {-0.380810, 0.130036}, - {-0.242440, 0.186934}, - {-0.200363, 0.070863}, - {-0.344844, -0.230814}, - { 0.408660, 0.345826}, - {-0.233016, 0.305203}, - { 0.158475, -0.430762}, - { 0.486972, 0.139163}, - {-0.301610, 0.009319}, - { 0.282245, -0.458671}, - { 0.482046, 0.443890}, - {-0.121527, 0.210223}, - {-0.477606, -0.424878}, - {-0.083941, -0.121440}, - {-0.345773, 0.253779}, - { 0.234646, 0.034549}, - { 0.394102, -0.210901}, - {-0.312571, 0.397656}, - { 0.200906, 0.333293}, - { 0.018703, -0.261792}, - {-0.209349, -0.065383}, - { 0.076248, 0.478538}, - {-0.073036, -0.355064}, - { 0.145087, 0.221726} -}; diff --git a/progs/redbook/leeds.bin b/progs/redbook/leeds.bin Binary files differdeleted file mode 100644 index 5dc105e6768..00000000000 --- a/progs/redbook/leeds.bin +++ /dev/null diff --git a/progs/redbook/light.c b/progs/redbook/light.c deleted file mode 100644 index 9431dce508e..00000000000 --- a/progs/redbook/light.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * light.c - * This program demonstrates the use of the OpenGL lighting - * model. A sphere is drawn using a grey material characteristic. - * A single light source illuminates the object. - */ -#include <GL/glut.h> -#include <stdlib.h> - -/* Initialize material property, light source, lighting model, - * and depth buffer. - */ -static void init(void) -{ - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat mat_shininess[] = { 50.0 }; - GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; - - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_SMOOTH); - - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); - glLightfv(GL_LIGHT0, GL_POSITION, light_position); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); -} - -static void display(void) -{ - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glutSolidSphere (1.0, 20, 16); - glFlush (); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w, - 1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); - else - glOrtho (-1.5*(GLfloat)w/(GLfloat)h, - 1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/lines.c b/progs/redbook/lines.c deleted file mode 100644 index 9f12da9acfe..00000000000 --- a/progs/redbook/lines.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * lines.c - * This program demonstrates geometric primitives and - * their attributes. - */ -#include <GL/glut.h> -#include <stdlib.h> - -#define drawOneLine(x1,y1,x2,y2) glBegin(GL_LINES); \ - glVertex2f ((x1),(y1)); glVertex2f ((x2),(y2)); glEnd(); - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_FLAT); -} - -static void display(void) -{ - int i; - - glClear (GL_COLOR_BUFFER_BIT); - -/* select white for all lines */ - glColor3f (1.0, 1.0, 1.0); - -/* in 1st row, 3 lines, each with a different stipple */ - glEnable (GL_LINE_STIPPLE); - - glLineStipple (1, 0x0101); /* dotted */ - drawOneLine (50.0, 125.0, 150.0, 125.0); - glLineStipple (1, 0x00FF); /* dashed */ - drawOneLine (150.0, 125.0, 250.0, 125.0); - glLineStipple (1, 0x1C47); /* dash/dot/dash */ - drawOneLine (250.0, 125.0, 350.0, 125.0); - -/* in 2nd row, 3 wide lines, each with different stipple */ - glLineWidth (5.0); - glLineStipple (1, 0x0101); /* dotted */ - drawOneLine (50.0, 100.0, 150.0, 100.0); - glLineStipple (1, 0x00FF); /* dashed */ - drawOneLine (150.0, 100.0, 250.0, 100.0); - glLineStipple (1, 0x1C47); /* dash/dot/dash */ - drawOneLine (250.0, 100.0, 350.0, 100.0); - glLineWidth (1.0); - -/* in 3rd row, 6 lines, with dash/dot/dash stipple */ -/* as part of a single connected line strip */ - glLineStipple (1, 0x1C47); /* dash/dot/dash */ - glBegin (GL_LINE_STRIP); - for (i = 0; i < 7; i++) - glVertex2f (50.0 + ((GLfloat) i * 50.0), 75.0); - glEnd (); - -/* in 4th row, 6 independent lines with same stipple */ - for (i = 0; i < 6; i++) { - drawOneLine (50.0 + ((GLfloat) i * 50.0), 50.0, - 50.0 + ((GLfloat)(i+1) * 50.0), 50.0); - } - -/* in 5th row, 1 line, with dash/dot/dash stipple */ -/* and a stipple repeat factor of 5 */ - glLineStipple (5, 0x1C47); /* dash/dot/dash */ - drawOneLine (50.0, 25.0, 350.0, 25.0); - - glDisable (GL_LINE_STIPPLE); - glFlush (); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (400, 150); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/list.c b/progs/redbook/list.c deleted file mode 100644 index 5dea26fcad1..00000000000 --- a/progs/redbook/list.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * list.c - * This program demonstrates how to make and execute a - * display list. Note that attributes, such as current - * color and matrix, are changed. - */ -#include <GL/glut.h> -#include <stdlib.h> - -GLuint listName; - -static void init (void) -{ - listName = glGenLists (1); - glNewList (listName, GL_COMPILE); - glColor3f (1.0, 0.0, 0.0); /* current color red */ - glBegin (GL_TRIANGLES); - glVertex2f (0.0, 0.0); - glVertex2f (1.0, 0.0); - glVertex2f (0.0, 1.0); - glEnd (); - glTranslatef (1.5, 0.0, 0.0); /* move position */ - glEndList (); - glShadeModel (GL_FLAT); -} - -static void drawLine (void) -{ - glBegin (GL_LINES); - glVertex2f (0.0, 0.5); - glVertex2f (15.0, 0.5); - glEnd (); -} - -static void display(void) -{ - GLuint i; - - glClear (GL_COLOR_BUFFER_BIT); - glColor3f (0.0, 1.0, 0.0); /* current color green */ - for (i = 0; i < 10; i++) /* draw 10 triangles */ - glCallList (listName); - drawLine (); /* is this line green? NO! */ - /* where is the line drawn? */ - glFlush (); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - gluOrtho2D (0.0, 2.0, -0.5 * (GLfloat) h/(GLfloat) w, - 1.5 * (GLfloat) h/(GLfloat) w); - else - gluOrtho2D (0.0, 2.0 * (GLfloat) w/(GLfloat) h, -0.5, 1.5); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize(650, 50); - glutCreateWindow(argv[0]); - init (); - glutReshapeFunc (reshape); - glutDisplayFunc (display); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/material.c b/progs/redbook/material.c deleted file mode 100644 index 5edddd9ef84..00000000000 --- a/progs/redbook/material.c +++ /dev/null @@ -1,306 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * material.c - * This program demonstrates the use of the GL lighting model. - * Several objects are drawn using different material characteristics. - * A single light source illuminates the objects. - */ -#include <stdlib.h> -#include <GL/glut.h> - -/* Initialize z-buffer, projection matrix, light source, - * and lighting model. Do not specify a material property here. - */ -static 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, 2.0, 0.0 }; - GLfloat lmodel_ambient[] = { 0.4, 0.4, 0.4, 1.0 }; - GLfloat local_view[] = { 0.0 }; - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - - 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); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - - glClearColor(0.0, 0.1, 0.1, 0.0); -} - -/* 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. - * - * The first column has materials with blue, diffuse reflection only. - * The second column has blue diffuse reflection, as well as specular - * reflection with a low shininess exponent. - * The third column has blue diffuse reflection, as well as specular - * reflection with a high shininess exponent (a more concentrated highlight). - * The fourth column has materials which also include an emissive component. - * - * glTranslatef() is used to move spheres to their appropriate locations. - */ - -static void display(void) -{ - GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 }; - GLfloat mat_ambient[] = { 0.7, 0.7, 0.7, 1.0 }; - GLfloat mat_ambient_color[] = { 0.8, 0.8, 0.2, 1.0 }; - GLfloat mat_diffuse[] = { 0.1, 0.5, 0.8, 1.0 }; - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat no_shininess[] = { 0.0 }; - GLfloat low_shininess[] = { 5.0 }; - GLfloat high_shininess[] = { 100.0 }; - GLfloat mat_emission[] = {0.3, 0.2, 0.2, 0.0}; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - -/* draw sphere in first row, first column - * diffuse reflection only; no ambient or specular - */ - glPushMatrix(); - glTranslatef (-3.75, 3.0, 0.0); - glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); - glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); - glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); - glutSolidSphere(1.0, 16, 16); - glPopMatrix(); - -/* draw sphere in first row, second column - * diffuse and specular reflection; low shininess; no ambient - */ - glPushMatrix(); - glTranslatef (-1.25, 3.0, 0.0); - glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); - glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); - glutSolidSphere(1.0, 16, 16); - glPopMatrix(); - -/* draw sphere in first row, third column - * diffuse and specular reflection; high shininess; no ambient - */ - glPushMatrix(); - glTranslatef (1.25, 3.0, 0.0); - glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); - glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); - glutSolidSphere(1.0, 16, 16); - glPopMatrix(); - -/* draw sphere in first row, fourth column - * diffuse reflection; emission; no ambient or specular reflection - */ - glPushMatrix(); - glTranslatef (3.75, 3.0, 0.0); - glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); - glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); - glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); - glutSolidSphere(1.0, 16, 16); - glPopMatrix(); - -/* draw sphere in second row, first column - * ambient and diffuse reflection; no specular - */ - glPushMatrix(); - glTranslatef (-3.75, 0.0, 0.0); - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); - glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); - glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); - glutSolidSphere(1.0, 16, 16); - glPopMatrix(); - -/* draw sphere in second row, second column - * ambient, diffuse and specular reflection; low shininess - */ - glPushMatrix(); - glTranslatef (-1.25, 0.0, 0.0); - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); - glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); - glutSolidSphere(1.0, 16, 16); - glPopMatrix(); - -/* draw sphere in second row, third column - * ambient, diffuse and specular reflection; high shininess - */ - glPushMatrix(); - glTranslatef (1.25, 0.0, 0.0); - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); - glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); - glutSolidSphere(1.0, 16, 16); - glPopMatrix(); - -/* draw sphere in second row, fourth column - * ambient and diffuse reflection; emission; no specular - */ - glPushMatrix(); - glTranslatef (3.75, 0.0, 0.0); - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); - glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); - glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); - glutSolidSphere(1.0, 16, 16); - glPopMatrix(); - -/* draw sphere in third row, first column - * colored ambient and diffuse reflection; no specular - */ - glPushMatrix(); - glTranslatef (-3.75, -3.0, 0.0); - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); - glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); - glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); - glutSolidSphere(1.0, 16, 16); - glPopMatrix(); - -/* draw sphere in third row, second column - * colored ambient, diffuse and specular reflection; low shininess - */ - glPushMatrix(); - glTranslatef (-1.25, -3.0, 0.0); - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); - glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); - glutSolidSphere(1.0, 16, 16); - glPopMatrix(); - -/* draw sphere in third row, third column - * colored ambient, diffuse and specular reflection; high shininess - */ - glPushMatrix(); - glTranslatef (1.25, -3.0, 0.0); - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); - glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); - glutSolidSphere(1.0, 16, 16); - glPopMatrix(); - -/* draw sphere in third row, fourth column - * colored ambient and diffuse reflection; emission; no specular - */ - glPushMatrix(); - glTranslatef (3.75, -3.0, 0.0); - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); - glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); - glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); - glutSolidSphere(1.0, 16, 16); - glPopMatrix(); - - glFlush(); -} - -static void myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= (h * 2)) - 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), - 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, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (600, 450); - glutCreateWindow(argv[0]); - myinit(); - glutReshapeFunc(myReshape); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/minmax.c b/progs/redbook/minmax.c deleted file mode 100644 index 2c1356c9de4..00000000000 --- a/progs/redbook/minmax.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * minmax.c - * Determine the minimum and maximum values of a group of pixels. - * This demonstrates use of the glMinmax() call. - */ -#include <GL/glew.h> -#include <GL/glut.h> -#include <assert.h> -#include <stdlib.h> -#include <stdio.h> - - -static GLubyte *pixels; -static GLsizei width, height; - - -static GLuint bswap(GLuint x) -{ - const GLuint ui = 1; - const GLubyte *ubp = (const GLubyte *) &ui; - if (*ubp == 1) { - /* we're on little endiang so byteswap x */ - GLsizei y = ((x >> 24) - | ((x >> 8) & 0xff00) - | ((x << 8) & 0xff0000) - | ((x << 24) & 0xff000000)); - return y; - } - else { - return x; - } -} - - -static GLubyte * -readImage( const char* filename, GLsizei* width, GLsizei *height ) -{ - int n; - GLubyte* pixels; - size_t num_read; - - FILE* infile = fopen( filename, "rb" ); - - if ( !infile ) { - fprintf( stderr, "Unable to open file '%s'\n", filename ); - return NULL; - } - - num_read = fread( width, sizeof( GLsizei ), 1, infile ); - assert(num_read == 1); - num_read = fread( height, sizeof( GLsizei ), 1, infile ); - assert(num_read == 1); - - *width = bswap(*width); - *height = bswap(*height); - - n = 3 * (*width) * (*height); - - pixels = (GLubyte *) malloc( n * sizeof( GLubyte )); - if ( !pixels ) { - fprintf( stderr, "Unable to malloc() bytes for pixels\n" ); - fclose( infile ); - return NULL; - } - - num_read = fread( pixels, sizeof( GLubyte ), n, infile ); - assert(num_read == n); - - fclose( infile ); - - return pixels; -} - -static void init(void) -{ - if (!glutExtensionSupported("GL_ARB_imaging")) { - fprintf(stderr, "Sorry, this program requires GL_ARB_imaging.\n"); - exit(1); - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glClearColor(0.0, 0.0, 0.0, 0.0); - - glMinmax(GL_MINMAX, GL_RGB, GL_FALSE); - glEnable(GL_MINMAX); -} - -static void display(void) -{ - GLubyte values[6]; - - glClear(GL_COLOR_BUFFER_BIT); - glRasterPos2i(1, 1); - glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels); - glFlush(); - - glGetMinmax(GL_MINMAX, GL_TRUE, GL_RGB, GL_UNSIGNED_BYTE, values); - printf(" Red : min = %d max = %d\n", values[0], values[3]); - printf(" Green : min = %d max = %d\n", values[1], values[4]); - printf(" Blue : min = %d max = %d\n", values[2], values[5]); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, w, 0, h, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); -} - -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - } -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - pixels = readImage("leeds.bin", &width, &height); - - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize(width, height); - glutInitWindowPosition(100, 100); - glutCreateWindow(argv[0]); - glewInit(); - init(); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutDisplayFunc(display); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/mipmap.c b/progs/redbook/mipmap.c deleted file mode 100644 index dadde055bef..00000000000 --- a/progs/redbook/mipmap.c +++ /dev/null @@ -1,178 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* mipmap.c - * This program demonstrates using mipmaps for texture maps. - * To overtly show the effect of mipmaps, each mipmap reduction - * level has a solidly colored, contrasting texture image. - * Thus, the quadrilateral which is drawn is drawn with several - * different colors. - */ -#include <stdlib.h> -#include <GL/glut.h> - -GLubyte mipmapImage32[32][32][3]; -GLubyte mipmapImage16[16][16][3]; -GLubyte mipmapImage8[8][8][3]; -GLubyte mipmapImage4[4][4][3]; -GLubyte mipmapImage2[2][2][3]; -GLubyte mipmapImage1[1][1][3]; - -static void makeImages(void) -{ - int i, j; - - for (i = 0; i < 32; i++) { - for (j = 0; j < 32; j++) { - mipmapImage32[i][j][0] = 255; - mipmapImage32[i][j][1] = 255; - mipmapImage32[i][j][2] = 0; - } - } - for (i = 0; i < 16; i++) { - for (j = 0; j < 16; j++) { - mipmapImage16[i][j][0] = 255; - mipmapImage16[i][j][1] = 0; - mipmapImage16[i][j][2] = 255; - } - } - for (i = 0; i < 8; i++) { - for (j = 0; j < 8; j++) { - mipmapImage8[i][j][0] = 255; - mipmapImage8[i][j][1] = 0; - mipmapImage8[i][j][2] = 0; - } - } - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - mipmapImage4[i][j][0] = 0; - mipmapImage4[i][j][1] = 255; - mipmapImage4[i][j][2] = 0; - } - } - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++) { - mipmapImage2[i][j][0] = 0; - mipmapImage2[i][j][1] = 0; - mipmapImage2[i][j][2] = 255; - } - } - mipmapImage1[0][0][0] = 255; - mipmapImage1[0][0][1] = 255; - mipmapImage1[0][0][2] = 255; -} - -static void myinit(void) -{ - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - glShadeModel(GL_FLAT); - - glTranslatef(0.0, 0.0, -3.6); - makeImages(); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, 3, 32, 32, 0, - GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage32[0][0][0]); - glTexImage2D(GL_TEXTURE_2D, 1, 3, 16, 16, 0, - GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage16[0][0][0]); - glTexImage2D(GL_TEXTURE_2D, 2, 3, 8, 8, 0, - GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage8[0][0][0]); - glTexImage2D(GL_TEXTURE_2D, 3, 3, 4, 4, 0, - GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage4[0][0][0]); - glTexImage2D(GL_TEXTURE_2D, 4, 3, 2, 2, 0, - GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage2[0][0][0]); - glTexImage2D(GL_TEXTURE_2D, 5, 3, 1, 1, 0, - GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage1[0][0][0]); - 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, - GL_NEAREST_MIPMAP_NEAREST); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); - glEnable(GL_TEXTURE_2D); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); - glTexCoord2f(0.0, 8.0); glVertex3f(-2.0, 1.0, 0.0); - glTexCoord2f(8.0, 8.0); glVertex3f(2000.0, 1.0, -6000.0); - glTexCoord2f(8.0, 0.0); glVertex3f(2000.0, -1.0, -6000.0); - glEnd(); - glFlush(); -} - -static void myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0); - glMatrixMode(GL_MODELVIEW); - 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); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (500, 500); - glutCreateWindow (argv[0]); - myinit(); - glutReshapeFunc (myReshape); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/model.c b/progs/redbook/model.c deleted file mode 100644 index f7c92f4f87c..00000000000 --- a/progs/redbook/model.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * model.c - * This program demonstrates modeling transformations - */ -#include <GL/glut.h> -#include <stdlib.h> - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_FLAT); -} - -static void draw_triangle(void) -{ - glBegin (GL_LINE_LOOP); - glVertex2f(0.0, 25.0); - glVertex2f(25.0, -25.0); - glVertex2f(-25.0, -25.0); - glEnd(); -} - -static void display(void) -{ - glClear (GL_COLOR_BUFFER_BIT); - glColor3f (1.0, 1.0, 1.0); - - glLoadIdentity (); - glColor3f (1.0, 1.0, 1.0); - draw_triangle (); - - glEnable (GL_LINE_STIPPLE); - glLineStipple (1, 0xF0F0); - glLoadIdentity (); - glTranslatef (-20.0, 0.0, 0.0); - draw_triangle (); - - glLineStipple (1, 0xF00F); - glLoadIdentity (); - glScalef (1.5, 0.5, 1.0); - draw_triangle (); - - glLineStipple (1, 0x8888); - glLoadIdentity (); - glRotatef (90.0, 0.0, 0.0, 1.0); - draw_triangle (); - glDisable (GL_LINE_STIPPLE); - - glFlush (); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - if (w <= h) - glOrtho (-50.0, 50.0, -50.0*(GLfloat)h/(GLfloat)w, - 50.0*(GLfloat)h/(GLfloat)w, -1.0, 1.0); - else - glOrtho (-50.0*(GLfloat)w/(GLfloat)h, - 50.0*(GLfloat)w/(GLfloat)h, -50.0, 50.0, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/movelight.c b/progs/redbook/movelight.c deleted file mode 100644 index 93758a222a4..00000000000 --- a/progs/redbook/movelight.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * movelight.c - * This program demonstrates when to issue lighting and - * transformation commands to render a model with a light - * which is moved by a modeling transformation (rotate or - * translate). The light position is reset after the modeling - * transformation is called. The eye position does not change. - * - * A sphere is drawn using a grey material characteristic. - * A single light source illuminates the object. - * - * Interaction: pressing the left mouse button alters - * the modeling transformation (x rotation) by 30 degrees. - * The scene is then redrawn with the light in a new position. - */ -#include <GL/glut.h> -#include <stdlib.h> - -static int spin = 0; - -/* Initialize material property, light source, lighting model, - * and depth buffer. - */ -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_SMOOTH); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); -} - -/* Here is where the light position is reset after the modeling - * transformation (glRotated) is called. This places the - * light at a new position in world coordinates. The cube - * represents the position of the light. - */ -static void display(void) -{ - GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 }; - - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glPushMatrix (); - gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); - - glPushMatrix (); - glRotated ((GLdouble) spin, 1.0, 0.0, 0.0); - glLightfv (GL_LIGHT0, GL_POSITION, position); - - glTranslated (0.0, 0.0, 1.5); - glDisable (GL_LIGHTING); - glColor3f (0.0, 1.0, 1.0); - glutWireCube (0.1); - glEnable (GL_LIGHTING); - glPopMatrix (); - - glutSolidTorus (0.275, 0.85, 8, 15); - glPopMatrix (); - glFlush (); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity(); - gluPerspective(40.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED2 */ -static void mouse(int button, int state, int x, int y) -{ - switch (button) { - case GLUT_LEFT_BUTTON: - if (state == GLUT_DOWN) { - spin = (spin + 30) % 360; - glutPostRedisplay(); - } - break; - default: - break; - } -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutMouseFunc(mouse); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/multisamp.c b/progs/redbook/multisamp.c deleted file mode 100644 index 38bd572fc13..00000000000 --- a/progs/redbook/multisamp.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * multisamp.c - * This program draws shows how to use multisampling to - * draw anti-aliased geometric primitives. The same - * display list, a pinwheel of triangles and lines of - * varying widths, is rendered twice. Multisampling is - * enabled when the left side is drawn. Multisampling is - * disabled when the right side is drawn. - * - * Pressing the 'b' key toggles drawing of the checkerboard - * background. Antialiasing is sometimes easier to see - * when objects are rendered over a contrasting background. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -static int bgtoggle = 1; - -/* - * Print out state values related to multisampling. - * Create display list with "pinwheel" of lines and - * triangles. - */ -static void init(void) -{ - static GLint buf[1], sbuf[1]; - int i, j; - - glClearColor(0.0, 0.0, 0.0, 0.0); - glGetIntegerv (GL_SAMPLE_BUFFERS_ARB, buf); - printf ("number of sample buffers is %d\n", buf[0]); - glGetIntegerv (GL_SAMPLES_ARB, sbuf); - printf ("number of samples is %d\n", sbuf[0]); - - glNewList (1, GL_COMPILE); - for (i = 0; i < 19; i++) { - glPushMatrix(); - glRotatef(360.0*(float)i/19.0, 0.0, 0.0, 1.0); - glColor3f (1.0, 1.0, 1.0); - glLineWidth((i%3)+1.0); - glBegin (GL_LINES); - glVertex2f (0.25, 0.05); - glVertex2f (0.9, 0.2); - glEnd (); - glColor3f (0.0, 1.0, 1.0); - glBegin (GL_TRIANGLES); - glVertex2f (0.25, 0.0); - glVertex2f (0.9, 0.0); - glVertex2f (0.875, 0.10); - glEnd (); - glPopMatrix(); - } - glEndList (); - - glNewList (2, GL_COMPILE); - glColor3f (1.0, 0.5, 0.0); - glBegin (GL_QUADS); - for (i = 0; i < 16; i++) { - for (j = 0; j < 16; j++) { - if (((i + j) % 2) == 0) { - glVertex2f (-2.0 + (i * 0.25), -2.0 + (j * 0.25)); - glVertex2f (-2.0 + (i * 0.25), -1.75 + (j * 0.25)); - glVertex2f (-1.75 + (i * 0.25), -1.75 + (j * 0.25)); - glVertex2f (-1.75 + (i * 0.25), -2.0 + (j * 0.25)); - } - } - } - glEnd (); - glEndList (); -} - -/* Draw two sets of primitives, so that you can - * compare the user of multisampling against its absence. - * - * This code enables antialiasing and draws one display list - * and disables and draws the other display list - */ -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - if (bgtoggle) - glCallList (2); - - glEnable (GL_MULTISAMPLE_ARB); - glPushMatrix(); - glTranslatef (-1.0, 0.0, 0.0); - glCallList (1); - glPopMatrix(); - - glDisable (GL_MULTISAMPLE_ARB); - glPushMatrix(); - glTranslatef (1.0, 0.0, 0.0); - glCallList (1); - glPopMatrix(); - glutSwapBuffers(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= (2 * h)) - gluOrtho2D (-2.0, 2.0, - -2.0*(GLfloat)h/(GLfloat)w, 2.0*(GLfloat)h/(GLfloat)w); - else - gluOrtho2D (-2.0*(GLfloat)w/(GLfloat)h, - 2.0*(GLfloat)w/(GLfloat)h, -2.0, 2.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 'b': - case 'B': - bgtoggle = !bgtoggle; - glutPostRedisplay(); - break; - case 27: /* Escape Key */ - exit(0); - default: - break; - } -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_MULTISAMPLE); - glutInitWindowSize (600, 300); - glutCreateWindow (argv[0]); - init(); - glutReshapeFunc (reshape); - glutKeyboardFunc (keyboard); - glutDisplayFunc (display); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/multitex.c b/progs/redbook/multitex.c deleted file mode 100644 index 118f0ea77ee..00000000000 --- a/progs/redbook/multitex.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* multitex.c - */ -#include <GL/glew.h> -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - - -static GLubyte texels0[32][32][4]; -static GLubyte texels1[16][16][4]; - -static void makeCheckImages(void) -{ - int i, j; - - for (i = 0; i < 32; i++) { - for (j = 0; j < 32; j++) { - texels0[i][j][0] = (GLubyte) (255 * i / 31); - texels0[i][j][1] = (GLubyte) (255 * j / 31); - texels0[i][j][2] = (GLubyte) (i*j)/255; - texels0[i][j][3] = (GLubyte) 255; - } - } - - for (i = 0; i < 16; i++) { - for (j = 0; j < 16; j++) { - texels1[i][j][0] = (GLubyte) 255; - texels1[i][j][1] = (GLubyte) (255 * i / 15); - texels1[i][j][2] = (GLubyte) (255 * j / 15); - texels1[i][j][3] = (GLubyte) 255; - } - } -} - -static void init(void) -{ - GLuint texNames[2]; - - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel(GL_FLAT); - glEnable(GL_DEPTH_TEST); - - makeCheckImages(); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glGenTextures(2, texNames); - glBindTexture(GL_TEXTURE_2D, texNames[0]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, - GL_UNSIGNED_BYTE, texels0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - - glBindTexture(GL_TEXTURE_2D, texNames[1]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, - GL_UNSIGNED_BYTE, texels1); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - /* Use the two texture objects to define two texture units - * for use in multitexturing */ - glActiveTextureARB (GL_TEXTURE0_ARB); - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texNames[0]); - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glMatrixMode (GL_TEXTURE); - glLoadIdentity(); - glTranslatef(0.5f, 0.5f, 0.0f); - glRotatef(45.0f, 0.0f, 0.0f, 1.0f); - glTranslatef(-0.5f, -0.5f, 0.0f); - glMatrixMode (GL_MODELVIEW); - glActiveTextureARB (GL_TEXTURE1_ARB); - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texNames[1]); - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glBegin(GL_TRIANGLES); - glMultiTexCoord2fARB (GL_TEXTURE0_ARB, 0.0, 0.0); - glMultiTexCoord2fARB (GL_TEXTURE1_ARB, 1.0, 0.0); - glVertex2f(0.0, 0.0); - glMultiTexCoord2fARB (GL_TEXTURE0_ARB, 0.5, 1.0); - glMultiTexCoord2fARB (GL_TEXTURE1_ARB, 0.5, 0.0); - glVertex2f(50.0, 100.0); - glMultiTexCoord2fARB (GL_TEXTURE0_ARB, 1.0, 0.0); - glMultiTexCoord2fARB (GL_TEXTURE1_ARB, 1.0, 1.0); - glVertex2f(100.0, 0.0); - glEnd(); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - gluOrtho2D(0.0, 100.0, 0.0, 100.0 * (GLdouble)h/(GLdouble)w); - else - gluOrtho2D(0.0, 100.0 * (GLdouble)w/(GLdouble)h, 0.0, 100.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(250, 250); - glutInitWindowPosition(100, 100); - glutCreateWindow(argv[0]); - glewInit(); - init(); - glutReshapeFunc(reshape); - glutDisplayFunc(display); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/mvarray.c b/progs/redbook/mvarray.c deleted file mode 100644 index 1022723ad94..00000000000 --- a/progs/redbook/mvarray.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * mvarray.c - * This program demonstrates multiple vertex arrays, - * specifically the OpenGL routine glMultiDrawElements(). - */ - -#include <GL/glew.h> -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -#ifdef GL_VERSION_1_3 - -static void setupPointer(void) -{ - static GLint vertices[] = {25, 25, - 75, 75, - 100, 125, - 150, 75, - 200, 175, - 250, 150, - 300, 125, - 100, 200, - 150, 250, - 200, 225, - 250, 300, - 300, 250}; - - glEnableClientState (GL_VERTEX_ARRAY); - glVertexPointer (2, GL_INT, 0, vertices); -} - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_SMOOTH); - setupPointer (); -} - -static void display(void) -{ - static GLubyte oneIndices[] = {0, 1, 2, 3, 4, 5, 6}; - static GLubyte twoIndices[] = {1, 7, 8, 9, 10, 11}; - static GLsizei count[] = {7, 6}; - static GLvoid * indices[2] = {oneIndices, twoIndices}; - - glClear (GL_COLOR_BUFFER_BIT); - glColor3f (1.0, 1.0, 1.0); - glMultiDrawElementsEXT (GL_LINE_STRIP, count, GL_UNSIGNED_BYTE, - (const GLvoid **) indices, 2); - glFlush (); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h); -} - -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (350, 350); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - glewInit(); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} -#else -int main(int argc, char** argv) -{ - fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0.\n"); - fprintf (stderr, "If your implementation of OpenGL Version 1.0 has the right extensions,\n"); - fprintf (stderr, "you may be able to modify this program to make it run.\n"); - return 0; -} -#endif diff --git a/progs/redbook/nurbs.c b/progs/redbook/nurbs.c deleted file mode 100644 index fe03ce667ed..00000000000 --- a/progs/redbook/nurbs.c +++ /dev/null @@ -1,190 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * nurbs.c - * This program shows a NURBS (Non-uniform rational B-splines) - * surface, shaped like a heart. - */ -#include <stdlib.h> -#include <GL/glut.h> - -#define S_NUMPOINTS 13 -#define S_ORDER 3 -#define S_NUMKNOTS (S_NUMPOINTS + S_ORDER) -#define T_NUMPOINTS 3 -#define T_ORDER 3 -#define T_NUMKNOTS (T_NUMPOINTS + T_ORDER) -#define SQRT2 1.41421356237309504880 - -/* initialized local data */ - -GLfloat sknots[S_NUMKNOTS] = - {-1.0, -1.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, - 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 9.0, 9.0}; -GLfloat tknots[T_NUMKNOTS] = {1.0, 1.0, 1.0, 2.0, 2.0, 2.0}; - -GLfloat ctlpoints[S_NUMPOINTS][T_NUMPOINTS][4] = { -{ {4.,2.,2.,1.},{4.,1.6,2.5,1.},{4.,2.,3.0,1.} }, -{ {5.,4.,2.,1.},{5.,4.,2.5,1.},{5.,4.,3.0,1.} }, -{ {6.,5.,2.,1.},{6.,5.,2.5,1.},{6.,5.,3.0,1.} }, -{ {SQRT2*6.,SQRT2*6.,SQRT2*2.,SQRT2}, - {SQRT2*6.,SQRT2*6.,SQRT2*2.5,SQRT2}, - {SQRT2*6.,SQRT2*6.,SQRT2*3.0,SQRT2} }, -{ {5.2,6.7,2.,1.},{5.2,6.7,2.5,1.},{5.2,6.7,3.0,1.} }, -{ {SQRT2*4.,SQRT2*6.,SQRT2*2.,SQRT2}, - {SQRT2*4.,SQRT2*6.,SQRT2*2.5,SQRT2}, - {SQRT2*4.,SQRT2*6.,SQRT2*3.0,SQRT2} }, -{ {4.,5.2,2.,1.},{4.,4.6,2.5,1.},{4.,5.2,3.0,1.} }, -{ {SQRT2*4.,SQRT2*6.,SQRT2*2.,SQRT2}, - {SQRT2*4.,SQRT2*6.,SQRT2*2.5,SQRT2}, - {SQRT2*4.,SQRT2*6.,SQRT2*3.0,SQRT2} }, -{ {2.8,6.7,2.,1.},{2.8,6.7,2.5,1.},{2.8,6.7,3.0,1.} }, -{ {SQRT2*2.,SQRT2*6.,SQRT2*2.,SQRT2}, - {SQRT2*2.,SQRT2*6.,SQRT2*2.5,SQRT2}, - {SQRT2*2.,SQRT2*6.,SQRT2*3.0,SQRT2} }, -{ {2.,5.,2.,1.},{2.,5.,2.5,1.},{2.,5.,3.0,1.} }, -{ {3.,4.,2.,1.},{3.,4.,2.5,1.},{3.,4.,3.0,1.} }, -{ {4.,2.,2.,1.},{4.,1.6,2.5,1.},{4.,2.,3.0,1.} } -}; - -GLUnurbsObj *theNurb; - -/* Initialize material property, light source, lighting model, - * and depth buffer. - */ -static void myinit(void) -{ - GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat mat_diffuse[] = { 1.0, 0.2, 1.0, 1.0 }; - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat mat_shininess[] = { 50.0 }; - - GLfloat light0_position[] = { 1.0, 0.1, 1.0, 0.0 }; - GLfloat light1_position[] = { -1.0, 0.1, 1.0, 0.0 }; - - GLfloat lmodel_ambient[] = { 0.3, 0.3, 0.3, 1.0 }; - - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); - glLightfv(GL_LIGHT0, GL_POSITION, light0_position); - glLightfv(GL_LIGHT1, GL_POSITION, light1_position); - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_LIGHT1); - glDepthFunc(GL_LESS); - glEnable(GL_DEPTH_TEST); - glEnable(GL_AUTO_NORMAL); - - theNurb = gluNewNurbsRenderer(); - - gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0); - gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix(); - glTranslatef (4., 4.5, 2.5); - glRotatef (220.0, 1., 0., 0.); - glRotatef (115.0, 0., 1., 0.); - glTranslatef (-4., -4.5, -2.5); - - gluBeginSurface(theNurb); - gluNurbsSurface(theNurb, - S_NUMKNOTS, sknots, - T_NUMKNOTS, tknots, - 4 * T_NUMPOINTS, - 4, - &ctlpoints[0][0][0], - S_ORDER, T_ORDER, - GL_MAP2_VERTEX_4); - gluEndSurface(theNurb); - - glPopMatrix(); - glFlush(); -} - -static void myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-1.0, 1.0, -1.5, 0.5, 0.8, 10.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - 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, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutCreateWindow (argv[0]); - 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 deleted file mode 100644 index 91d44a38c0a..00000000000 --- a/progs/redbook/pickdepth.c +++ /dev/null @@ -1,217 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * 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. - * Rectangles which are drawn under the cursor position - * are "picked." Pay special attention to the depth - * value range, which is returned. - */ -#include <stdlib.h> -#include <stdio.h> -#include <GL/glut.h> - -static void -myinit(void) -{ - glClearColor(0.0, 0.0, 0.0, 0.0); - glDepthFunc(GL_LESS); - glEnable(GL_DEPTH_TEST); - glShadeModel(GL_FLAT); - 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 - * each rectangle is drawn with a different z value. - */ -static void -drawRects(GLenum mode) -{ - if (mode == GL_SELECT) - glLoadName(1); - glBegin(GL_QUADS); - glColor3f(1.0, 1.0, 0.0); - glVertex3i(2, 0, 0); - glVertex3i(2, 6, 0); - glVertex3i(6, 6, 0); - glVertex3i(6, 0, 0); - glEnd(); - if (mode == GL_SELECT) - glLoadName(2); - glBegin(GL_QUADS); - glColor3f(0.0, 1.0, 1.0); - glVertex3i(3, 2, -1); - glVertex3i(3, 8, -1); - glVertex3i(8, 8, -1); - glVertex3i(8, 2, -1); - glEnd(); - if (mode == GL_SELECT) - glLoadName(3); - glBegin(GL_QUADS); - glColor3f(1.0, 0.0, 1.0); - glVertex3i(0, 2, -2); - glVertex3i(0, 7, -2); - glVertex3i(5, 7, -2); - glVertex3i(5, 2, -2); - glEnd(); -} - -/* processHits() prints out the contents of the - * selection array. - */ -static void -processHits(GLint hits, GLuint buffer[]) -{ - GLint i; - GLuint j, names, *ptr; - - printf("hits = %d\n", hits); - ptr = (GLuint *) buffer; - for (i = 0; i < hits; i++) { /* for each hit */ - names = *ptr; - printf(" number of names for hit = %d\n", names); - ptr++; - printf(" z1 is %g;", (float) *ptr/0xffffffff); - ptr++; - printf(" z2 is %g\n", (float) *ptr/0xffffffff); - ptr++; - printf(" the name is "); - for (j = 0; j < names; j++) { /* for each name */ - printf("%d ", *ptr); - ptr++; - } - printf("\n"); - } -} - -/* pickRects() sets up selection mode, name stack, - * and projection matrix for picking. Then the objects - * are drawn. - */ -#define BUFSIZE 512 - -static void -pickRects(int button, int state, int x, int y) -{ - GLuint selectBuf[BUFSIZE]; - GLint hits; - GLint viewport[4]; - - if (button != GLUT_LEFT_BUTTON || state != GLUT_DOWN) - return; - - glGetIntegerv(GL_VIEWPORT, viewport); - - glSelectBuffer(BUFSIZE, selectBuf); - (void) glRenderMode(GL_SELECT); - - glInitNames(); - glPushName(-1); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); -/* create 5x5 pixel picking region near cursor location */ - gluPickMatrix((GLdouble) x, (GLdouble) (viewport[3] - y), - 5.0, 5.0, viewport); - glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5); - drawRects(GL_SELECT); - glPopMatrix(); - glFlush(); - - hits = glRenderMode(GL_RENDER); - processHits(hits, selectBuf); -} - -static void -display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - drawRects(GL_RENDER); - glutSwapBuffers(); -} - -static void -myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5); - glMatrixMode(GL_MODELVIEW); - 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, - * RGBA display mode, depth buffer, and handle input events. - */ -int -main(int argc, char **argv) -{ - glutInitWindowSize(200, 200); - glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); - glutInit(&argc, argv); - glutCreateWindow(argv[0]); - myinit(); - glutMouseFunc(pickRects); - glutReshapeFunc(myReshape); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/picksquare.c b/progs/redbook/picksquare.c deleted file mode 100644 index cc092dbf538..00000000000 --- a/progs/redbook/picksquare.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * picksquare.c - * Use of multiple names and picking are demonstrated. - * A 3x3 grid of squares is drawn. When the left mouse - * button is pressed, all squares under the cursor position - * have their color changed. - */ -#include <stdlib.h> -#include <stdio.h> -#include <GL/glut.h> - -int board[3][3]; /* amount of color for each square */ - -/* Clear color value for every square on the board */ -static void init(void) -{ - int i, j; - for (i = 0; i < 3; i++) - for (j = 0; j < 3; j ++) - board[i][j] = 0; - glClearColor (0.0, 0.0, 0.0, 0.0); -} - -/* The nine squares are drawn. In selection mode, each - * square is given two names: one for the row and the - * other for the column on the grid. The color of each - * square is determined by its position on the grid, and - * the value in the board[][] array. - */ -static void drawSquares(GLenum mode) -{ - GLuint i, j; - for (i = 0; i < 3; i++) { - if (mode == GL_SELECT) - glLoadName (i); - for (j = 0; j < 3; j ++) { - if (mode == GL_SELECT) - glPushName (j); - glColor3f ((GLfloat) i/3.0, (GLfloat) j/3.0, - (GLfloat) board[i][j]/3.0); - glRecti (i, j, i+1, j+1); - if (mode == GL_SELECT) - glPopName (); - } - } -} - -/* processHits prints out the contents of the - * selection array. - */ -static void processHits (GLint hits, GLuint buffer[]) -{ - GLint i; - GLuint j, ii = 0, jj = 0, names, *ptr; - - printf ("hits = %d\n", hits); - ptr = (GLuint *) buffer; - for (i = 0; i < hits; i++) { /* for each hit */ - names = *ptr; - printf (" number of names for this hit = %d\n", names); ptr++; - printf(" z1 is %g;", (float) *ptr/0x7fffffff); ptr++; - printf(" z2 is %g\n", (float) *ptr/0x7fffffff); ptr++; - printf (" names are "); - for (j = 0; j < names; j++) { /* for each name */ - printf ("%d ", *ptr); - if (j == 0) /* set row and column */ - ii = *ptr; - else if (j == 1) - jj = *ptr; - ptr++; - } - printf ("\n"); - board[ii][jj] = (board[ii][jj] + 1) % 3; - } -} - -/* pickSquares() sets up selection mode, name stack, - * and projection matrix for picking. Then the - * objects are drawn. - */ -#define BUFSIZE 512 - -static void pickSquares(int button, int state, int x, int y) -{ - GLuint selectBuf[BUFSIZE]; - GLint hits; - GLint viewport[4]; - - if (button != GLUT_LEFT_BUTTON || state != GLUT_DOWN) - return; - - glGetIntegerv (GL_VIEWPORT, viewport); - - glSelectBuffer (BUFSIZE, selectBuf); - (void) glRenderMode (GL_SELECT); - - glInitNames(); - glPushName(0); - - glMatrixMode (GL_PROJECTION); - glPushMatrix (); - glLoadIdentity (); -/* create 5x5 pixel picking region near cursor location */ - gluPickMatrix ((GLdouble) x, (GLdouble) (viewport[3] - y), - 5.0, 5.0, viewport); - gluOrtho2D (0.0, 3.0, 0.0, 3.0); - drawSquares (GL_SELECT); - - glMatrixMode (GL_PROJECTION); - glPopMatrix (); - glFlush (); - - hits = glRenderMode (GL_RENDER); - processHits (hits, selectBuf); - glutPostRedisplay(); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - drawSquares (GL_RENDER); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluOrtho2D (0.0, 3.0, 0.0, 3.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -/* Main Loop */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (100, 100); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutReshapeFunc (reshape); - glutDisplayFunc(display); - glutMouseFunc (pickSquares); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/plane.c b/progs/redbook/plane.c deleted file mode 100644 index 2c2e2d24d93..00000000000 --- a/progs/redbook/plane.c +++ /dev/null @@ -1,171 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * plane.c - * This program demonstrates the use of local versus - * infinite lighting on a flat plane. - */ -#include <stdlib.h> -#include <GL/glut.h> - -/* Initialize material property, light source, and lighting model. - */ -static void myinit(void) -{ - GLfloat mat_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; -/* mat_specular and mat_shininess are NOT default values */ - GLfloat mat_diffuse[] = { 0.4, 0.4, 0.4, 1.0 }; - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat mat_shininess[] = { 15.0 }; - - GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; - GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat lmodel_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; - - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); - glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); - glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); - glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glDepthFunc(GL_LESS); - glEnable(GL_DEPTH_TEST); -} - -static void drawPlane(void) -{ - glBegin (GL_QUADS); - glNormal3f (0.0, 0.0, 1.0); - glVertex3f (-1.0, -1.0, 0.0); - glVertex3f (0.0, -1.0, 0.0); - glVertex3f (0.0, 0.0, 0.0); - glVertex3f (-1.0, 0.0, 0.0); - - glNormal3f (0.0, 0.0, 1.0); - glVertex3f (0.0, -1.0, 0.0); - glVertex3f (1.0, -1.0, 0.0); - glVertex3f (1.0, 0.0, 0.0); - glVertex3f (0.0, 0.0, 0.0); - - glNormal3f (0.0, 0.0, 1.0); - glVertex3f (0.0, 0.0, 0.0); - glVertex3f (1.0, 0.0, 0.0); - glVertex3f (1.0, 1.0, 0.0); - glVertex3f (0.0, 1.0, 0.0); - - glNormal3f (0.0, 0.0, 1.0); - glVertex3f (0.0, 0.0, 0.0); - glVertex3f (0.0, 1.0, 0.0); - glVertex3f (-1.0, 1.0, 0.0); - glVertex3f (-1.0, 0.0, 0.0); - glEnd(); -} - -static void display (void) -{ - GLfloat infinite_light[] = { 1.0, 1.0, 1.0, 0.0 }; - GLfloat local_light[] = { 1.0, 1.0, 1.0, 1.0 }; - - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix (); - glTranslatef (-1.5, 0.0, 0.0); - glLightfv (GL_LIGHT0, GL_POSITION, infinite_light); - drawPlane (); - glPopMatrix (); - - glPushMatrix (); - glTranslatef (1.5, 0.0, 0.0); - glLightfv (GL_LIGHT0, GL_POSITION, local_light); - drawPlane (); - glPopMatrix (); - glFlush (); -} - -static 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, - 1.5*(GLdouble)h/(GLdouble)w, -10.0, 10.0); - 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, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (500, 200); - glutCreateWindow (argv[0]); - myinit(); - glutReshapeFunc (myReshape); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/planet.c b/progs/redbook/planet.c deleted file mode 100644 index cc428b4e427..00000000000 --- a/progs/redbook/planet.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * planet.c - * This program shows how to composite modeling transformations - * to draw translated and rotated models. - * Interaction: pressing the d and y keys (day and year) - * alters the rotation of the planet around the sun. - */ -#include <GL/glut.h> -#include <stdlib.h> - -static int year = 0, day = 0; - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_FLAT); -} - -static void display(void) -{ - glClear (GL_COLOR_BUFFER_BIT); - glColor3f (1.0, 1.0, 1.0); - - glPushMatrix(); - glutWireSphere(1.0, 20, 16); /* draw sun */ - glRotatef ((GLfloat) year, 0.0, 1.0, 0.0); - glTranslatef (2.0, 0.0, 0.0); - glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); - glutWireSphere(0.2, 10, 8); /* draw smaller planet */ - glPopMatrix(); - glutSwapBuffers(); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); -} - -/* ARGSUSED1 */ -static void keyboard (unsigned char key, int x, int y) -{ - switch (key) { - case 'd': - day = (day + 10) % 360; - glutPostRedisplay(); - break; - case 'D': - day = (day - 10) % 360; - glutPostRedisplay(); - break; - case 'y': - year = (year + 5) % 360; - glutPostRedisplay(); - break; - case 'Y': - year = (year - 5) % 360; - glutPostRedisplay(); - break; - case 27: - exit(0); - break; - default: - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/pointp.c b/progs/redbook/pointp.c deleted file mode 100644 index b273623d856..00000000000 --- a/progs/redbook/pointp.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * pointp.c - * This program demonstrates point parameters and their effect - * on point primitives. - * 250 points are randomly generated within a 10 by 10 by 40 - * region, centered at the origin. In some modes (including the - * default), points that are closer to the viewer will appear larger. - * - * Pressing the 'l', 'q', and 'c' keys switch the point - * parameters attenuation mode to linear, quadratic, or constant, - * respectively. - * Pressing the 'f' and 'b' keys move the viewer forward - * and backwards. In either linear or quadratic attenuation - * mode, the distance from the viewer to the point will change - * the size of the point primitive. - * Pressing the '+' and '-' keys will change the current point - * size. In this program, the point size is bounded, so it - * will not get less than 2.0, nor greater than GL_POINT_SIZE_MAX. - */ - -#include <GL/glew.h> -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -static GLfloat psize = 7.0; -static GLfloat pmax[1]; -static GLfloat constant[3] = {1.0, 0.0, 0.0}; -static GLfloat linear[3] = {0.0, 0.12, 0.0}; -static GLfloat quadratic[3] = {0.0, 0.0, 0.01}; - -static void init(void) -{ - int i; - - srand (12345); - - glNewList(1, GL_COMPILE); - glBegin (GL_POINTS); - for (i = 0; i < 250; i++) { - glColor3f (1.0, ((rand()/(float) RAND_MAX) * 0.5) + 0.5, - rand()/(float) RAND_MAX); -/* randomly generated vertices: - -5 < x < 5; -5 < y < 5; -5 < z < -45 */ - glVertex3f ( ((rand()/(float)RAND_MAX) * 10.0) - 5.0, - ((rand()/(float)RAND_MAX) * 10.0) - 5.0, - ((rand()/(float)RAND_MAX) * 40.0) - 45.0); - } - glEnd(); - glEndList(); - - glEnable(GL_DEPTH_TEST); - glEnable(GL_POINT_SMOOTH); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glPointSize(psize); - glGetFloatv(GL_POINT_SIZE_MAX_EXT, pmax); - - glPointParameterfvEXT (GL_DISTANCE_ATTENUATION_EXT, linear); - glPointParameterfEXT (GL_POINT_FADE_THRESHOLD_SIZE_EXT, 2.0); -} - -static void display(void) -{ - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glCallList (1); - glutSwapBuffers (); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - gluPerspective (35.0, 1.0, 0.25, 200.0); - glMatrixMode (GL_MODELVIEW); - glTranslatef (0.0, 0.0, -10.0); -} - -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 'b': - glMatrixMode (GL_MODELVIEW); - glTranslatef (0.0, 0.0, -0.5); - glutPostRedisplay(); - break; - case 'c': - glPointParameterfvEXT (GL_DISTANCE_ATTENUATION_EXT, constant); - glutPostRedisplay(); - break; - case 'f': - glMatrixMode (GL_MODELVIEW); - glTranslatef (0.0, 0.0, 0.5); - glutPostRedisplay(); - break; - case 'l': - glPointParameterfvEXT (GL_DISTANCE_ATTENUATION_EXT, linear); - glutPostRedisplay(); - break; - case 'q': - glPointParameterfvEXT (GL_DISTANCE_ATTENUATION_EXT, quadratic); - glutPostRedisplay(); - break; - case '+': - if (psize < (pmax[0] + 1.0)) - psize = psize + 1.0; - glPointSize (psize); - glutPostRedisplay(); - break; - case '-': - if (psize >= 2.0) - psize = psize - 1.0; - glPointSize (psize); - glutPostRedisplay(); - break; - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - glewInit(); - init (); - glutDisplayFunc (display); - glutReshapeFunc (reshape); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/polyoff.c b/progs/redbook/polyoff.c deleted file mode 100644 index 0e0ce86ec91..00000000000 --- a/progs/redbook/polyoff.c +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * polyoff.c - * This program demonstrates polygon offset to draw a shaded - * polygon and its wireframe counterpart without ugly visual - * artifacts ("stitching"). - */ -#include <GL/glut.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#ifdef GL_VERSION_1_1 -GLuint list; -GLint fill = 1; -GLfloat spinx = 0; -GLfloat spiny = 0; -GLfloat tdist = 0.0; -GLfloat polyfactor = 1.0; -GLfloat polyunits = 1.0; -GLboolean doubleBuffer; - - -/* display() draws two spheres, one with a gray, diffuse material, - * the other sphere with a magenta material with a specular highlight. - */ -static void display (void) -{ - GLfloat gray[] = { 0.8, 0.8, 0.8, 1.0 }; - GLfloat black[] = { 0.0, 0.0, 0.0, 1.0 }; - - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glPushMatrix (); - glTranslatef (0.0, 0.0, tdist); - glRotatef ((GLfloat) spinx, 1.0, 0.0, 0.0); - glRotatef ((GLfloat) spiny, 0.0, 1.0, 0.0); - - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, gray); - glMaterialfv(GL_FRONT, GL_SPECULAR, black); - glMaterialf(GL_FRONT, GL_SHININESS, 0.0); - if (fill) { - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(polyfactor, polyunits); - glCallList (list); - glDisable(GL_POLYGON_OFFSET_FILL); - } - - glDisable(GL_LIGHTING); - glDisable(GL_LIGHT0); - glColor3f (1.0, 1.0, 1.0); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glPolygonOffset(-polyfactor, -polyunits); - if (!fill) glEnable(GL_POLYGON_OFFSET_LINE); - glCallList (list); - glDisable(GL_POLYGON_OFFSET_LINE); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - - if (!fill) { - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glCallList (list); - } - - glPopMatrix (); - glFlush (); - if (doubleBuffer) glutSwapBuffers(); -} - -/* specify initial properties - * create display list with sphere - * initialize lighting and depth buffer - */ -static void gfxinit (void) -{ - GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; - GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; - - GLfloat global_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; - - glClearColor (0.0, 0.0, 0.0, 1.0); - - list = glGenLists(1); - glNewList (list, GL_COMPILE); - glutSolidSphere(1.0, 20, 12); - glEndList (); - - glEnable(GL_DEPTH_TEST); - - glLightfv (GL_LIGHT0, GL_AMBIENT, light_ambient); - glLightfv (GL_LIGHT0, GL_DIFFUSE, light_diffuse); - glLightfv (GL_LIGHT0, GL_SPECULAR, light_specular); - glLightfv (GL_LIGHT0, GL_POSITION, light_position); - glLightModelfv (GL_LIGHT_MODEL_AMBIENT, global_ambient); -} - -/* call when window is resized */ -static void reshape(int width, int height) -{ - glViewport (0, 0, width, height); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - gluPerspective(45.0, (GLdouble)width/(GLdouble)height, - 1.0, 10.0); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); -} - -static void Benchmark( float xdiff, float ydiff ) -{ - int startTime, endTime; - int draws; - double seconds, fps; - - printf("Benchmarking...\n"); - fflush(stdout); - - draws = 0; - startTime = glutGet(GLUT_ELAPSED_TIME); - spinx = spiny = 0.0; - do { - spinx += xdiff; - spiny += ydiff; - display(); - draws++; - endTime = glutGet(GLUT_ELAPSED_TIME); - } while (endTime - startTime < 5000); /* 5 seconds */ - - /* Results */ - seconds = (double) (endTime - startTime) / 1000.0; - fps = draws / seconds; - printf("Result: fps: %g\n", fps); - fflush(stdout); -} - - -/* call when mouse button is pressed */ -/* ARGSUSED2 */ -static void mouse(int button, int state, int x, int y) { - switch (button) { - case GLUT_LEFT_BUTTON: - switch (state) { - case GLUT_DOWN: - spinx += 5; - glutPostRedisplay(); - break; - default: - break; - } - break; - case GLUT_MIDDLE_BUTTON: - switch (state) { - case GLUT_DOWN: - spiny += 5; - glutPostRedisplay(); - break; - default: - break; - } - break; - case GLUT_RIGHT_BUTTON: - switch (state) { - case GLUT_UP: - exit(0); - break; - default: - break; - } - break; - default: - break; - } -} - -/* ARGSUSED1 */ -static void keyboard (unsigned char key, int x, int y) -{ - switch (key) { - case 't': - if (tdist < 4.0) { - tdist = (tdist + 0.5); - glutPostRedisplay(); - } - break; - case 'T': - if (tdist > -5.0) { - tdist = (tdist - 0.5); - glutPostRedisplay(); - } - break; - case 'F': - polyfactor = polyfactor + 0.1; - printf ("polyfactor is %f\n", polyfactor); - glutPostRedisplay(); - break; - case 'f': - polyfactor = polyfactor - 0.1; - printf ("polyfactor is %f\n", polyfactor); - glutPostRedisplay(); - break; - case 'U': - polyunits = polyunits + 1.0; - printf ("polyunits is %f\n", polyunits); - glutPostRedisplay(); - break; - case 'u': - polyunits = polyunits - 1.0; - printf ("polyunits is %f\n", polyunits); - glutPostRedisplay(); - break; - case 'b': - Benchmark(5.0, 0); - break; - case 'B': - Benchmark(0, 5.0); - break; - case ' ': - fill = !fill; - printf ("fill/line: %d\n", fill); - glutPostRedisplay(); - break; - case 27: /* Escape */ - exit(0); - break; - default: - break; - } - fflush(stdout); -} - -static GLenum Args(int argc, char **argv) -{ - GLint i; - - doubleBuffer = GL_FALSE; - - for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "-sb") == 0) { - doubleBuffer = GL_FALSE; - } else if (strcmp(argv[i], "-db") == 0) { - doubleBuffer = GL_TRUE; - } else { - printf("%s (Bad option).\n", argv[i]); - return GL_FALSE; - } - } - return GL_TRUE; -} - - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - GLuint type; - glutInit(&argc, argv); - - Args(argc, argv); - - type = GLUT_DEPTH | GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - - glutInitDisplayMode(type); - glutCreateWindow("polyoff"); - glutReshapeFunc(reshape); - glutDisplayFunc(display); - glutMouseFunc(mouse); - glutKeyboardFunc(keyboard); - gfxinit(); - glutMainLoop(); - return 0; -} -#else -int main(int argc, char** argv) -{ - fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0.\n"); - fprintf (stderr, "If your implementation of OpenGL Version 1.0 has the right extensions,\n"); - fprintf (stderr, "you may be able to modify this program to make it run.\n"); - return 0; -} -#endif diff --git a/progs/redbook/polys.c b/progs/redbook/polys.c deleted file mode 100644 index eeffe2301ce..00000000000 --- a/progs/redbook/polys.c +++ /dev/null @@ -1,138 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * polys.c - * This program demonstrates polygon stippling. - */ -#include <stdlib.h> -#include <GL/glut.h> - -static void display(void) -{ - GLubyte fly[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x03, 0x80, 0x01, 0xC0, 0x06, 0xC0, 0x03, 0x60, 0x04, 0x60, 0x06, 0x20, -0x04, 0x30, 0x0C, 0x20, 0x04, 0x18, 0x18, 0x20, 0x04, 0x0C, 0x30, 0x20, -0x04, 0x06, 0x60, 0x20, 0x44, 0x03, 0xC0, 0x22, 0x44, 0x01, 0x80, 0x22, -0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, -0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x66, 0x01, 0x80, 0x66, -0x33, 0x01, 0x80, 0xCC, 0x19, 0x81, 0x81, 0x98, 0x0C, 0xC1, 0x83, 0x30, -0x07, 0xe1, 0x87, 0xe0, 0x03, 0x3f, 0xfc, 0xc0, 0x03, 0x31, 0x8c, 0xc0, -0x03, 0x33, 0xcc, 0xc0, 0x06, 0x64, 0x26, 0x60, 0x0c, 0xcc, 0x33, 0x30, -0x18, 0xcc, 0x33, 0x18, 0x10, 0xc4, 0x23, 0x08, 0x10, 0x63, 0xC6, 0x08, -0x10, 0x30, 0x0c, 0x08, 0x10, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x08}; - - GLubyte halftone[] = { -0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, -0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, -0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, -0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, -0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, -0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, -0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, -0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, -0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, -0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, -0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55}; - - glClear (GL_COLOR_BUFFER_BIT); - -/* draw all polygons in white */ - glColor3f (1.0, 1.0, 1.0); - -/* draw one solid, unstippled rectangle, */ -/* then two stippled rectangles */ - glRectf (25.0, 25.0, 125.0, 125.0); - glEnable (GL_POLYGON_STIPPLE); - glPolygonStipple (fly); - glRectf (125.0, 25.0, 225.0, 125.0); - glPolygonStipple (halftone); - glRectf (225.0, 25.0, 325.0, 125.0); - glDisable (GL_POLYGON_STIPPLE); - - glFlush (); -} - -static void myinit (void) -{ -/* clear background to black */ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_FLAT); -} - -static void reshape(GLsizei w, GLsizei h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.0, (GLdouble)w, 0.0, (GLdouble)h, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -static void -key(unsigned char k, int x, int y) -{ - switch (k) { - case 27: /* Escape */ - exit(0); - break; - default: - break; - } - glutPostRedisplay(); -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (350, 150); - glutCreateWindow (argv[0]); - myinit (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/quadric.c b/progs/redbook/quadric.c deleted file mode 100644 index 1cbd395e47b..00000000000 --- a/progs/redbook/quadric.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * quadric.c - * This program demonstrates the use of some of the gluQuadric* - * routines. Quadric objects are created with some quadric - * properties and the callback routine to handle errors. - * Note that the cylinder has no top or bottom and the circle - * has a hole in it. - */ -#include <GL/glut.h> -#include <stdio.h> -#include <stdlib.h> - -/* Win32 calling conventions. */ -#ifndef CALLBACK -#define CALLBACK -#endif - -GLuint startList; - -static void CALLBACK errorCallback(GLenum errorCode) -{ - const GLubyte *estring; - - estring = gluErrorString(errorCode); - fprintf(stderr, "Quadric Error: %s\n", estring); - exit(0); -} - -static void init(void) -{ - GLUquadricObj *qobj; - GLfloat mat_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat mat_shininess[] = { 50.0 }; - GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; - GLfloat model_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; - - glClearColor(0.0, 0.0, 0.0, 0.0); - - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); - glLightfv(GL_LIGHT0, GL_POSITION, light_position); - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, model_ambient); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); - -/* Create 4 display lists, each with a different quadric object. - * Different drawing styles and surface normal specifications - * are demonstrated. - */ - startList = glGenLists(4); - qobj = gluNewQuadric(); - gluQuadricCallback(qobj, GLU_ERROR, - (GLvoid (CALLBACK*) ()) errorCallback); - - gluQuadricDrawStyle(qobj, GLU_FILL); /* smooth shaded */ - gluQuadricNormals(qobj, GLU_SMOOTH); - glNewList(startList, GL_COMPILE); - gluSphere(qobj, 0.75, 15, 10); - glEndList(); - - gluQuadricDrawStyle(qobj, GLU_FILL); /* flat shaded */ - gluQuadricNormals(qobj, GLU_FLAT); - glNewList(startList+1, GL_COMPILE); - gluCylinder(qobj, 0.5, 0.3, 1.0, 15, 5); - glEndList(); - - gluQuadricDrawStyle(qobj, GLU_LINE); /* all polygons wireframe */ - gluQuadricNormals(qobj, GLU_NONE); - glNewList(startList+2, GL_COMPILE); - gluDisk(qobj, 0.25, 1.0, 20, 4); - glEndList(); - - gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); /* boundary only */ - gluQuadricNormals(qobj, GLU_NONE); - glNewList(startList+3, GL_COMPILE); - gluPartialDisk(qobj, 0.0, 1.0, 20, 4, 0.0, 225.0); - glEndList(); - - gluDeleteQuadric(qobj); -} - -static void display(void) -{ - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glPushMatrix(); - - glEnable(GL_LIGHTING); - glShadeModel (GL_SMOOTH); - glTranslatef(-1.0, -1.0, 0.0); - glCallList(startList); - - glShadeModel (GL_FLAT); - glTranslatef(0.0, 2.0, 0.0); - glPushMatrix(); - glRotatef(300.0, 1.0, 0.0, 0.0); - glCallList(startList+1); - glPopMatrix(); - - glDisable(GL_LIGHTING); - glColor3f(0.0, 1.0, 1.0); - glTranslatef(2.0, -2.0, 0.0); - glCallList(startList+2); - - glColor3f(1.0, 1.0, 0.0); - glTranslatef(0.0, 2.0, 0.0); - glCallList(startList+3); - - glPopMatrix(); - glFlush(); -} - -static void reshape (int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - 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, - 2.5*(GLfloat)w/(GLfloat)h, -2.5, 2.5, -10.0, 10.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(500, 500); - glutInitWindowPosition(100, 100); - glutCreateWindow(argv[0]); - init(); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/robot.c b/progs/redbook/robot.c deleted file mode 100644 index c90b72ab3ea..00000000000 --- a/progs/redbook/robot.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * robot.c - * This program shows how to composite modeling transformations - * to draw translated and rotated hierarchical models. - * Interaction: pressing the s and e keys (shoulder and elbow) - * alters the rotation of the robot arm. - */ -#include <GL/glut.h> -#include <stdlib.h> - -static int shoulder = 0, elbow = 0; - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_FLAT); -} - -static void display(void) -{ - glClear (GL_COLOR_BUFFER_BIT); - glPushMatrix(); - glTranslatef (-1.0, 0.0, 0.0); - glRotatef ((GLfloat) shoulder, 0.0, 0.0, 1.0); - glTranslatef (1.0, 0.0, 0.0); - glPushMatrix(); - glScalef (2.0, 0.4, 1.0); - glutWireCube (1.0); - glPopMatrix(); - - glTranslatef (1.0, 0.0, 0.0); - glRotatef ((GLfloat) elbow, 0.0, 0.0, 1.0); - glTranslatef (1.0, 0.0, 0.0); - glPushMatrix(); - glScalef (2.0, 0.4, 1.0); - glutWireCube (1.0); - glPopMatrix(); - - glPopMatrix(); - glutSwapBuffers(); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - gluPerspective(65.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef (0.0, 0.0, -5.0); -} - -/* ARGSUSED1 */ -static void keyboard (unsigned char key, int x, int y) -{ - switch (key) { - case 's': - shoulder = (shoulder + 5) % 360; - glutPostRedisplay(); - break; - case 'S': - shoulder = (shoulder - 5) % 360; - glutPostRedisplay(); - break; - case 'e': - elbow = (elbow + 5) % 360; - glutPostRedisplay(); - break; - case 'E': - elbow = (elbow - 5) % 360; - glutPostRedisplay(); - break; - case 27: - exit(0); - break; - default: - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/sccolorlight.c b/progs/redbook/sccolorlight.c deleted file mode 100644 index d9e0a254e90..00000000000 --- a/progs/redbook/sccolorlight.c +++ /dev/null @@ -1,141 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * sccolorlight.c - * 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> -#include <GL/glut.h> - -/* Initialize material property and light source. - */ -static void myinit(void) -{ - GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; - GLfloat light_diffuse[] = { 1.0, 0.0, 1.0, 1.0 }; - GLfloat light_specular[] = { 1.0, 0.0, 1.0, 1.0 }; -/* light_position is NOT default value */ - GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; - - glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); - 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); - glEnable(GL_DEPTH_TEST); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glPushMatrix (); - glRotatef (20.0, 1.0, 0.0, 0.0); - - glPushMatrix (); - 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); - 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); - glutSolidSphere (1.0, 20, 20); - glPopMatrix (); - - glPopMatrix (); - glFlush(); -} - -static 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, - 2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); - 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, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (500, 500); - glutCreateWindow (argv[0]); - 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 deleted file mode 100644 index 6f336a8db46..00000000000 --- a/progs/redbook/scene.c +++ /dev/null @@ -1,141 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * scene.c - * This program demonstrates the use of the GL lighting model. - * Objects are drawn using a grey material characteristic. - * A single light source illuminates the objects. - */ -#include <stdlib.h> -#include <GL/glut.h> - -/* Initialize material property and light source. - */ -static void myinit (void) -{ - GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; - GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; -/* light_position is NOT default value */ - GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; - - glLightfv (GL_LIGHT0, GL_AMBIENT, light_ambient); - 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); - glEnable(GL_DEPTH_TEST); -} - -static void display (void) -{ - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix (); - glRotatef (20.0, 1.0, 0.0, 0.0); - - glPushMatrix (); - 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); - 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); - glutSolidSphere (1.0, 15, 15); - glPopMatrix (); - - glPopMatrix (); - glFlush (); -} - -static 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, - 2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); - 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, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (500, 500); - glutCreateWindow (argv[0]); - 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 deleted file mode 100644 index ea605f8c737..00000000000 --- a/progs/redbook/scenebamb.c +++ /dev/null @@ -1,140 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * scenebamb.c - * This program demonstrates use of a blue ambient light - * source. - */ -#include <stdlib.h> -#include <GL/glut.h> - -/* Initialize light source and lighting. - */ -static void myinit(void) -{ - GLfloat light_ambient[] = { 0.0, 0.0, 1.0, 1.0 }; - GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; -/* light_position is NOT default value */ - GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; - - glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); - 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); - glEnable(GL_DEPTH_TEST); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix (); - glRotatef (20.0, 1.0, 0.0, 0.0); - - glPushMatrix (); - 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); - 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); - glutSolidSphere (1.0, 15, 15); - glPopMatrix (); - - glPopMatrix (); - glFlush(); -} - -static 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, - 2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); - 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, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (500, 500); - glutCreateWindow (argv[0]); - 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 deleted file mode 100644 index 1b277334f5c..00000000000 --- a/progs/redbook/sceneflat.c +++ /dev/null @@ -1,140 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * sceneflat.c - * This program draws lighted objects with flat shading. - */ -#include <stdlib.h> -#include <GL/glut.h> - -/* Initialize light source and shading model (GL_FLAT). - */ -static void myinit(void) -{ - GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; - GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; -/* light_position is NOT default value */ - GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; - - glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); - 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); - glEnable(GL_DEPTH_TEST); - glShadeModel (GL_FLAT); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix (); - glRotatef (20.0, 1.0, 0.0, 0.0); - - glPushMatrix (); - 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); - 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); - glutSolidSphere (1.0, 15, 15); - glPopMatrix (); - - glPopMatrix (); - glFlush(); -} - -static 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, - 2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); - 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, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (500, 500); - glutCreateWindow (argv[0]); - myinit(); - glutReshapeFunc (myReshape); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/select.c b/progs/redbook/select.c deleted file mode 100644 index 537d5194d46..00000000000 --- a/progs/redbook/select.c +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * select.c - * This is an illustration of the selection mode and - * name stack, which detects whether objects which collide - * with a viewing volume. First, four triangles and a - * rectangular box representing a viewing volume are drawn - * (drawScene routine). The green triangle and yellow - * triangles appear to lie within the viewing volume, but - * the red triangle appears to lie outside it. Then the - * selection mode is entered (selectObjects routine). - * Drawing to the screen ceases. To see if any collisions - * occur, the four triangles are called. In this example, - * the green triangle causes one hit with the name 1, and - * the yellow triangles cause one hit with the name 3. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -/* draw a triangle with vertices at (x1, y1), (x2, y2) - * and (x3, y3) at z units away from the origin. - */ -static void drawTriangle (GLfloat x1, GLfloat y1, GLfloat x2, - GLfloat y2, GLfloat x3, GLfloat y3, GLfloat z) -{ - glBegin (GL_TRIANGLES); - glVertex3f (x1, y1, z); - glVertex3f (x2, y2, z); - glVertex3f (x3, y3, z); - glEnd (); -} - -/* draw a rectangular box with these outer x, y, and z values */ -static void drawViewVolume (GLfloat x1, GLfloat x2, GLfloat y1, - GLfloat y2, GLfloat z1, GLfloat z2) -{ - glColor3f (1.0, 1.0, 1.0); - glBegin (GL_LINE_LOOP); - glVertex3f (x1, y1, -z1); - glVertex3f (x2, y1, -z1); - glVertex3f (x2, y2, -z1); - glVertex3f (x1, y2, -z1); - glEnd (); - - glBegin (GL_LINE_LOOP); - glVertex3f (x1, y1, -z2); - glVertex3f (x2, y1, -z2); - glVertex3f (x2, y2, -z2); - glVertex3f (x1, y2, -z2); - glEnd (); - - glBegin (GL_LINES); /* 4 lines */ - glVertex3f (x1, y1, -z1); - glVertex3f (x1, y1, -z2); - glVertex3f (x1, y2, -z1); - glVertex3f (x1, y2, -z2); - glVertex3f (x2, y1, -z1); - glVertex3f (x2, y1, -z2); - glVertex3f (x2, y2, -z1); - glVertex3f (x2, y2, -z2); - glEnd (); -} - -/* drawScene draws 4 triangles and a wire frame - * which represents the viewing volume. - */ -static void drawScene (void) -{ - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - gluPerspective (40.0, 4.0/3.0, 1.0, 100.0); - - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - gluLookAt (7.5, 7.5, 12.5, 2.5, 2.5, -5.0, 0.0, 1.0, 0.0); - glColor3f (0.0, 1.0, 0.0); /* green triangle */ - drawTriangle (2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -5.0); - glColor3f (1.0, 0.0, 0.0); /* red triangle */ - drawTriangle (2.0, 7.0, 3.0, 7.0, 2.5, 8.0, -5.0); - glColor3f (1.0, 1.0, 0.0); /* yellow triangles */ - drawTriangle (2.0, 2.0, 3.0, 2.0, 2.5, 3.0, 0.0); - drawTriangle (2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -10.0); - drawViewVolume (0.0, 5.0, 0.0, 5.0, 0.0, 10.0); -} - -/* processHits prints out the contents of the selection array - */ -static void processHits (GLint hits, GLuint buffer[]) -{ - GLint i; - GLuint j, names, *ptr; - - printf ("hits = %d\n", hits); - ptr = (GLuint *) buffer; - for (i = 0; i < hits; i++) { /* for each hit */ - names = *ptr; - printf (" number of names for hit = %d\n", names); ptr++; - printf(" z1 is %g;", (float) *ptr/0x7fffffff); ptr++; - printf(" z2 is %g\n", (float) *ptr/0x7fffffff); ptr++; - printf (" the name is "); - for (j = 0; j < names; j++) { /* for each name */ - printf ("%d ", *ptr); ptr++; - } - printf ("\n"); - } -} - -/* selectObjects "draws" the triangles in selection mode, - * assigning names for the triangles. Note that the third - * and fourth triangles share one name, so that if either - * or both triangles intersects the viewing/clipping volume, - * only one hit will be registered. - */ -#define BUFSIZE 512 - -static void selectObjects(void) -{ - GLuint selectBuf[BUFSIZE]; - GLint hits; - - glSelectBuffer (BUFSIZE, selectBuf); - (void) glRenderMode (GL_SELECT); - - glInitNames(); - glPushName(0); - - glPushMatrix (); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - glOrtho (0.0, 5.0, 0.0, 5.0, 0.0, 10.0); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - glLoadName(1); - drawTriangle (2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -5.0); - glLoadName(2); - drawTriangle (2.0, 7.0, 3.0, 7.0, 2.5, 8.0, -5.0); - glLoadName(3); - drawTriangle (2.0, 2.0, 3.0, 2.0, 2.5, 3.0, 0.0); - drawTriangle (2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -10.0); - glPopMatrix (); - glFlush (); - - hits = glRenderMode (GL_RENDER); - processHits (hits, selectBuf); -} - -static void init (void) -{ - glEnable(GL_DEPTH_TEST); - glShadeModel(GL_FLAT); -} - -static void display(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - drawScene (); - selectObjects (); - glFlush(); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -/* Main Loop */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (200, 200); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init(); - glutDisplayFunc(display); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/shadowmap.c b/progs/redbook/shadowmap.c deleted file mode 100644 index f37191d9ff3..00000000000 --- a/progs/redbook/shadowmap.c +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <GL/glew.h> -#include <GL/glut.h> -/*#include "helpers.h"*/ - -#define SHADOW_MAP_WIDTH 256 -#define SHADOW_MAP_HEIGHT 256 - -#define PI 3.14159265359 - -GLdouble fovy = 60.0; -GLdouble nearPlane = 10.0; -GLdouble farPlane = 100.0; - -GLfloat angle = 0.0; -GLfloat torusAngle = 0.0; - -GLfloat lightPos[] = { 25.0, 25.0, 25.0, 1.0 }; -GLfloat lookat[] = { 0.0, 0.0, 0.0 }; -GLfloat up[] = { 0.0, 0.0, 1.0 }; - -GLboolean showShadow = GL_FALSE; - -static void -init( void ) -{ - GLfloat white[] = { 1.0, 1.0, 1.0, 1.0 }; - - glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, - SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, 0, - GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL ); - - glLightfv( GL_LIGHT0, GL_POSITION, lightPos ); - glLightfv( GL_LIGHT0, GL_SPECULAR, white ); - glLightfv( GL_LIGHT0, GL_DIFFUSE, white ); - - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL ); - glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, - GL_COMPARE_R_TO_TEXTURE ); - - glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); - glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); - glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); - glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); - - glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); - - glCullFace( GL_BACK ); - - glEnable( GL_DEPTH_TEST ); - glEnable( GL_LIGHT0 ); - glEnable( GL_LIGHTING ); - glEnable( GL_TEXTURE_2D ); - glEnable( GL_TEXTURE_GEN_S ); - glEnable( GL_TEXTURE_GEN_T ); - glEnable( GL_TEXTURE_GEN_R ); - glEnable( GL_TEXTURE_GEN_Q ); - glEnable( GL_COLOR_MATERIAL ); - glEnable( GL_CULL_FACE ); -} - -static void -reshape( int width, int height ) -{ - glViewport( 0, 0, width, height ); - - glMatrixMode( GL_PROJECTION ); - glLoadIdentity(); - gluPerspective( fovy, (GLdouble) width/height, nearPlane, farPlane ); - glMatrixMode( GL_MODELVIEW ); -} - -static void -idle( void ) -{ - angle += PI / 10000; - torusAngle += .1; - glutPostRedisplay(); -} - -static void -keyboard( unsigned char key, int x, int y ) -{ - switch( key ) { - case 27: /* Escape */ - exit( 0 ); - break; - - case 't': { - static GLboolean textureOn = GL_TRUE; - textureOn = !textureOn; - if ( textureOn ) - glEnable( GL_TEXTURE_2D ); - else - glDisable( GL_TEXTURE_2D ); - } - break; - - case 'm': { - static GLboolean compareMode = GL_TRUE; - compareMode = !compareMode; - printf( "Compare mode %s\n", compareMode ? "On" : "Off" ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, - compareMode ? GL_COMPARE_R_TO_TEXTURE : GL_NONE ); - } - break; - - case 'f': { - static GLboolean funcMode = GL_TRUE; - funcMode = !funcMode; - printf( "Operator %s\n", funcMode ? "GL_LEQUAL" : "GL_GEQUAL" ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, - funcMode ? GL_LEQUAL : GL_GEQUAL ); - } - break; - - case 's': - showShadow = !showShadow; - break; - - case 'p': { - static GLboolean animate = GL_TRUE; - animate = !animate; - glutIdleFunc( animate ? idle : NULL ); - } - break; - } - - glutPostRedisplay(); -} - -static void -transposeMatrix( GLfloat m[16] ) -{ - GLfloat tmp; -#define Swap( a, b ) tmp = a; a = b; b = tmp - Swap( m[1], m[4] ); - Swap( m[2], m[8] ); - Swap( m[3], m[12] ); - Swap( m[6], m[9] ); - Swap( m[7], m[13] ); - Swap( m[11], m[14] ); -#undef Swap -} - -static void -drawObjects( GLboolean shadowRender ) -{ - GLboolean textureOn = glIsEnabled( GL_TEXTURE_2D ); - - if ( shadowRender ) - glDisable( GL_TEXTURE_2D ); - - if ( !shadowRender ) { - glNormal3f( 0, 0, 1 ); - glColor3f( 1, 1, 1 ); - glRectf( -20.0, -20.0, 20.0, 20.0 ); - } - - glPushMatrix(); - glTranslatef( 11, 11, 11 ); - glRotatef( 54.73, -5, 5, 0 ); - glRotatef( torusAngle, 1, 0, 0 ); - glColor3f( 1, 0, 0 ); - glutSolidTorus( 1, 4, 8, 36 ); - glPopMatrix(); - - glPushMatrix(); - glTranslatef( 2, 2, 2 ); - glColor3f( 0, 0, 1 ); - glutSolidCube( 4 ); - glPopMatrix(); - - glPushMatrix(); - glTranslatef( lightPos[0], lightPos[1], lightPos[2] ); - glColor3f( 1, 1, 1 ); - glutWireSphere( 0.5, 6, 6 ); - glPopMatrix(); - - if ( shadowRender && textureOn ) - glEnable( GL_TEXTURE_2D ); -} - -static void -generateShadowMap( void ) -{ - GLint viewport[4]; - GLfloat lightPos[4]; - - glGetLightfv( GL_LIGHT0, GL_POSITION, lightPos ); - glGetIntegerv( GL_VIEWPORT, viewport ); - - glViewport( 0, 0, SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT ); - - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - - glMatrixMode( GL_PROJECTION ); - glPushMatrix(); - glLoadIdentity(); - gluPerspective( 80.0, 1.0, 10.0, 1000.0 ); - glMatrixMode( GL_MODELVIEW ); - - glPushMatrix(); - glLoadIdentity(); - gluLookAt( lightPos[0], lightPos[1], lightPos[2], - lookat[0], lookat[1], lookat[2], - up[0], up[1], up[2] ); - - drawObjects( GL_TRUE ); - - glPopMatrix(); - glMatrixMode( GL_PROJECTION ); - glPopMatrix(); - glMatrixMode( GL_MODELVIEW ); - - glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, - SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, 0 ); - - glViewport( viewport[0], viewport[1], viewport[2], viewport[3] ); - - if ( showShadow ) { - GLfloat depthImage[SHADOW_MAP_WIDTH][SHADOW_MAP_HEIGHT]; - glReadPixels( 0, 0, SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, - GL_DEPTH_COMPONENT, GL_FLOAT, depthImage ); - glWindowPos2f( viewport[2]/2, 0 ); - glDrawPixels( SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_LUMINANCE, - GL_FLOAT, depthImage ); - glutSwapBuffers(); - } -} - -static void -generateTextureMatrix( void ) -{ - GLfloat tmpMatrix[16]; - - /* - * Set up projective texture matrix. We use the GL_MODELVIEW matrix - * stack and OpenGL matrix commands to make the matrix. - */ - glPushMatrix(); - glLoadIdentity(); - glTranslatef( 0.5, 0.5, 0.0 ); - glScalef( 0.5, 0.5, 1.0 ); - gluPerspective( 60.0, 1.0, 1.0, 1000.0 ); - gluLookAt( lightPos[0], lightPos[1], lightPos[2], - lookat[0], lookat[1], lookat[2], - up[0], up[1], up[2] ); - glGetFloatv( GL_MODELVIEW_MATRIX, tmpMatrix ); - glPopMatrix(); - - transposeMatrix( tmpMatrix ); - - glTexGenfv( GL_S, GL_OBJECT_PLANE, &tmpMatrix[0] ); - glTexGenfv( GL_T, GL_OBJECT_PLANE, &tmpMatrix[4] ); - glTexGenfv( GL_R, GL_OBJECT_PLANE, &tmpMatrix[8] ); - glTexGenfv( GL_Q, GL_OBJECT_PLANE, &tmpMatrix[12] ); -} - -static void -display( void ) -{ - GLfloat radius = 30; - - generateShadowMap(); - generateTextureMatrix(); - - if ( showShadow ) - return; - - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - - glPushMatrix(); - gluLookAt( radius*cos(angle), radius*sin(angle), 30, - lookat[0], lookat[1], lookat[2], - up[0], up[1], up[2] ); - drawObjects( GL_FALSE ); - glPopMatrix(); - - glutSwapBuffers(); -} - -int -main( int argc, char** argv ) -{ - glutInit( &argc, argv ); - glutInitDisplayMode( GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE ); - glutInitWindowSize( 512, 512 ); - glutInitWindowPosition( 100, 100 ); - glutCreateWindow( argv[0] ); - glewInit(); - - init(); - - glutDisplayFunc( display ); - glutReshapeFunc( reshape ); - glutKeyboardFunc( keyboard ); - glutIdleFunc( idle ); - - glutMainLoop(); - - return 0; -} diff --git a/progs/redbook/smooth.c b/progs/redbook/smooth.c deleted file mode 100644 index 874033d5adf..00000000000 --- a/progs/redbook/smooth.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * smooth.c - * This program demonstrates smooth shading. - * A smooth shaded polygon is drawn in a 2-D projection. - */ -#include <GL/glut.h> -#include <stdlib.h> - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_SMOOTH); -} - -static void triangle(void) -{ - glBegin (GL_TRIANGLES); - glColor3f (1.0, 0.0, 0.0); - glVertex2f (5.0, 5.0); - glColor3f (0.0, 1.0, 0.0); - glVertex2f (25.0, 5.0); - glColor3f (0.0, 0.0, 1.0); - glVertex2f (5.0, 25.0); - glEnd(); -} - -static void display(void) -{ - glClear (GL_COLOR_BUFFER_BIT); - triangle (); - glFlush (); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - if (w <= h) - gluOrtho2D (0.0, 30.0, 0.0, 30.0 * (GLfloat) h/(GLfloat) w); - else - gluOrtho2D (0.0, 30.0 * (GLfloat) w/(GLfloat) h, 0.0, 30.0); - glMatrixMode(GL_MODELVIEW); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/stencil.c b/progs/redbook/stencil.c deleted file mode 100644 index 5325abf8b77..00000000000 --- a/progs/redbook/stencil.c +++ /dev/null @@ -1,193 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * 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 - * (a sphere) is drawn in a different color. - */ - -/* - * !!! NOTE !!! - * - * This demo is poorly written. The stencil buffer should be - * redrawn in display(), not in the myReshape() function. - * The reason is if the window gets "damaged" then the stencil buffer - * contents will be in an undefined state (myReshape is not called when - * a window is damaged and needs to be redrawn). If the stencil buffer - * contents are undefined, the results of display() are unpredictable. - * - * -Brian - */ - - -#include <stdlib.h> -#include <GL/glut.h> - -#define YELLOWMAT 1 -#define BLUEMAT 2 - -static 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 }; - - GLfloat blue_diffuse[] = { 0.1, 0.1, 0.7, 1.0 }; - GLfloat blue_specular[] = { 0.1, 1.0, 1.0, 1.0 }; - - GLfloat position_one[] = { 1.0, 1.0, 1.0, 0.0 }; - - glNewList(YELLOWMAT, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_DIFFUSE, yellow_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, yellow_specular); - glMaterialf(GL_FRONT, GL_SHININESS, 64.0); - glEndList(); - - glNewList(BLUEMAT, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_DIFFUSE, blue_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, blue_specular); - glMaterialf(GL_FRONT, GL_SHININESS, 45.0); - glEndList(); - - glLightfv(GL_LIGHT0, GL_POSITION, position_one); - - glEnable(GL_LIGHT0); - glEnable(GL_LIGHTING); - glDepthFunc(GL_LESS); - glEnable(GL_DEPTH_TEST); - - glClearStencil(0x0); - glEnable(GL_STENCIL_TEST); - -} - -/* Draw a sphere in a diamond-shaped section in the - * middle of a window with 2 tori. - */ -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP); - -/* draw blue sphere where the stencil is 1 */ - glStencilFunc (GL_EQUAL, 0x1, 0x1); - glCallList (BLUEMAT); - glutSolidSphere (0.5, 15, 15); - -/* draw the tori where the stencil is not 1 */ - glStencilFunc (GL_NOTEQUAL, 0x1, 0x1); - glPushMatrix(); - glRotatef (45.0, 0.0, 0.0, 1.0); - glRotatef (45.0, 0.0, 1.0, 0.0); - glCallList (YELLOWMAT); - glutSolidTorus (0.275, 0.85, 15, 15); - glPushMatrix(); - glRotatef (90.0, 1.0, 0.0, 0.0); - glutSolidTorus (0.275, 0.85, 15, 15); - glPopMatrix(); - glPopMatrix(); - - glFlush(); - glutSwapBuffers(); -} - -/* Whenever the window is reshaped, redefine the - * coordinate system and redraw the stencil area. - */ -static void myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - - glClear(GL_STENCIL_BUFFER_BIT); -/* create a diamond shaped stencil area */ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-3.0, 3.0, -3.0, 3.0, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glStencilFunc (GL_ALWAYS, 0x1, 0x1); - glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE); - glBegin(GL_QUADS); - glVertex3f (-1.0, 0.0, 0.0); - glVertex3f (0.0, 1.0, 0.0); - glVertex3f (1.0, 0.0, 0.0); - glVertex3f (0.0, -1.0, 0.0); - glEnd(); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(45.0, (GLfloat) w/(GLfloat) h, 3.0, 7.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - 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, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL); - glutInitWindowSize (400, 400); - glutCreateWindow (argv[0]); - 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 deleted file mode 100644 index 68b639abf4f..00000000000 --- a/progs/redbook/stroke.c +++ /dev/null @@ -1,195 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* - * stroke.c - * This program demonstrates some characters of a - * stroke (vector) font. The characters are represented - * by display lists, which are given numbers which - * correspond to the ASCII values of the characters. - * Use of glCallLists() is demonstrated. - */ -#include <stdlib.h> -#include <string.h> -#include <GL/glut.h> - -#define PT 1 -#define STROKE 2 -#define END 3 - -typedef struct charpoint { - GLfloat x, y; - int type; -} CP; - -CP Adata[] = { - { 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 Edata[] = { - {5, 0, PT}, {0, 0, PT}, {0, 10, PT}, {5, 10, STROKE}, - {0, 5, PT}, {4, 5, END} -}; - -CP Pdata[] = { - {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}, - {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}, - {4, 10, PT}, {5, 9, END} -}; - -/* drawLetter() interprets the instructions from the array - * for that letter and renders the letter with line segments. - */ -static void drawLetter(CP *l) -{ - glBegin(GL_LINE_STRIP); - for (;;) { - switch (l->type) { - case PT: - glVertex2fv(&l->x); - break; - case STROKE: - glVertex2fv(&l->x); - glEnd(); - glBegin(GL_LINE_STRIP); - break; - case END: - glVertex2fv(&l->x); - glEnd(); - glTranslatef(8.0, 0.0, 0.0); - return; - } - l++; - } -} - -/* Create a display list for each of 6 characters */ -static void myinit (void) -{ - GLuint base; - - glShadeModel (GL_FLAT); - - base = glGenLists (128); - glListBase(base); - glNewList(base+'A', GL_COMPILE); drawLetter(Adata); glEndList(); - glNewList(base+'E', GL_COMPILE); drawLetter(Edata); glEndList(); - glNewList(base+'P', GL_COMPILE); drawLetter(Pdata); glEndList(); - glNewList(base+'R', GL_COMPILE); drawLetter(Rdata); glEndList(); - glNewList(base+'S', GL_COMPILE); drawLetter(Sdata); glEndList(); - glNewList(base+' ', GL_COMPILE); glTranslatef(8.0, 0.0, 0.0); glEndList(); -} - -char *test1 = "A SPARE SERAPE APPEARS AS"; -char *test2 = "APES PREPARE RARE PEPPERS"; - -static void printStrokedString(char *s) -{ - GLsizei len = (GLsizei) strlen(s); - glCallLists(len, GL_BYTE, (GLbyte *)s); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - glColor3f(1.0, 1.0, 1.0); - glPushMatrix(); - glScalef(2.0, 2.0, 2.0); - glTranslatef(10.0, 30.0, 0.0); - printStrokedString(test1); - glPopMatrix(); - glPushMatrix(); - glScalef(2.0, 2.0, 2.0); - glTranslatef(10.0, 13.0, 0.0); - printStrokedString(test2); - glPopMatrix(); - glFlush(); -} - -static void reshape(GLsizei w, GLsizei h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.0, (GLdouble)w, 0.0, (GLdouble)h, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); - 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, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (440, 120); - glutCreateWindow (argv[0]); - 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 deleted file mode 100644 index f0c5ab0b47c..00000000000 --- a/progs/redbook/surface.c +++ /dev/null @@ -1,232 +0,0 @@ -/* aux2glut conversion Copyright (c) Mark J. Kilgard, 1994, 1995 */ - -/** - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/** - * surface.c - * This program draws a NURBS surface in the shape of a - * symmetrical hill. - */ -#include <stdlib.h> -#include <GL/glut.h> - -GLfloat ctlpoints[4][4][3]; -int showPoints = 0; - -GLUnurbsObj *theNurb; - -/* - * Initializes the control points of the surface to a small hill. - * The control points range from -3 to +3 in x, y, and z - */ -static void init_surface(void) -{ - int u, v; - for (u = 0; u < 4; u++) { - for (v = 0; v < 4; v++) { - ctlpoints[u][v][0] = 2.0*((GLfloat)u - 1.5); - ctlpoints[u][v][1] = 2.0*((GLfloat)v - 1.5); - - if ( (u == 1 || u == 2) && (v == 1 || v == 2)) - ctlpoints[u][v][2] = 7.0; - else - ctlpoints[u][v][2] = -3.0; - } - } -} - -/* Initialize material property and depth buffer. - */ -static void myinit(void) -{ - GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 }; - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat mat_shininess[] = { 100.0 }; - - glClearColor (0.0, 0.0, 0.0, 1.0); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glDepthFunc(GL_LESS); - glEnable(GL_DEPTH_TEST); - glEnable(GL_AUTO_NORMAL); - glEnable(GL_NORMALIZE); - - init_surface(); - - theNurb = gluNewNurbsRenderer(); - gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0); - gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef (0.0, 0.0, -5.0); -} - -static void display(void) -{ - GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0}; - int i, j; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix(); - glRotatef(330.0, 1.,0.,0.); - glScalef (0.25, 0.25, 0.25); - - gluBeginSurface(theNurb); - gluNurbsSurface(theNurb, - 8, knots, - 8, knots, - 4 * 3, - 3, - &ctlpoints[0][0][0], - 4, 4, - GL_MAP2_VERTEX_3); - gluEndSurface(theNurb); - - if(showPoints) { - glPointSize(5.0); - glDisable(GL_LIGHTING); - glColor3f(1.0, 1.0, 0.0); - glBegin(GL_POINTS); - for(i=0;i<4;i++) { - for(j=0;j<4;j++) { - glVertex3f(ctlpoints[i][j][0], ctlpoints[i][j][1], ctlpoints[i][j][2]); - } - } - glEnd(); - glEnable(GL_LIGHTING); - } - - glPopMatrix(); - glutSwapBuffers(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective (45.0, (GLdouble)w/(GLdouble)h, 3.0, 8.0); - - glMatrixMode(GL_MODELVIEW); -} - -static void -menu(int value) -{ - switch (value) { - case 0: - case 1: - showPoints = value; - break; - case 2: - gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); - break; - case 3: - gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_OUTLINE_POLYGON); - break; - } - glutPostRedisplay(); -} - -int down = 0, lastx; - -/* ARGSUSED1 */ -static void -motion(int x, int y) -{ - if (down) { - glRotatef(lastx - x, 0, 1, 0); - lastx = x; - glutPostRedisplay(); - } -} - -/* ARGSUSED3 */ -static void -mouse(int button, int state, int x, int y) -{ - if (button == GLUT_LEFT_BUTTON) { - if (state == GLUT_DOWN) { - lastx = x; - down = 1; - } else { - down = 0; - } - } -} - -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) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB); - glutCreateWindow(argv[0]); - myinit(); - glutReshapeFunc(reshape); - glutDisplayFunc(display); - glutCreateMenu(menu); - glutAddMenuEntry("Show control points", 1); - glutAddMenuEntry("Hide control points", 0); - glutAddMenuEntry("Solid", 2); - glutAddMenuEntry("Wireframe", 3); - 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/surfpoints.c b/progs/redbook/surfpoints.c deleted file mode 100644 index 094f0dada80..00000000000 --- a/progs/redbook/surfpoints.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * surfpoints.c - * This program is a modification of the earlier surface.c - * program. The vertex data are not directly rendered, - * but are instead passed to the callback function. - * The values of the tessellated vertices are printed - * out there. - * - * This program draws a NURBS surface in the shape of a - * symmetrical hill. The 'c' keyboard key allows you to - * toggle the visibility of the control points themselves. - * Note that some of the control points are hidden by the - * surface itself. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -#ifdef GLU_VERSION_1_3 - -#ifndef CALLBACK -#define CALLBACK -#endif - -GLfloat ctlpoints[4][4][3]; -int showPoints = 0; - -GLUnurbsObj *theNurb; - -/* - * Initializes the control points of the surface to a small hill. - * The control points range from -3 to +3 in x, y, and z - */ -static void init_surface(void) -{ - int u, v; - for (u = 0; u < 4; u++) { - for (v = 0; v < 4; v++) { - ctlpoints[u][v][0] = 2.0*((GLfloat)u - 1.5); - ctlpoints[u][v][1] = 2.0*((GLfloat)v - 1.5); - - if ( (u == 1 || u == 2) && (v == 1 || v == 2)) - ctlpoints[u][v][2] = 3.0; - else - ctlpoints[u][v][2] = -3.0; - } - } -} - -static void CALLBACK nurbsError(GLenum errorCode) -{ - const GLubyte *estring; - - estring = gluErrorString(errorCode); - fprintf (stderr, "Nurbs Error: %s\n", estring); - exit (0); -} - -static void CALLBACK beginCallback(GLenum whichType) -{ - glBegin (whichType); /* resubmit rendering directive */ - printf ("glBegin("); - switch (whichType) { /* print diagnostic message */ - case GL_LINES: - printf ("GL_LINES)\n"); - break; - case GL_LINE_LOOP: - printf ("GL_LINE_LOOP)\n"); - break; - case GL_LINE_STRIP: - printf ("GL_LINE_STRIP)\n"); - break; - case GL_TRIANGLES: - printf ("GL_TRIANGLES)\n"); - break; - case GL_TRIANGLE_STRIP: - printf ("GL_TRIANGLE_STRIP)\n"); - break; - case GL_TRIANGLE_FAN: - printf ("GL_TRIANGLE_FAN)\n"); - break; - case GL_QUADS: - printf ("GL_QUADS)\n"); - break; - case GL_QUAD_STRIP: - printf ("GL_QUAD_STRIP)\n"); - break; - case GL_POLYGON: - printf ("GL_POLYGON)\n"); - break; - default: - break; - } -} - -static void CALLBACK endCallback() -{ - glEnd(); /* resubmit rendering directive */ - printf ("glEnd()\n"); -} - -static void CALLBACK vertexCallback(GLfloat *vertex) -{ - glVertex3fv(vertex); /* resubmit rendering directive */ - printf ("glVertex3f (%5.3f, %5.3f, %5.3f)\n", - vertex[0], vertex[1], vertex[2]); -} - -static void CALLBACK normalCallback(GLfloat *normal) -{ - glNormal3fv(normal); /* resubmit rendering directive */ - printf ("glNormal3f (%5.3f, %5.3f, %5.3f)\n", - normal[0], normal[1], normal[2]); -} - -/* Initialize material property and depth buffer. - */ -static void init(void) -{ - GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 }; - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat mat_shininess[] = { 100.0 }; - - glClearColor (0.0, 0.0, 0.0, 0.0); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); - glEnable(GL_AUTO_NORMAL); - glEnable(GL_NORMALIZE); - - init_surface(); - - theNurb = gluNewNurbsRenderer(); - gluNurbsProperty(theNurb, GLU_NURBS_MODE, - GLU_NURBS_TESSELLATOR); - gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0); - gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); - gluNurbsCallback(theNurb, GLU_ERROR, nurbsError); - gluNurbsCallback(theNurb, GLU_NURBS_BEGIN, beginCallback); - gluNurbsCallback(theNurb, GLU_NURBS_VERTEX, vertexCallback); - gluNurbsCallback(theNurb, GLU_NURBS_NORMAL, normalCallback); - gluNurbsCallback(theNurb, GLU_NURBS_END, endCallback); - -} - -static void display(void) -{ - GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0}; - int i, j; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix(); - glRotatef(330.0, 1.,0.,0.); - glScalef (0.5, 0.5, 0.5); - - gluBeginSurface(theNurb); - gluNurbsSurface(theNurb, - 8, knots, 8, knots, - 4 * 3, 3, &ctlpoints[0][0][0], - 4, 4, GL_MAP2_VERTEX_3); - gluEndSurface(theNurb); - - if (showPoints) { - glPointSize(5.0); - glDisable(GL_LIGHTING); - glColor3f(1.0, 1.0, 0.0); - glBegin(GL_POINTS); - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - glVertex3f(ctlpoints[i][j][0], - ctlpoints[i][j][1], ctlpoints[i][j][2]); - } - } - glEnd(); - glEnable(GL_LIGHTING); - } - glPopMatrix(); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective (45.0, (GLdouble)w/(GLdouble)h, 3.0, 8.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef (0.0, 0.0, -5.0); -} - -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 'c': - case 'C': - showPoints = !showPoints; - glutPostRedisplay(); - break; - case 27: - exit(0); - break; - default: - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow(argv[0]); - init(); - glutReshapeFunc(reshape); - glutDisplayFunc(display); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} - -#else -int main(int argc, char** argv) -{ - fprintf (stderr, "This program demonstrates a feature which is introduced in the\n"); - fprintf (stderr, "OpenGL Utility Library (GLU) Version 1.3.\n"); - fprintf (stderr, "If your implementation of GLU has the right extensions,\n"); - fprintf (stderr, "you may be able to modify this program to make it run.\n"); - return 0; -} -#endif - diff --git a/progs/redbook/teaambient.c b/progs/redbook/teaambient.c deleted file mode 100644 index 20ff1a4a33b..00000000000 --- a/progs/redbook/teaambient.c +++ /dev/null @@ -1,162 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/** - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/** - * teaambient.c - * This program renders three lighted, shaded teapots, with - * different ambient values. - */ -#include <stdlib.h> -#include <GL/glut.h> - -/* Initialize light source and lighting model. - */ -static void -myinit(void) -{ - GLfloat light_ambient[] = - {0.0, 0.0, 0.0, 1.0}; - GLfloat light_diffuse[] = - {1.0, 1.0, 1.0, 1.0}; - GLfloat light_specular[] = - {1.0, 1.0, 1.0, 1.0}; -/* light_position is NOT default value */ - GLfloat light_position[] = - {1.0, 0.0, 0.0, 0.0}; - GLfloat global_ambient[] = - {0.75, 0.75, 0.75, 1.0}; - - glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); - glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); - glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); - glLightfv(GL_LIGHT0, GL_POSITION, light_position); - - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient); - - glFrontFace(GL_CW); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_AUTO_NORMAL); - glEnable(GL_NORMALIZE); - glDepthFunc(GL_LESS); - glEnable(GL_DEPTH_TEST); -} - -static void -display(void) -{ - GLfloat low_ambient[] = - {0.1, 0.1, 0.1, 1.0}; - GLfloat more_ambient[] = - {0.4, 0.4, 0.4, 1.0}; - GLfloat most_ambient[] = - {1.0, 1.0, 1.0, 1.0}; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - /* material has small ambient reflection */ - glMaterialfv(GL_FRONT, GL_AMBIENT, low_ambient); - glMaterialf(GL_FRONT, GL_SHININESS, 40.0); - glPushMatrix(); - glTranslatef(0.0, 2.0, 0.0); - glutSolidTeapot(1.0); - glPopMatrix(); - - /* material has moderate ambient reflection */ - glMaterialfv(GL_FRONT, GL_AMBIENT, more_ambient); - glPushMatrix(); - glTranslatef(0.0, 0.0, 0.0); - glutSolidTeapot(1.0); - glPopMatrix(); - - /* material has large ambient reflection */ - glMaterialfv(GL_FRONT, GL_AMBIENT, most_ambient); - glPushMatrix(); - glTranslatef(0.0, -2.0, 0.0); - glutSolidTeapot(1.0); - glPopMatrix(); - glFlush(); -} - -static void -myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - glOrtho(-4.0, 4.0, -4.0 * (GLfloat) h / (GLfloat) w, - 4.0 * (GLfloat) h / (GLfloat) w, -10.0, 10.0); - else - glOrtho(-4.0 * (GLfloat) w / (GLfloat) h, - 4.0 * (GLfloat) w / (GLfloat) h, -4.0, 4.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, - * RGBA display mode, and handle input events. - */ -int -main(int argc, char **argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(500, 500); - glutCreateWindow(argv[0]); - 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 deleted file mode 100644 index 102c18a3e33..00000000000 --- a/progs/redbook/teapots.c +++ /dev/null @@ -1,220 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/** - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/** - * teapots.c - * This program demonstrates lots of material properties. - * A single light source illuminates the objects. - */ -#include <stdlib.h> -#include <GL/glut.h> - -/* - * Initialize depth buffer, projection matrix, light source, and lighting - * model. Do not specify a material property here. - */ -static 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}; - - 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); - - glFrontFace(GL_CW); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_AUTO_NORMAL); - glEnable(GL_NORMALIZE); - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); -} - -/* - * Move object into position. Use 3rd through 12th parameters to specify the - * material property. Draw a teapot. - */ -static void -renderTeapot(GLfloat x, GLfloat y, - 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, 0.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; - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); - mat[0] = specr; - mat[1] = specg; - mat[2] = specb; - glMaterialfv(GL_FRONT, GL_SPECULAR, mat); - glMaterialf(GL_FRONT, GL_SHININESS, shine * 128.0); - glutSolidTeapot(1.0); - glPopMatrix(); -} - -/** - * First column: emerald, jade, obsidian, pearl, ruby, turquoise - * 2nd column: brass, bronze, chrome, copper, gold, silver - * 3rd column: black, cyan, green, red, white, yellow plastic - * 4th column: black, cyan, green, red, white, yellow rubber - */ -static void -display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - renderTeapot(2.0, 17.0, 0.0215, 0.1745, 0.0215, - 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6); - renderTeapot(2.0, 14.0, 0.135, 0.2225, 0.1575, - 0.54, 0.89, 0.63, 0.316228, 0.316228, 0.316228, 0.1); - renderTeapot(2.0, 11.0, 0.05375, 0.05, 0.06625, - 0.18275, 0.17, 0.22525, 0.332741, 0.328634, 0.346435, 0.3); - renderTeapot(2.0, 8.0, 0.25, 0.20725, 0.20725, - 1, 0.829, 0.829, 0.296648, 0.296648, 0.296648, 0.088); - renderTeapot(2.0, 5.0, 0.1745, 0.01175, 0.01175, - 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6); - renderTeapot(2.0, 2.0, 0.1, 0.18725, 0.1745, - 0.396, 0.74151, 0.69102, 0.297254, 0.30829, 0.306678, 0.1); - renderTeapot(6.0, 17.0, 0.329412, 0.223529, 0.027451, - 0.780392, 0.568627, 0.113725, 0.992157, 0.941176, 0.807843, - 0.21794872); - renderTeapot(6.0, 14.0, 0.2125, 0.1275, 0.054, - 0.714, 0.4284, 0.18144, 0.393548, 0.271906, 0.166721, 0.2); - renderTeapot(6.0, 11.0, 0.25, 0.25, 0.25, - 0.4, 0.4, 0.4, 0.774597, 0.774597, 0.774597, 0.6); - renderTeapot(6.0, 8.0, 0.19125, 0.0735, 0.0225, - 0.7038, 0.27048, 0.0828, 0.256777, 0.137622, 0.086014, 0.1); - renderTeapot(6.0, 5.0, 0.24725, 0.1995, 0.0745, - 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4); - renderTeapot(6.0, 2.0, 0.19225, 0.19225, 0.19225, - 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4); - renderTeapot(10.0, 17.0, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01, - 0.50, 0.50, 0.50, .25); - renderTeapot(10.0, 14.0, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392, - 0.50196078, 0.50196078, 0.50196078, .25); - renderTeapot(10.0, 11.0, 0.0, 0.0, 0.0, - 0.1, 0.35, 0.1, 0.45, 0.55, 0.45, .25); - renderTeapot(10.0, 8.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, - 0.7, 0.6, 0.6, .25); - renderTeapot(10.0, 5.0, 0.0, 0.0, 0.0, 0.55, 0.55, 0.55, - 0.70, 0.70, 0.70, .25); - renderTeapot(10.0, 2.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, - 0.60, 0.60, 0.50, .25); - renderTeapot(14.0, 17.0, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01, - 0.4, 0.4, 0.4, .078125); - renderTeapot(14.0, 14.0, 0.0, 0.05, 0.05, 0.4, 0.5, 0.5, - 0.04, 0.7, 0.7, .078125); - renderTeapot(14.0, 11.0, 0.0, 0.05, 0.0, 0.4, 0.5, 0.4, - 0.04, 0.7, 0.04, .078125); - renderTeapot(14.0, 8.0, 0.05, 0.0, 0.0, 0.5, 0.4, 0.4, - 0.7, 0.04, 0.04, .078125); - renderTeapot(14.0, 5.0, 0.05, 0.05, 0.05, 0.5, 0.5, 0.5, - 0.7, 0.7, 0.7, .078125); - renderTeapot(14.0, 2.0, 0.05, 0.05, 0.0, 0.5, 0.5, 0.4, - 0.7, 0.7, 0.04, .078125); - glFlush(); -} - -static void -myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - glOrtho(0.0, 16.0, 0.0, 18.0 * (GLfloat) h / (GLfloat) w, - -10.0, 10.0); - else - glOrtho(0.0, 16.0 * (GLfloat) w / (GLfloat) h, 0.0, 18.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, RGBA display - * mode, and handle input events. - */ -int -main(int argc, char **argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutCreateWindow(argv[0]); - myinit(); - glutReshapeFunc(myReshape); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/tess.c b/progs/redbook/tess.c deleted file mode 100644 index 0bf8a8eb986..00000000000 --- a/progs/redbook/tess.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * tess.c - * This program demonstrates polygon tessellation. - * Two tesselated objects are drawn. The first is a - * rectangle with a triangular hole. The second is a - * smooth shaded, self-intersecting star. - * - * Note the exterior rectangle is drawn with its vertices - * in counter-clockwise order, but its interior clockwise. - * Note the combineCallback is needed for the self-intersecting - * star. Also note that removing the TessProperty for the - * star will make the interior unshaded (WINDING_ODD). - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -#ifdef GLU_VERSION_1_2 - -/* Win32 calling conventions. */ -#ifndef CALLBACK -#define CALLBACK -#endif - -GLuint startList; - -static void display (void) { - glClear(GL_COLOR_BUFFER_BIT); - glColor3f(1.0, 1.0, 1.0); - glCallList(startList); - glCallList(startList + 1); - glFlush(); -} - -static void CALLBACK beginCallback(GLenum which) -{ - glBegin(which); -} - -static void CALLBACK errorCallback(GLenum errorCode) -{ - const GLubyte *estring; - - estring = gluErrorString(errorCode); - fprintf(stderr, "Tessellation Error: %s\n", (char *) estring); - exit(0); -} - -static void CALLBACK endCallback(void) -{ - glEnd(); -} - -static void CALLBACK vertexCallback(GLvoid *vertex) -{ - const GLdouble *pointer; - - pointer = (GLdouble *) vertex; - glColor3dv(pointer+3); - glVertex3dv(pointer); -} - -/* combineCallback is used to create a new vertex when edges - * intersect. coordinate location is trivial to calculate, - * but weight[4] may be used to average color, normal, or texture - * coordinate data. In this program, color is weighted. - */ -static void CALLBACK combineCallback(GLdouble coords[3], - GLdouble *vertex_data[4], - GLfloat weight[4], GLdouble **dataOut ) -{ - GLdouble *vertex; - int i; - - vertex = (GLdouble *) malloc(6 * sizeof(GLdouble)); - - vertex[0] = coords[0]; - vertex[1] = coords[1]; - vertex[2] = coords[2]; - for (i = 3; i < 6; i++) - vertex[i] = weight[0] * vertex_data[0][i] - + weight[1] * vertex_data[1][i] - + weight[2] * vertex_data[2][i] - + weight[3] * vertex_data[3][i]; - *dataOut = vertex; -} - -static void init (void) -{ - GLUtesselator *tobj; - GLdouble rect[4][3] = {{50.0, 50.0, 0.0}, - {200.0, 50.0, 0.0}, - {200.0, 200.0, 0.0}, - {50.0, 200.0, 0.0}}; - GLdouble tri[3][3] = {{75.0, 75.0, 0.0}, - {125.0, 175.0, 0.0}, - {175.0, 75.0, 0.0}}; - GLdouble star[5][6] = {{250.0, 50.0, 0.0, 1.0, 0.0, 1.0}, - {325.0, 200.0, 0.0, 1.0, 1.0, 0.0}, - {400.0, 50.0, 0.0, 0.0, 1.0, 1.0}, - {250.0, 150.0, 0.0, 1.0, 0.0, 0.0}, - {400.0, 150.0, 0.0, 0.0, 1.0, 0.0}}; - - glClearColor(0.0, 0.0, 0.0, 0.0); - - startList = glGenLists(2); - - tobj = gluNewTess(); - gluTessCallback(tobj, GLU_TESS_VERTEX, - (GLvoid (CALLBACK*) ()) &glVertex3dv); - gluTessCallback(tobj, GLU_TESS_BEGIN, - (GLvoid (CALLBACK*) ()) &beginCallback); - gluTessCallback(tobj, GLU_TESS_END, - (GLvoid (CALLBACK*) ()) &endCallback); - gluTessCallback(tobj, GLU_TESS_ERROR, - (GLvoid (CALLBACK*) ()) &errorCallback); - - /* rectangle with triangular hole inside */ - glNewList(startList, GL_COMPILE); - glShadeModel(GL_FLAT); - gluTessBeginPolygon(tobj, NULL); - gluTessBeginContour(tobj); - gluTessVertex(tobj, rect[0], rect[0]); - gluTessVertex(tobj, rect[1], rect[1]); - gluTessVertex(tobj, rect[2], rect[2]); - gluTessVertex(tobj, rect[3], rect[3]); - gluTessEndContour(tobj); - gluTessBeginContour(tobj); - gluTessVertex(tobj, tri[0], tri[0]); - gluTessVertex(tobj, tri[1], tri[1]); - gluTessVertex(tobj, tri[2], tri[2]); - gluTessEndContour(tobj); - gluTessEndPolygon(tobj); - glEndList(); - - gluTessCallback(tobj, GLU_TESS_VERTEX, - (GLvoid (CALLBACK*) ()) &vertexCallback); - gluTessCallback(tobj, GLU_TESS_BEGIN, - (GLvoid (CALLBACK*) ()) &beginCallback); - gluTessCallback(tobj, GLU_TESS_END, - (GLvoid (CALLBACK*) ()) &endCallback); - gluTessCallback(tobj, GLU_TESS_ERROR, - (GLvoid (CALLBACK*) ()) &errorCallback); - gluTessCallback(tobj, GLU_TESS_COMBINE, - (GLvoid (CALLBACK*) ()) &combineCallback); - - /* smooth shaded, self-intersecting star */ - glNewList(startList + 1, GL_COMPILE); - glShadeModel(GL_SMOOTH); - gluTessProperty(tobj, GLU_TESS_WINDING_RULE, - GLU_TESS_WINDING_POSITIVE); - gluTessBeginPolygon(tobj, NULL); - gluTessBeginContour(tobj); - gluTessVertex(tobj, star[0], star[0]); - gluTessVertex(tobj, star[1], star[1]); - gluTessVertex(tobj, star[2], star[2]); - gluTessVertex(tobj, star[3], star[3]); - gluTessVertex(tobj, star[4], star[4]); - gluTessEndContour(tobj); - gluTessEndPolygon(tobj); - glEndList(); - gluDeleteTess(tobj); -} - -static void reshape (int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluOrtho2D(0.0, (GLdouble) w, 0.0, (GLdouble) h); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize(500, 500); - glutCreateWindow(argv[0]); - init(); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} - -#else -int main(int argc, char** argv) -{ - fprintf (stderr, "This program demonstrates the new tesselator API in GLU 1.2.\n"); - fprintf (stderr, "Your GLU library does not support this new interface, sorry.\n"); - return 0; -} -#endif diff --git a/progs/redbook/tesswind.c b/progs/redbook/tesswind.c deleted file mode 100644 index 4729880a57e..00000000000 --- a/progs/redbook/tesswind.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * tesswind.c - * This program demonstrates the winding rule polygon - * tessellation property. Four tessellated objects are drawn, - * each with very different contours. When the w key is pressed, - * the objects are drawn with a different winding rule. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -#ifdef GLU_VERSION_1_2 - -/* Win32 calling conventions. */ -#ifndef CALLBACK -#define CALLBACK -#endif - -GLdouble currentWinding = GLU_TESS_WINDING_ODD; -int currentShape = 0; -GLUtesselator *tobj; -GLuint list; - -/* Make four display lists, - * each with a different tessellated object. - */ -static void makeNewLists (void) { - int i; - static GLdouble rects[12][3] = - {{ 50.0, 50.0, 0.0}, {300.0, 50.0, 0.0}, - {300.0, 300.0, 0.0}, { 50.0, 300.0, 0.0}, - {100.0, 100.0, 0.0}, {250.0, 100.0, 0.0}, - {250.0, 250.0, 0.0}, {100.0, 250.0, 0.0}, - {150.0, 150.0, 0.0}, {200.0, 150.0, 0.0}, - {200.0, 200.0, 0.0}, {150.0, 200.0, 0.0}}; - static GLdouble spiral[16][3] = - {{400.0, 250.0, 0.0}, {400.0, 50.0, 0.0}, - { 50.0, 50.0, 0.0}, { 50.0, 400.0, 0.0}, - {350.0, 400.0, 0.0}, {350.0, 100.0, 0.0}, - {100.0, 100.0, 0.0}, {100.0, 350.0, 0.0}, - {300.0, 350.0, 0.0}, {300.0, 150.0, 0.0}, - {150.0, 150.0, 0.0}, {150.0, 300.0, 0.0}, - {250.0, 300.0, 0.0}, {250.0, 200.0, 0.0}, - {200.0, 200.0, 0.0}, {200.0, 250.0, 0.0}}; - static GLdouble quad1[4][3] = - {{ 50.0, 150.0, 0.0}, {350.0, 150.0, 0.0}, - {350.0, 200.0, 0.0}, { 50.0, 200.0, 0.0}}; - static GLdouble quad2[4][3] = - {{100.0, 100.0, 0.0}, {300.0, 100.0, 0.0}, - {300.0, 350.0, 0.0}, {100.0, 350.0, 0.0}}; - static GLdouble tri[3][3] = - {{200.0, 50.0, 0.0}, {250.0, 300.0, 0.0}, - {150.0, 300.0, 0.0}}; - - gluTessProperty(tobj, GLU_TESS_WINDING_RULE, - currentWinding); - - glNewList(list, GL_COMPILE); - gluTessBeginPolygon(tobj, NULL); - gluTessBeginContour(tobj); - for (i = 0; i < 4; i++) - gluTessVertex(tobj, rects[i], rects[i]); - gluTessEndContour(tobj); - gluTessBeginContour(tobj); - for (i = 4; i < 8; i++) - gluTessVertex(tobj, rects[i], rects[i]); - gluTessEndContour(tobj); - gluTessBeginContour(tobj); - for (i = 8; i < 12; i++) - gluTessVertex(tobj, rects[i], rects[i]); - gluTessEndContour(tobj); - gluTessEndPolygon(tobj); - glEndList(); - - glNewList(list+1, GL_COMPILE); - gluTessBeginPolygon(tobj, NULL); - gluTessBeginContour(tobj); - for (i = 0; i < 4; i++) - gluTessVertex(tobj, rects[i], rects[i]); - gluTessEndContour(tobj); - gluTessBeginContour(tobj); - for (i = 7; i >= 4; i--) - gluTessVertex(tobj, rects[i], rects[i]); - gluTessEndContour(tobj); - gluTessBeginContour(tobj); - for (i = 11; i >= 8; i--) - gluTessVertex(tobj, rects[i], rects[i]); - gluTessEndContour(tobj); - gluTessEndPolygon(tobj); - glEndList(); - - glNewList(list+2, GL_COMPILE); - gluTessBeginPolygon(tobj, NULL); - gluTessBeginContour(tobj); - for (i = 0; i < 16; i++) - gluTessVertex(tobj, spiral[i], spiral[i]); - gluTessEndContour(tobj); - gluTessEndPolygon(tobj); - glEndList(); - - glNewList(list+3, GL_COMPILE); - gluTessBeginPolygon(tobj, NULL); - gluTessBeginContour(tobj); - for (i = 0; i < 4; i++) - gluTessVertex(tobj, quad1[i], quad1[i]); - gluTessEndContour(tobj); - gluTessBeginContour(tobj); - for (i = 0; i < 4; i++) - gluTessVertex(tobj, quad2[i], quad2[i]); - gluTessEndContour(tobj); - gluTessBeginContour(tobj); - for (i = 0; i < 3; i++) - gluTessVertex(tobj, tri[i], tri[i]); - gluTessEndContour(tobj); - gluTessEndPolygon(tobj); - glEndList(); -} - -static void display (void) { - glClear(GL_COLOR_BUFFER_BIT); - glColor3f(1.0, 1.0, 1.0); - glPushMatrix(); - glCallList(list); - glTranslatef(0.0, 500.0, 0.0); - glCallList(list+1); - glTranslatef(500.0, -500.0, 0.0); - glCallList(list+2); - glTranslatef(0.0, 500.0, 0.0); - glCallList(list+3); - glPopMatrix(); - glFlush(); -} - -static void CALLBACK beginCallback(GLenum which) -{ - glBegin(which); -} - -static void CALLBACK errorCallback(GLenum errorCode) -{ - const GLubyte *estring; - - estring = gluErrorString(errorCode); - fprintf(stderr, "Tessellation Error: %s\n", (char *) estring); - exit(0); -} - -static void CALLBACK endCallback(void) -{ - glEnd(); -} - -/* combineCallback is used to create a new vertex when edges - * intersect. coordinate location is trivial to calculate, - * but weight[4] may be used to average color, normal, or texture - * coordinate data. - */ -/* ARGSUSED */ -static void CALLBACK combineCallback(GLdouble coords[3], GLdouble *data[4], - GLfloat weight[4], GLdouble **dataOut ) -{ - GLdouble *vertex; - vertex = (GLdouble *) malloc(3 * sizeof(GLdouble)); - - vertex[0] = coords[0]; - vertex[1] = coords[1]; - vertex[2] = coords[2]; - *dataOut = vertex; -} - -static void init(void) -{ - glClearColor(0.0, 0.0, 0.0, 0.0); - glShadeModel(GL_FLAT); - - tobj = gluNewTess(); - gluTessCallback(tobj, GLU_TESS_VERTEX, - (GLvoid (CALLBACK*) ()) &glVertex3dv); - gluTessCallback(tobj, GLU_TESS_BEGIN, - (GLvoid (CALLBACK*) ()) &beginCallback); - gluTessCallback(tobj, GLU_TESS_END, - (GLvoid (CALLBACK*) ()) &endCallback); - gluTessCallback(tobj, GLU_TESS_ERROR, - (GLvoid (CALLBACK*) ()) &errorCallback); - gluTessCallback(tobj, GLU_TESS_COMBINE, - (GLvoid (CALLBACK*) ()) &combineCallback); - - list = glGenLists(4); - makeNewLists(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - gluOrtho2D(0.0, 1000.0, 0.0, 1000.0 * (GLdouble)h/(GLdouble)w); - else - gluOrtho2D(0.0, 1000.0 * (GLdouble)w/(GLdouble)h, 0.0, 1000.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 'w': - case 'W': - if (currentWinding == GLU_TESS_WINDING_ODD) - currentWinding = GLU_TESS_WINDING_NONZERO; - else if (currentWinding == GLU_TESS_WINDING_NONZERO) - currentWinding = GLU_TESS_WINDING_POSITIVE; - else if (currentWinding == GLU_TESS_WINDING_POSITIVE) - currentWinding = GLU_TESS_WINDING_NEGATIVE; - else if (currentWinding == GLU_TESS_WINDING_NEGATIVE) - currentWinding = GLU_TESS_WINDING_ABS_GEQ_TWO; - else if (currentWinding == GLU_TESS_WINDING_ABS_GEQ_TWO) - currentWinding = GLU_TESS_WINDING_ODD; - makeNewLists(); - glutPostRedisplay(); - break; - case 27: - exit(0); - break; - default: - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize(500, 500); - glutCreateWindow(argv[0]); - init(); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} - -#else -int main(int argc, char** argv) -{ - fprintf (stderr, "This program demonstrates the new tesselator API in GLU 1.2.\n"); - fprintf (stderr, "Your GLU library does not support this new interface, sorry.\n"); - return 0; -} -#endif diff --git a/progs/redbook/texbind.c b/progs/redbook/texbind.c deleted file mode 100644 index b6404b32d8c..00000000000 --- a/progs/redbook/texbind.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* texbind.c - * This program demonstrates using glBindTexture() by - * creating and managing two textures. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -#ifdef GL_VERSION_1_1 -/* Create checkerboard texture */ -#define checkImageWidth 64 -#define checkImageHeight 64 -static GLubyte checkImage[checkImageHeight][checkImageWidth][4]; -static GLubyte otherImage[checkImageHeight][checkImageWidth][4]; - -static GLuint texName[2]; - -static 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; - 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; - otherImage[i][j][0] = (GLubyte) c; - otherImage[i][j][1] = (GLubyte) 0; - otherImage[i][j][2] = (GLubyte) 0; - otherImage[i][j][3] = (GLubyte) 255; - } - } -} - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel(GL_FLAT); - glEnable(GL_DEPTH_TEST); - - makeCheckImages(); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glGenTextures(2, texName); - 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, - GL_NEAREST); - 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, - checkImage); - - glBindTexture(GL_TEXTURE_2D, texName[1]); - 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, 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, - otherImage); - glEnable(GL_TEXTURE_2D); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glBindTexture(GL_TEXTURE_2D, texName[0]); - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); - glTexCoord2f(0.0, 1.0); glVertex3f(-2.0, 1.0, 0.0); - glTexCoord2f(1.0, 1.0); glVertex3f(0.0, 1.0, 0.0); - glTexCoord2f(1.0, 0.0); glVertex3f(0.0, -1.0, 0.0); - glEnd(); - glBindTexture(GL_TEXTURE_2D, texName[1]); - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); - glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 1.0, 0.0); - glTexCoord2f(1.0, 1.0); glVertex3f(2.41421, 1.0, -1.41421); - glTexCoord2f(1.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); - glEnd(); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 30.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -3.6); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(250, 250); - glutInitWindowPosition(100, 100); - glutCreateWindow(argv[0]); - init(); - glutReshapeFunc(reshape); - glutDisplayFunc(display); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} -#else -int main(int argc, char** argv) -{ - fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0.\n"); - fprintf (stderr, "If your implementation of OpenGL Version 1.0 has the right extensions,\n"); - fprintf (stderr, "you may be able to modify this program to make it run.\n"); - return 0; -} -#endif diff --git a/progs/redbook/texgen.c b/progs/redbook/texgen.c deleted file mode 100644 index 5cb97e5a43d..00000000000 --- a/progs/redbook/texgen.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* texgen.c - * This program draws a texture mapped teapot with - * automatically generated texture coordinates. The - * texture is rendered as stripes on the teapot. - * Initially, the object is drawn with texture coordinates - * based upon the object coordinates of the vertex - * and distance from the plane x = 0. Pressing the 'e' - * key changes the coordinate generation to eye coordinates - * of the vertex. Pressing the 'o' key switches it back - * to the object coordinates. Pressing the 's' key - * changes the plane to a slanted one (x + y + z = 0). - * Pressing the 'x' key switches it back to x = 0. - */ - -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -#define stripeImageWidth 32 -GLubyte stripeImage[4*stripeImageWidth]; - -#ifdef GL_VERSION_1_1 -static GLuint texName; -#endif - -static void makeStripeImage(void) -{ - int j; - - for (j = 0; j < stripeImageWidth; j++) { - stripeImage[4*j] = (GLubyte) ((j<=4) ? 255 : 0); - stripeImage[4*j+1] = (GLubyte) ((j>4) ? 255 : 0); - stripeImage[4*j+2] = (GLubyte) 0; - stripeImage[4*j+3] = (GLubyte) 255; - } -} - -/* planes for texture coordinate generation */ -static GLfloat xequalzero[] = {1.0, 0.0, 0.0, 0.0}; -static GLfloat slanted[] = {1.0, 1.0, 1.0, 0.0}; -static GLfloat *currentCoeff; -static GLenum currentPlane; -static GLint currentGenMode; - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glEnable(GL_DEPTH_TEST); - glShadeModel(GL_SMOOTH); - - makeStripeImage(); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - -#ifdef GL_VERSION_1_1 - glGenTextures(1, &texName); - glBindTexture(GL_TEXTURE_1D, texName); -#endif - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); -#ifdef GL_VERSION_1_1 - glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, stripeImageWidth, 0, - GL_RGBA, GL_UNSIGNED_BYTE, stripeImage); -#else - glTexImage1D(GL_TEXTURE_1D, 0, 4, stripeImageWidth, 0, - GL_RGBA, GL_UNSIGNED_BYTE, stripeImage); -#endif - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - currentCoeff = xequalzero; - currentGenMode = GL_OBJECT_LINEAR; - currentPlane = GL_OBJECT_PLANE; - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, currentGenMode); - glTexGenfv(GL_S, currentPlane, currentCoeff); - - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_1D); - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_AUTO_NORMAL); - glEnable(GL_NORMALIZE); - glFrontFace(GL_CW); - glCullFace(GL_BACK); - glMaterialf (GL_FRONT, GL_SHININESS, 64.0); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix (); - glRotatef(45.0, 0.0, 0.0, 1.0); -#ifdef GL_VERSION_1_1 - glBindTexture(GL_TEXTURE_1D, texName); -#endif - glutSolidTeapot(2.0); - glPopMatrix (); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - glOrtho (-3.5, 3.5, -3.5*(GLfloat)h/(GLfloat)w, - 3.5*(GLfloat)h/(GLfloat)w, -3.5, 3.5); - else - glOrtho (-3.5*(GLfloat)w/(GLfloat)h, - 3.5*(GLfloat)w/(GLfloat)h, -3.5, 3.5, -3.5, 3.5); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -/* ARGSUSED1 */ -static void keyboard (unsigned char key, int x, int y) -{ - switch (key) { - case 'e': - case 'E': - currentGenMode = GL_EYE_LINEAR; - currentPlane = GL_EYE_PLANE; - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, currentGenMode); - glTexGenfv(GL_S, currentPlane, currentCoeff); - glutPostRedisplay(); - break; - case 'o': - case 'O': - currentGenMode = GL_OBJECT_LINEAR; - currentPlane = GL_OBJECT_PLANE; - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, currentGenMode); - glTexGenfv(GL_S, currentPlane, currentCoeff); - glutPostRedisplay(); - break; - case 's': - case 'S': - currentCoeff = slanted; - glTexGenfv(GL_S, currentPlane, currentCoeff); - glutPostRedisplay(); - break; - case 'x': - case 'X': - currentCoeff = xequalzero; - glTexGenfv(GL_S, currentPlane, currentCoeff); - glutPostRedisplay(); - break; - case 27: - exit(0); - break; - default: - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(256, 256); - glutInitWindowPosition(100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/texprox.c b/progs/redbook/texprox.c deleted file mode 100644 index c2d699a71b2..00000000000 --- a/progs/redbook/texprox.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * texprox.c - * The brief program illustrates use of texture proxies. - * This program only prints out some messages about whether - * certain size textures are supported and then exits. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -#ifdef GL_VERSION_1_1 - -/* Microsoft OpenGL 1.1's <GL/gl.h> forgets to define - GL_TEXTURE_INTERNAL_FORMAT. */ -#ifndef GL_TEXTURE_INTERNAL_FORMAT -#define GL_TEXTURE_INTERNAL_FORMAT GL_TEXTURE_COMPONENTS -#endif - -static void init(void) -{ - GLint proxyComponents; - - putchar('\n'); - - glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, - 64, 64, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, - GL_TEXTURE_INTERNAL_FORMAT, &proxyComponents); - printf ("Proxying 64x64 level 0 RGBA8 texture (level 0)\n"); - if (proxyComponents == GL_RGBA8) - printf ("proxy allocation succeeded\n"); - else - printf ("proxy allocation failed\n"); - putchar('\n'); - - glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA16, - 2048, 2048, 0, - GL_RGBA, GL_UNSIGNED_SHORT, NULL); - glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, - GL_TEXTURE_INTERNAL_FORMAT, &proxyComponents); - printf ("Proxying 2048x2048 level 0 RGBA16 texture (big so unlikely to be supported)\n"); - if (proxyComponents == GL_RGBA16) - printf ("proxy allocation succeeded\n"); - else - printf ("proxy allocation failed\n"); - putchar('\n'); -} - -static void display(void) -{ - exit(0); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutMainLoop(); - return 0; -} -#else -int main(int argc, char** argv) -{ - fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0.\n"); - fprintf (stderr, "If your implementation of OpenGL Version 1.0 has the right extensions,\n"); - fprintf (stderr, "you may be able to modify this program to make it run.\n"); - return 0; -} -#endif diff --git a/progs/redbook/texsub.c b/progs/redbook/texsub.c deleted file mode 100644 index 7827d5a45f3..00000000000 --- a/progs/redbook/texsub.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* texsub.c - * This program texture maps a checkerboard image onto - * 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, - * the original texture is restored. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -#ifdef GL_VERSION_1_1 -/* Create checkerboard textures */ -#define checkImageWidth 64 -#define checkImageHeight 64 -#define subImageWidth 16 -#define subImageHeight 16 -static GLubyte checkImage[checkImageHeight][checkImageWidth][4]; -static GLubyte subImage[subImageHeight][subImageWidth][4]; - -static GLuint texName; - -static 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; - checkImage[i][j][0] = (GLubyte) c; - checkImage[i][j][1] = (GLubyte) c; - checkImage[i][j][2] = (GLubyte) c; - checkImage[i][j][3] = (GLubyte) 255; - } - } - for (i = 0; i < subImageHeight; i++) { - for (j = 0; j < subImageWidth; j++) { - 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; - subImage[i][j][3] = (GLubyte) 255; - } - } -} - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel(GL_FLAT); - glEnable(GL_DEPTH_TEST); - - makeCheckImages(); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glGenTextures(1, &texName); - glBindTexture(GL_TEXTURE_2D, texName); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - 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, - 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glEnable(GL_TEXTURE_2D); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); - glBindTexture(GL_TEXTURE_2D, texName); - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); - glTexCoord2f(0.0, 1.0); glVertex3f(-2.0, 1.0, 0.0); - glTexCoord2f(1.0, 1.0); glVertex3f(0.0, 1.0, 0.0); - glTexCoord2f(1.0, 0.0); glVertex3f(0.0, -1.0, 0.0); - - glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); - glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 1.0, 0.0); - glTexCoord2f(1.0, 1.0); glVertex3f(2.41421, 1.0, -1.41421); - glTexCoord2f(1.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); - glEnd(); - glFlush(); - glDisable(GL_TEXTURE_2D); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 30.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -3.6); -} - -/* ARGSUSED1 */ -static void keyboard (unsigned char key, int x, int y) -{ - switch (key) { - case 's': - case 'S': - glBindTexture(GL_TEXTURE_2D, texName); - glTexSubImage2D(GL_TEXTURE_2D, 0, 12, 44, subImageWidth, - subImageHeight, GL_RGBA, - GL_UNSIGNED_BYTE, subImage); - glutPostRedisplay(); - break; - case 'r': - case 'R': - glBindTexture(GL_TEXTURE_2D, texName); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, - checkImageHeight, 0, GL_RGBA, - GL_UNSIGNED_BYTE, checkImage); - glutPostRedisplay(); - break; - case 27: - exit(0); - break; - default: - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(250, 250); - glutInitWindowPosition(100, 100); - glutCreateWindow(argv[0]); - init(); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} -#else -int main(int argc, char** argv) -{ - fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0.\n"); - fprintf (stderr, "If your implementation of OpenGL Version 1.0 has the right extensions,\n"); - fprintf (stderr, "you may be able to modify this program to make it run.\n"); - return 0; -} -#endif diff --git a/progs/redbook/texture3d.c b/progs/redbook/texture3d.c deleted file mode 100644 index c7b77c1caeb..00000000000 --- a/progs/redbook/texture3d.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 1993-2003, Silicon Graphics, Inc. - * 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 the name of Silicon Graphics, Inc. not be used in - * advertising or publicity pertaining to distribution of the software - * without specific, 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF - * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD - * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor clauses - * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights - * reserved under the copyright laws of the United States. - * - * Contractor/manufacturer is: - * Silicon Graphics, Inc. - * 1500 Crittenden Lane - * Mountain View, CA 94043 - * United State of America - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* texture3d.c - * This program demonstrates using a three-dimensional texture. - * It creates a 3D texture and then renders two rectangles - * with different texture coordinates to obtain different - * "slices" of the 3D texture. - */ -#include <GL/glew.h> -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -#ifdef GL_VERSION_1_2 -#define iWidth 16 -#define iHeight 16 -#define iDepth 16 - -static GLubyte image[iDepth][iHeight][iWidth][3]; -static GLuint texName; - -/* Create a 16x16x16x3 array with different color values in - * each array element [r, g, b]. Values range from 0 to 255. - */ - -static void makeImage(void) -{ - int s, t, r; - - for (s = 0; s < 16; s++) - for (t = 0; t < 16; t++) - for (r = 0; r < 16; r++) { - image[r][t][s][0] = (GLubyte) (s * 17); - image[r][t][s][1] = (GLubyte) (t * 17); - image[r][t][s][2] = (GLubyte) (r * 17); - } -} - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel(GL_FLAT); - glEnable(GL_DEPTH_TEST); - - makeImage(); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glGenTextures(1, &texName); - glBindTexture(GL_TEXTURE_3D, texName); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, - GL_NEAREST); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, - GL_NEAREST); - glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, iWidth, iHeight, - iDepth, 0, GL_RGB, GL_UNSIGNED_BYTE, image); - glEnable(GL_TEXTURE_3D); -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glBegin(GL_QUADS); - glTexCoord3f(0.0, 0.0, 0.0); glVertex3f(-2.25, -1.0, 0.0); - glTexCoord3f(0.0, 1.0, 0.0); glVertex3f(-2.25, 1.0, 0.0); - glTexCoord3f(1.0, 1.0, 1.0); glVertex3f(-0.25, 1.0, 0.0); - glTexCoord3f(1.0, 0.0, 1.0); glVertex3f(-0.25, -1.0, 0.0); - - glTexCoord3f(0.0, 0.0, 1.0); glVertex3f(0.25, -1.0, 0.0); - glTexCoord3f(0.0, 1.0, 1.0); glVertex3f(0.25, 1.0, 0.0); - glTexCoord3f(1.0, 1.0, 0.0); glVertex3f(2.25, 1.0, 0.0); - glTexCoord3f(1.0, 0.0, 0.0); glVertex3f(2.25, -1.0, 0.0); - glEnd(); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 30.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -4.0); -} - -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(250, 250); - glutInitWindowPosition(100, 100); - glutCreateWindow(argv[0]); - glewInit(); - init(); - glutReshapeFunc(reshape); - glutDisplayFunc(display); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} -#else -int main(int argc, char** argv) -{ - fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0 or 1.1.\n"); - fprintf (stderr, "If your implementation of OpenGL has the right extensions,\n"); - fprintf (stderr, "you may be able to modify this program to make it run.\n"); - return 0; -} -#endif - diff --git a/progs/redbook/texturesurf.c b/progs/redbook/texturesurf.c deleted file mode 100644 index 2023072dba8..00000000000 --- a/progs/redbook/texturesurf.c +++ /dev/null @@ -1,155 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/* - * (c) Copyright 1993, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(TM) is a trademark of Silicon Graphics, Inc. - */ -/* texturesurf.c - * This program uses evaluators to generate a curved - * surface and automatically generated texture coordinates. - */ - -#include <stdlib.h> -#include <GL/glut.h> -#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}, - {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}}, - {{1.0, 0.0}, {1.0, 1.0}}}; - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glColor3f(1.0, 1.0, 1.0); - glEvalMesh2(GL_FILL, 0, 20, 0, 20); - glFlush(); -} - -#define imageWidth 64 -#define imageHeight 64 -GLubyte image[3*imageWidth*imageHeight]; - -static 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++) { - tj = 2.0*3.14159265*j/imageHeight; - - image[3*(imageHeight*i+j)] = (GLubyte) 127*(1.0+sin(ti)); - image[3*(imageHeight*i+j)+1] = (GLubyte) 127*(1.0+cos(2*tj)); - image[3*(imageHeight*i+j)+2] = (GLubyte) 127*(1.0+cos(ti+tj)); - } - } -} - -static 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, - 0, 1, 4, 2, &texpts[0][0][0]); - glEnable(GL_MAP2_TEXTURE_COORD_2); - glEnable(GL_MAP2_VERTEX_3); - glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0); - makeImage(); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); - 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, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, 3, imageWidth, imageHeight, 0, - GL_RGB, GL_UNSIGNED_BYTE, image); - glEnable(GL_TEXTURE_2D); - glEnable(GL_DEPTH_TEST); - glEnable(GL_NORMALIZE); - glShadeModel (GL_FLAT); -} - -static void myReshape(int w, int h) -{ - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - 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, - 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); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutCreateWindow (argv[0]); - myinit(); - glutReshapeFunc (myReshape); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutMainLoop(); - return 0; /* ANSI C requires main to return int. */ -} diff --git a/progs/redbook/torus.c b/progs/redbook/torus.c deleted file mode 100644 index a67d48e0f59..00000000000 --- a/progs/redbook/torus.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * torus.c - * This program demonstrates the creation of a display list. - */ - -#include <GL/glut.h> -#include <stdio.h> -#include <math.h> -#include <stdlib.h> - -/* Some <math.h> files do not define M_PI... */ -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -GLuint theTorus; - -/* Draw a torus */ -static void torus(int numc, int numt) -{ - int i, j, k; - double s, t, x, y, z, twopi; - - twopi = 2 * (double)M_PI; - for (i = 0; i < numc; i++) { - glBegin(GL_QUAD_STRIP); - for (j = 0; j <= numt; j++) { - for (k = 1; k >= 0; k--) { - s = (i + k) % numc + 0.5; - t = j % numt; - - x = (1+.1*cos(s*twopi/numc))*cos(t*twopi/numt); - y = (1+.1*cos(s*twopi/numc))*sin(t*twopi/numt); - z = .1 * sin(s * twopi / numc); - glVertex3f(x, y, z); - } - } - glEnd(); - } -} - -/* Create display list with Torus and initialize state */ -static void init(void) -{ - theTorus = glGenLists (1); - glNewList(theTorus, GL_COMPILE); - torus(8, 25); - glEndList(); - - glShadeModel(GL_FLAT); - glClearColor(0.0, 0.0, 0.0, 0.0); -} - -/* Clear window and draw torus */ -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - glColor3f (1.0, 1.0, 1.0); - glCallList(theTorus); - glFlush(); -} - -/* Handle window resize */ -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(30, (GLfloat) w/(GLfloat) h, 1.0, 100.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0); -} - -/* Rotate about x-axis when "x" typed; rotate about y-axis - when "y" typed; "i" returns torus to original view */ -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 'x': - case 'X': - glRotatef(30.,1.0,0.0,0.0); - glutPostRedisplay(); - break; - case 'y': - case 'Y': - glRotatef(30.,0.0,1.0,0.0); - glutPostRedisplay(); - break; - case 'i': - case 'I': - glLoadIdentity(); - gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0); - glutPostRedisplay(); - break; - case 27: - exit(0); - break; - } -} - -int main(int argc, char **argv) -{ - glutInitWindowSize(200, 200); - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - glutCreateWindow(argv[0]); - init(); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutDisplayFunc(display); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/trim.c b/progs/redbook/trim.c deleted file mode 100644 index 216f62a7c2f..00000000000 --- a/progs/redbook/trim.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * trim.c - * This program draws a NURBS surface in the shape of a - * symmetrical hill, using both a NURBS curve and pwl - * (piecewise linear) curve to trim part of the surface. - */ -#include <stdlib.h> -#include <GL/glut.h> -#include <stdio.h> - - -#ifndef CALLBACK -#define CALLBACK -#endif - - -GLfloat ctlpoints[4][4][3]; - -GLUnurbsObj *theNurb; - -/* - * Initializes the control points of the surface to a small hill. - * The control points range from -3 to +3 in x, y, and z - */ -static void init_surface(void) -{ - int u, v; - for (u = 0; u < 4; u++) { - for (v = 0; v < 4; v++) { - ctlpoints[u][v][0] = 2.0*((GLfloat)u - 1.5); - ctlpoints[u][v][1] = 2.0*((GLfloat)v - 1.5); - - if ( (u == 1 || u == 2) && (v == 1 || v == 2)) - ctlpoints[u][v][2] = 3.0; - else - ctlpoints[u][v][2] = -3.0; - } - } -} - -static void nurbsError(GLenum errorCode) -{ - const GLubyte *estring; - - estring = gluErrorString(errorCode); - fprintf (stderr, "Nurbs Error: %s\n", (char *) estring); - exit (0); -} - -/* Initialize material property and depth buffer. - */ -static void init(void) -{ - GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 }; - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat mat_shininess[] = { 100.0 }; - - glClearColor (0.0, 0.0, 0.0, 0.0); - glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); - glEnable(GL_AUTO_NORMAL); - glEnable(GL_NORMALIZE); - - init_surface(); - - theNurb = gluNewNurbsRenderer(); - gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0); - gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); - gluNurbsCallback(theNurb, GLU_ERROR, - (GLvoid (CALLBACK*) ()) nurbsError); -} - -static void display(void) -{ - GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0}; - GLfloat edgePt[5][2] = /* counter clockwise */ - {{0.0, 0.0}, {1.0, 0.0}, {1.0, 1.0}, {0.0, 1.0}, {0.0, 0.0}}; - GLfloat curvePt[4][2] = /* clockwise */ - {{0.25, 0.5}, {0.25, 0.75}, {0.75, 0.75}, {0.75, 0.5}}; - GLfloat curveKnots[8] = - {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0}; - GLfloat pwlPt[4][2] = /* clockwise */ - {{0.75, 0.5}, {0.5, 0.25}, {0.25, 0.5}}; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glPushMatrix(); - glRotatef(330.0, 1.,0.,0.); - glScalef (0.5, 0.5, 0.5); - - gluBeginSurface(theNurb); - gluNurbsSurface(theNurb, 8, knots, 8, knots, - 4 * 3, 3, &ctlpoints[0][0][0], - 4, 4, GL_MAP2_VERTEX_3); - gluBeginTrim (theNurb); - gluPwlCurve (theNurb, 5, &edgePt[0][0], 2, GLU_MAP1_TRIM_2); - gluEndTrim (theNurb); - gluBeginTrim (theNurb); - gluNurbsCurve (theNurb, 8, curveKnots, 2, - &curvePt[0][0], 4, GLU_MAP1_TRIM_2); - gluPwlCurve (theNurb, 3, &pwlPt[0][0], 2, GLU_MAP1_TRIM_2); - gluEndTrim (theNurb); - gluEndSurface(theNurb); - - glPopMatrix(); - glFlush(); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective (45.0, (GLdouble)w/(GLdouble)h, 3.0, 8.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef (0.0, 0.0, -5.0); -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -/* Main Loop - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow(argv[0]); - init(); - glutReshapeFunc(reshape); - glutDisplayFunc(display); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/unproject.c b/progs/redbook/unproject.c deleted file mode 100644 index 6d1c7dbeded..00000000000 --- a/progs/redbook/unproject.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * unproject.c - * When the left mouse button is pressed, this program - * reads the mouse position and determines two 3D points - * from which it was transformed. Very little is displayed. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - glFlush(); -} - -/* Change these values for a different transformation */ -static void reshape(int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective (45.0, (GLfloat) w/(GLfloat) h, 1.0, 100.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -static void mouse(int button, int state, int x, int y) -{ - GLint viewport[4]; - GLdouble mvmatrix[16], projmatrix[16]; - GLint realy; /* OpenGL y coordinate position */ - GLdouble wx, wy, wz; /* returned world x, y, z coords */ - - switch (button) { - case GLUT_LEFT_BUTTON: - if (state == GLUT_DOWN) { - glGetIntegerv (GL_VIEWPORT, viewport); - glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix); - glGetDoublev (GL_PROJECTION_MATRIX, projmatrix); -/* note viewport[3] is height of window in pixels */ - realy = viewport[3] - (GLint) y - 1; - printf ("Coordinates at cursor are (%4d, %4d)\n", x, realy); - gluUnProject ((GLdouble) x, (GLdouble) realy, 0.0, - mvmatrix, projmatrix, viewport, &wx, &wy, &wz); - printf ("World coords at z=0.0 are (%f, %f, %f)\n", - wx, wy, wz); - gluUnProject ((GLdouble) x, (GLdouble) realy, 1.0, - mvmatrix, projmatrix, viewport, &wx, &wy, &wz); - printf ("World coords at z=1.0 are (%f, %f, %f)\n", - wx, wy, wz); - } - break; - case GLUT_RIGHT_BUTTON: - if (state == GLUT_DOWN) - exit(0); - break; - default: - break; - } -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -/* - * Open window, register input callback functions - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (500, 500); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc (keyboard); - glutMouseFunc(mouse); - glutMainLoop(); - return 0; -} diff --git a/progs/redbook/varray.c b/progs/redbook/varray.c deleted file mode 100644 index 8ce39d77633..00000000000 --- a/progs/redbook/varray.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * varray.c - * This program demonstrates vertex arrays. - */ -#include <GL/glut.h> -#include <stdio.h> -#include <stdlib.h> - -#ifdef GL_VERSION_1_1 -#define POINTER 1 -#define INTERLEAVED 2 - -#define DRAWARRAY 1 -#define ARRAYELEMENT 2 -#define DRAWELEMENTS 3 - -int setupMethod = POINTER; -int derefMethod = DRAWARRAY; - -static void setupPointers(void) -{ - static GLint vertices[] = {25, 25, - 100, 325, - 175, 25, - 175, 325, - 250, 25, - 325, 325}; - static GLfloat colors[] = {1.0, 0.2, 0.2, - 0.2, 0.2, 1.0, - 0.8, 1.0, 0.2, - 0.75, 0.75, 0.75, - 0.35, 0.35, 0.35, - 0.5, 0.5, 0.5}; - - glEnableClientState (GL_VERTEX_ARRAY); - glEnableClientState (GL_COLOR_ARRAY); - - glVertexPointer (2, GL_INT, 0, vertices); - glColorPointer (3, GL_FLOAT, 0, colors); -} - -static void setupInterleave(void) -{ - static GLfloat intertwined[] = - {1.0, 0.2, 1.0, 100.0, 100.0, 0.0, - 1.0, 0.2, 0.2, 0.0, 200.0, 0.0, - 1.0, 1.0, 0.2, 100.0, 300.0, 0.0, - 0.2, 1.0, 0.2, 200.0, 300.0, 0.0, - 0.2, 1.0, 1.0, 300.0, 200.0, 0.0, - 0.2, 0.2, 1.0, 200.0, 100.0, 0.0}; - - glInterleavedArrays (GL_C3F_V3F, 0, intertwined); -} - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel (GL_SMOOTH); - setupPointers (); -} - -static void display(void) -{ - glClear (GL_COLOR_BUFFER_BIT); - - if (derefMethod == DRAWARRAY) - glDrawArrays (GL_TRIANGLES, 0, 6); - else if (derefMethod == ARRAYELEMENT) { - glBegin (GL_TRIANGLES); - glArrayElement (2); - glArrayElement (3); - glArrayElement (5); - glEnd (); - } - else if (derefMethod == DRAWELEMENTS) { - GLuint indices[4] = {0, 1, 3, 4}; - - glDrawElements (GL_POLYGON, 4, GL_UNSIGNED_INT, indices); - } - glFlush (); -} - -static void reshape (int w, int h) -{ - glViewport (0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h); -} - -/* ARGSUSED2 */ -static void mouse (int button, int state, int x, int y) -{ - switch (button) { - case GLUT_LEFT_BUTTON: - if (state == GLUT_DOWN) { - if (setupMethod == POINTER) { - setupMethod = INTERLEAVED; - setupInterleave(); - } - else if (setupMethod == INTERLEAVED) { - setupMethod = POINTER; - setupPointers(); - } - glutPostRedisplay(); - } - break; - case GLUT_MIDDLE_BUTTON: - case GLUT_RIGHT_BUTTON: - if (state == GLUT_DOWN) { - if (derefMethod == DRAWARRAY) - derefMethod = ARRAYELEMENT; - else if (derefMethod == ARRAYELEMENT) - derefMethod = DRAWELEMENTS; - else if (derefMethod == DRAWELEMENTS) - derefMethod = DRAWARRAY; - glutPostRedisplay(); - } - break; - default: - break; - } -} - -/* ARGSUSED1 */ -static void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (350, 350); - glutInitWindowPosition (100, 100); - glutCreateWindow (argv[0]); - init (); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutMouseFunc(mouse); - glutKeyboardFunc (keyboard); - glutMainLoop(); - return 0; -} -#else -int main(int argc, char** argv) -{ - fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0.\n"); - fprintf (stderr, "If your implementation of OpenGL Version 1.0 has the right extensions,\n"); - fprintf (stderr, "you may be able to modify this program to make it run.\n"); - return 0; -} -#endif diff --git a/progs/redbook/wrap.c b/progs/redbook/wrap.c deleted file mode 100644 index 67749716e83..00000000000 --- a/progs/redbook/wrap.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * 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 - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * 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, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * 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 - * 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 - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* wrap.c - * This program texture maps a checkerboard image onto - * two rectangles. This program demonstrates the wrapping - * modes, if the texture coordinates fall outside 0.0 and 1.0. - * Interaction: Pressing the 's' and 'S' keys switch the - * wrapping between clamping and repeating for the s parameter. - * The 't' and 'T' keys control the wrapping for the t parameter. - * - * If running this program on OpenGL 1.0, texture objects are - * not used. - */ -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -/* Create checkerboard texture */ -#define checkImageWidth 64 -#define checkImageHeight 64 -static GLubyte checkImage[checkImageHeight][checkImageWidth][4]; - -#ifdef GL_VERSION_1_1 -static GLuint texName; -#endif - -static void makeCheckImage(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; - checkImage[i][j][0] = (GLubyte) c; - checkImage[i][j][1] = (GLubyte) c; - checkImage[i][j][2] = (GLubyte) c; - checkImage[i][j][3] = (GLubyte) 255; - } - } -} - -static void init(void) -{ - glClearColor (0.0, 0.0, 0.0, 0.0); - glShadeModel(GL_FLAT); - glEnable(GL_DEPTH_TEST); - - makeCheckImage(); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - -#ifdef GL_VERSION_1_1 - glGenTextures(1, &texName); - glBindTexture(GL_TEXTURE_2D, texName); -#endif - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - 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); -#ifdef GL_VERSION_1_1 - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight, - 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); -#else - glTexImage2D(GL_TEXTURE_2D, 0, 4, checkImageWidth, checkImageHeight, - 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); -#endif -} - -static void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glEnable(GL_TEXTURE_2D); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); -#ifdef GL_VERSION_1_1 - glBindTexture(GL_TEXTURE_2D, texName); -#endif - - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); - glTexCoord2f(0.0, 3.0); glVertex3f(-2.0, 1.0, 0.0); - glTexCoord2f(3.0, 3.0); glVertex3f(0.0, 1.0, 0.0); - glTexCoord2f(3.0, 0.0); glVertex3f(0.0, -1.0, 0.0); - - glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); - glTexCoord2f(0.0, 3.0); glVertex3f(1.0, 1.0, 0.0); - glTexCoord2f(3.0, 3.0); glVertex3f(2.41421, 1.0, -1.41421); - glTexCoord2f(3.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); - glEnd(); - glFlush(); - glDisable(GL_TEXTURE_2D); -} - -static void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 30.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -3.6); -} - -/* ARGSUSED1 */ -static void keyboard (unsigned char key, int x, int y) -{ - switch (key) { - case 's': - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glutPostRedisplay(); - break; - case 'S': - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glutPostRedisplay(); - break; - case 't': - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glutPostRedisplay(); - break; - case 'T': - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glutPostRedisplay(); - break; - case 27: - exit(0); - break; - default: - break; - } -} - -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(250, 250); - glutInitWindowPosition(100, 100); - glutCreateWindow(argv[0]); - init(); - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyboard); - glutMainLoop(); - return 0; -} |