Skip to content

Instantly share code, notes, and snippets.

@cellularmitosis
Last active July 27, 2020 08:06
Show Gist options
  • Save cellularmitosis/ac6c4cfae2bc513277e5df3dec27e04e to your computer and use it in GitHub Desktop.
Save cellularmitosis/ac6c4cfae2bc513277e5df3dec27e04e to your computer and use it in GitHub Desktop.
Building the Redbook OpenGL 1.1 sample code on Linux and OS X Tiger

Blog 2020/7/10

<- previous | index | next ->

Building the Redbook OpenGL 1.1 sample code on Linux and OS X Tiger

The second edition of the "redbook" was a guide to OpenGL 1.1, and is now available for free online: https://www.glprogramming.com/red/

This book included sample code, which is still available as a zip file here: https://www.opengl.org/archives/resources/code/samples/redbook/

However, the samples don't build out-of-the-box on Mac, due to Apple's non-standard header file paths. Additionally, the Makefile needs a bit of massaging.

I tweaked the include statements and Makefiles and have all of these demos building on Mac OS X Tiger (10.4, PowerPC) as well as Debian Buster. See the patch file below.

To use this patch, download the zip file and the patch, then:

unzip redbook.zip
cd redbook
patch -p1 ../redbook.patch

To build on Linux, make -f Makefile.linux. For OS X, make -f Makefile.mac.

Screenshot_2020-07-11_11-18-10

Happy hacking!

p.s. see also this free textbook which covers OpenGL 1.1!

diff -urN redbook/aaindex.c redbook.patched/aaindex.c
--- redbook/aaindex.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/aaindex.c 2020-07-11 09:57:23.037115194 -0500
@@ -42,7 +42,13 @@
* is typed in the window, the lines are rotated in opposite
* directions.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include "stdlib.h"
#define RAMPSIZE 16
diff -urN redbook/aapoly.c redbook.patched/aapoly.c
--- redbook/aapoly.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/aapoly.c 2020-07-11 09:57:23.037115194 -0500
@@ -42,7 +42,13 @@
* function is used.
* Pressing the 't' key turns the antialiasing on and off.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff -urN redbook/aargb.c redbook.patched/aargb.c
--- redbook/aargb.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/aargb.c 2020-07-11 09:57:23.041115256 -0500
@@ -41,7 +41,13 @@
* two diagonal lines to form an X; when 'r' is typed in the window,
* the lines are rotated in opposite directions.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/accanti.c redbook.patched/accanti.c
--- redbook/accanti.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/accanti.c 2020-07-11 09:57:23.041115256 -0500
@@ -39,7 +39,13 @@
* Use the accumulation buffer to do full-scene antialiasing
* on a scene with orthographic parallel projection.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include "jitter.h"
diff -urN redbook/accpersp.c redbook.patched/accpersp.c
--- redbook/accpersp.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/accpersp.c 2020-07-11 09:57:23.041115256 -0500
@@ -40,7 +40,13 @@
* on a scene with perspective projection, using the special
* routines accFrustum() and accPerspective().
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <math.h>
#include "jitter.h"
diff -urN redbook/alpha3D.c redbook.patched/alpha3D.c
--- redbook/alpha3D.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/alpha3D.c 2020-07-11 09:57:23.041115256 -0500
@@ -43,7 +43,13 @@
* transparent object through the opaque object. Press
* the 'r' key to reset the scene.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/alpha.c redbook.patched/alpha.c
--- redbook/alpha.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/alpha.c 2020-07-11 09:57:23.041115256 -0500
@@ -41,7 +41,13 @@
* to demonstrate the effect order has on alpha blending results.
* Use the 't' key to toggle the order of drawing polygons.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
static int leftFirst = GL_TRUE;
diff -urN redbook/bezcurve.c redbook.patched/bezcurve.c
--- redbook/bezcurve.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/bezcurve.c 2020-07-11 09:57:23.041115256 -0500
@@ -38,7 +38,13 @@
/* bezcurve.c
* This program uses evaluators to draw a Bezier curve.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
GLfloat ctrlpoints[4][3] = {
diff -urN redbook/bezmesh.c redbook.patched/bezmesh.c
--- redbook/bezmesh.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/bezmesh.c 2020-07-11 09:57:23.041115256 -0500
@@ -40,7 +40,12 @@
* using two-dimensional evaluators.
*/
#include <stdlib.h>
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
GLfloat ctrlpoints[4][4][3] = {
{ {-1.5, -1.5, 4.0},
diff -urN redbook/bezsurf.c redbook.patched/bezsurf.c
--- redbook/bezsurf.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/bezsurf.c 2020-07-11 09:57:23.041115256 -0500
@@ -40,7 +40,12 @@
* using two-dimensional evaluators.
*/
#include <stdlib.h>
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
GLfloat ctrlpoints[4][4][3] = {
{{-1.5, -1.5, 4.0}, {-0.5, -1.5, 2.0},
diff -urN redbook/checker.c redbook.patched/checker.c
--- redbook/checker.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/checker.c 2020-07-11 09:57:23.041115256 -0500
@@ -42,7 +42,13 @@
* If running this program on OpenGL 1.0, texture objects are
* not used.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/clip.c redbook.patched/clip.c
--- redbook/clip.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/clip.c 2020-07-11 09:57:23.041115256 -0500
@@ -39,7 +39,13 @@
* clip.c
* This program demonstrates arbitrary clipping planes.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
void init(void)
diff -urN redbook/colormat.c redbook.patched/colormat.c
--- redbook/colormat.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/colormat.c 2020-07-11 09:57:23.041115256 -0500
@@ -41,7 +41,13 @@
* ColorMaterial mode. Interaction: pressing the
* mouse buttons will change the diffuse reflection values.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
GLfloat diffuseMaterial[4] = { 0.5, 0.5, 0.5, 1.0 };
diff -urN redbook/cube.c redbook.patched/cube.c
--- redbook/cube.c 1997-07-23 03:17:32.000000000 -0500
+++ redbook.patched/cube.c 2020-07-11 09:57:23.041115256 -0500
@@ -41,7 +41,13 @@
* glScalef() and a single viewing transformation, gluLookAt().
* A wireframe cube is rendered.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
void init(void)
diff -urN redbook/dof.c redbook.patched/dof.c
--- redbook/dof.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/dof.c 2020-07-11 09:57:23.045115319 -0500
@@ -44,7 +44,13 @@
* the viewing volume is at the same position, each time. In
* this case, the gold teapot remains in focus.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <math.h>
#include "jitter.h"
diff -urN redbook/double.c redbook.patched/double.c
--- redbook/double.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/double.c 2020-07-11 09:57:23.045115319 -0500
@@ -41,7 +41,13 @@
* Pressing the left mouse button rotates the rectangle.
* Pressing the middle mouse button stops the rotation.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
static GLfloat spin = 0.0;
diff -urN redbook/drawf.c redbook.patched/drawf.c
--- redbook/drawf.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/drawf.c 2020-07-11 09:57:23.045115319 -0500
@@ -40,7 +40,13 @@
* Draws the bitmapped letter F on the screen (several times).
* This demonstrates use of the glBitmap() call.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
GLubyte rasters[24] = {
diff -urN redbook/feedback.c redbook.patched/feedback.c
--- redbook/feedback.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/feedback.c 2020-07-11 09:57:23.177117395 -0500
@@ -42,7 +42,13 @@
* Then feedback mode is entered, and the same lines are
* drawn. The results in the feedback buffer are printed.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/fog.c redbook.patched/fog.c
--- redbook/fog.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/fog.c 2020-07-11 09:57:23.177117395 -0500
@@ -44,7 +44,13 @@
* In this program, there is a fixed density value, as well
* as fixed start and end values for the linear fog.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/fogindex.c redbook.patched/fogindex.c
--- redbook/fogindex.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/fogindex.c 2020-07-11 09:57:23.177117395 -0500
@@ -40,7 +40,13 @@
* This program draws 5 wireframe spheres, each at
* a different z distance from the eye, in linear fog.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/font.c redbook.patched/font.c
--- redbook/font.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/font.c 2020-07-11 09:57:23.177117395 -0500
@@ -42,7 +42,13 @@
* and other pixel routines. Also demonstrates use of
* display lists.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <string.h>
diff -urN redbook/hello.c redbook.patched/hello.c
--- redbook/hello.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/hello.c 2020-07-11 09:57:23.177117395 -0500
@@ -39,7 +39,12 @@
* hello.c
* This is a simple, introductory OpenGL program.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
void display(void)
{
diff -urN redbook/image.c redbook.patched/image.c
--- redbook/image.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/image.c 2020-07-11 09:57:23.181117457 -0500
@@ -46,7 +46,13 @@
* factors are reset. If you press the 'z' or 'Z' keys, you change
* the zoom factors.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/light.c redbook.patched/light.c
--- redbook/light.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/light.c 2020-07-11 09:57:23.181117457 -0500
@@ -41,7 +41,13 @@
* model. A sphere is drawn using a grey material characteristic.
* A single light source illuminates the object.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
/* Initialize material property, light source, lighting model,
diff -urN redbook/lines.c redbook.patched/lines.c
--- redbook/lines.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/lines.c 2020-07-11 09:57:23.181117457 -0500
@@ -40,7 +40,13 @@
* This program demonstrates geometric primitives and
* their attributes.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#define drawOneLine(x1,y1,x2,y2) glBegin(GL_LINES); \
diff -urN redbook/list.c redbook.patched/list.c
--- redbook/list.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/list.c 2020-07-11 09:57:23.181117457 -0500
@@ -41,7 +41,13 @@
* display list. Note that attributes, such as current
* color and matrix, are changed.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
GLuint listName;
diff -urN redbook/Makefile.linux redbook.patched/Makefile.linux
--- redbook/Makefile.linux 1969-12-31 18:00:00.000000000 -0600
+++ redbook.patched/Makefile.linux 2020-07-11 09:59:25.899046944 -0500
@@ -0,0 +1,25 @@
+# debian buster: apt-get install freeglut3-dev
+
+TARGETS = aaindex aapoly aargb accanti accpersp \
+ alpha alpha3D bezcurve bezmesh bezsurf \
+ clip colormat cube dof double \
+ drawf feedback fog fogindex font hello \
+ image light lines list material \
+ model movelight pickdepth picksquare planet \
+ polys quadric robot scene select \
+ smooth stencil stroke surface teapots tess \
+ tesswind checker mipmap \
+ polyoff texbind texgen texprox texsub varray wrap \
+ texturesurf torus trim unproject
+
+LIBS = -lGL -lGLU -lglut -lXext -lX11 -lm
+
+all: $(TARGETS)
+
+$(TARGETS):
+ cc $(LIBS) -o $@ [email protected]
+
+clean:
+ -rm -f *.o $(TARGETS)
+
+.PHONY: clean all
diff -urN redbook/Makefile.mac redbook.patched/Makefile.mac
--- redbook/Makefile.mac 1969-12-31 18:00:00.000000000 -0600
+++ redbook.patched/Makefile.mac 2020-07-11 09:57:23.037115194 -0500
@@ -0,0 +1,23 @@
+TARGETS = aaindex aapoly aargb accanti accpersp \
+ alpha alpha3D bezcurve bezmesh bezsurf \
+ clip colormat cube dof double \
+ drawf feedback fog fogindex font hello \
+ image light lines list material \
+ model movelight pickdepth picksquare planet \
+ polys quadric robot scene select \
+ smooth stencil stroke surface teapots tess \
+ tesswind checker mipmap \
+ polyoff texbind texgen texprox texsub varray wrap \
+ texturesurf torus trim unproject
+
+LIBS = -framework GLUT -framework OpenGL -framework Cocoa
+
+all: $(TARGETS)
+
+$(TARGETS):
+ cc $(LIBS) -o $@ [email protected]
+
+clean:
+ -rm -f *.o $(TARGETS)
+
+.PHONY: clean all
diff -urN redbook/material.c redbook.patched/material.c
--- redbook/material.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/material.c 2020-07-11 09:57:23.181117457 -0500
@@ -42,7 +42,12 @@
* A single light source illuminates the objects.
*/
#include <stdlib.h>
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
/* Initialize z-buffer, projection matrix, light source,
* and lighting model. Do not specify a material property here.
diff -urN redbook/mipmap.c redbook.patched/mipmap.c
--- redbook/mipmap.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/mipmap.c 2020-07-11 09:57:23.181117457 -0500
@@ -42,7 +42,13 @@
* Thus, the quadrilateral which is drawn is drawn with several
* different colors.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
GLubyte mipmapImage32[32][32][4];
diff -urN redbook/model.c redbook.patched/model.c
--- redbook/model.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/model.c 2020-07-11 09:57:23.181117457 -0500
@@ -39,7 +39,13 @@
* model.c
* This program demonstrates modeling transformations
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
void init(void)
diff -urN redbook/movelight.c redbook.patched/movelight.c
--- redbook/movelight.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/movelight.c 2020-07-11 09:57:23.181117457 -0500
@@ -50,7 +50,13 @@
* the modeling transformation (x rotation) by 30 degrees.
* The scene is then redrawn with the light in a new position.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
static int spin = 0;
diff -urN redbook/pickdepth.c redbook.patched/pickdepth.c
--- redbook/pickdepth.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/pickdepth.c 2020-07-11 09:57:23.181117457 -0500
@@ -45,7 +45,13 @@
* are "picked." Pay special attention to the depth
* value range, which is returned.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/picksquare.c redbook.patched/picksquare.c
--- redbook/picksquare.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/picksquare.c 2020-07-11 09:57:23.181117457 -0500
@@ -44,7 +44,12 @@
*/
#include <stdlib.h>
#include <stdio.h>
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
int board[3][3]; /* amount of color for each square */
diff -urN redbook/planet.c redbook.patched/planet.c
--- redbook/planet.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/planet.c 2020-07-11 09:57:23.181117457 -0500
@@ -42,7 +42,13 @@
* Interaction: pressing the d and y keys (day and year)
* alters the rotation of the planet around the sun.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
static int year = 0, day = 0;
diff -urN redbook/polyoff.c redbook.patched/polyoff.c
--- redbook/polyoff.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/polyoff.c 2020-07-11 09:57:23.185117520 -0500
@@ -41,7 +41,13 @@
* polygon and its wireframe counterpart without ugly visual
* artifacts ("stitching").
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
diff -urN redbook/polys.c redbook.patched/polys.c
--- redbook/polys.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/polys.c 2020-07-11 09:57:23.185117520 -0500
@@ -39,7 +39,13 @@
* polys.c
* This program demonstrates polygon stippling.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
void display(void)
diff -urN redbook/quadric.c redbook.patched/quadric.c
--- redbook/quadric.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/quadric.c 2020-07-11 09:57:23.185117520 -0500
@@ -43,7 +43,13 @@
* Note that the cylinder has no top or bottom and the circle
* has a hole in it.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
diff -urN redbook/robot.c redbook.patched/robot.c
--- redbook/robot.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/robot.c 2020-07-11 09:57:23.185117520 -0500
@@ -42,7 +42,13 @@
* Interaction: pressing the s and e keys (shoulder and elbow)
* alters the rotation of the robot arm.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
static int shoulder = 0, elbow = 0;
diff -urN redbook/scene.c redbook.patched/scene.c
--- redbook/scene.c 1997-07-23 03:17:34.000000000 -0500
+++ redbook.patched/scene.c 2020-07-11 09:57:23.185117520 -0500
@@ -41,7 +41,13 @@
* Objects are drawn using a grey material characteristic.
* A single light source illuminates the objects.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
/* Initialize material property and light source.
diff -urN redbook/select.c redbook.patched/select.c
--- redbook/select.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/select.c 2020-07-11 09:57:23.185117520 -0500
@@ -50,7 +50,13 @@
* the green triangle causes one hit with the name 1, and
* the yellow triangles cause one hit with the name 3.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/smooth.c redbook.patched/smooth.c
--- redbook/smooth.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/smooth.c 2020-07-11 09:57:23.185117520 -0500
@@ -40,7 +40,13 @@
* This program demonstrates smooth shading.
* A smooth shaded polygon is drawn in a 2-D projection.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
void init(void)
diff -urN redbook/stencil.c redbook.patched/stencil.c
--- redbook/stencil.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/stencil.c 2020-07-11 09:57:23.185117520 -0500
@@ -45,7 +45,13 @@
* Then a blue sphere is drawn where the stencil value is 1,
* and yellow torii are drawn where the stencil value is not 1.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#define YELLOWMAT 1
diff -urN redbook/stroke.c redbook.patched/stroke.c
--- redbook/stroke.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/stroke.c 2020-07-11 09:57:23.185117520 -0500
@@ -43,7 +43,13 @@
* correspond to the ASCII values of the characters.
* Use of glCallLists() is demonstrated.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <string.h>
diff -urN redbook/surface.c redbook.patched/surface.c
--- redbook/surface.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/surface.c 2020-07-11 09:57:23.185117520 -0500
@@ -43,7 +43,13 @@
* Note that some of the control points are hidden by the
* surface itself.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/teapots.c redbook.patched/teapots.c
--- redbook/teapots.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/teapots.c 2020-07-11 09:57:23.185117520 -0500
@@ -41,7 +41,12 @@
* A single light source illuminates the objects.
*/
#include <stdlib.h>
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
GLuint teapotList;
diff -urN redbook/tess.c redbook.patched/tess.c
--- redbook/tess.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/tess.c 2020-07-11 09:57:23.185117520 -0500
@@ -48,7 +48,13 @@
* star. Also note that removing the TessProperty for the
* star will make the interior unshaded (WINDING_ODD).
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/tesswind.c redbook.patched/tesswind.c
--- redbook/tesswind.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/tesswind.c 2020-07-11 09:57:23.189117583 -0500
@@ -42,7 +42,13 @@
* each with very different contours. When the w key is pressed,
* the objects are drawn with a different winding rule.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/texbind.c redbook.patched/texbind.c
--- redbook/texbind.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/texbind.c 2020-07-11 09:57:23.189117583 -0500
@@ -39,7 +39,13 @@
* This program demonstrates using glBindTexture() by
* creating and managing two textures.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/texgen.c redbook.patched/texgen.c
--- redbook/texgen.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/texgen.c 2020-07-11 09:57:23.189117583 -0500
@@ -49,7 +49,12 @@
* Pressing the 'x' key switches it back to x = 0.
*/
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/texprox.c redbook.patched/texprox.c
--- redbook/texprox.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/texprox.c 2020-07-11 09:57:23.189117583 -0500
@@ -41,7 +41,13 @@
* This program only prints out some messages about whether
* certain size textures are supported and then exits.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/texsub.c redbook.patched/texsub.c
--- redbook/texsub.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/texsub.c 2020-07-11 09:57:23.189117583 -0500
@@ -43,7 +43,13 @@
* alter the original texture. If the r key is pressed,
* the original texture is restored.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/texturesurf.c redbook.patched/texturesurf.c
--- redbook/texturesurf.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/texturesurf.c 2020-07-11 09:57:23.189117583 -0500
@@ -41,7 +41,13 @@
*/
#include <stdlib.h>
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <math.h>
GLfloat ctrlpoints[4][4][3] = {
diff -urN redbook/torus.c redbook.patched/torus.c
--- redbook/torus.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/torus.c 2020-07-11 09:57:23.189117583 -0500
@@ -40,7 +40,12 @@
* This program demonstrates the creation of a display list.
*/
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
diff -urN redbook/trim.c redbook.patched/trim.c
--- redbook/trim.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/trim.c 2020-07-11 09:57:23.189117583 -0500
@@ -42,7 +42,13 @@
* (piecewise linear) curve to trim part of the surface.
*/
#include <stdlib.h>
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdio.h>
#ifndef CALLBACK
diff -urN redbook/unproject.c redbook.patched/unproject.c
--- redbook/unproject.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/unproject.c 2020-07-11 09:57:23.189117583 -0500
@@ -41,7 +41,13 @@
* reads the mouse position and determines two 3D points
* from which it was transformed. Very little is displayed.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
diff -urN redbook/varray.c redbook.patched/varray.c
--- redbook/varray.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/varray.c 2020-07-11 09:57:23.189117583 -0500
@@ -39,7 +39,13 @@
* varray.c
* This program demonstrates vertex arrays.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdio.h>
#ifdef GL_VERSION_1_1
diff -urN redbook/wrap.c redbook.patched/wrap.c
--- redbook/wrap.c 1997-07-23 03:17:36.000000000 -0500
+++ redbook.patched/wrap.c 2020-07-11 09:57:23.189117583 -0500
@@ -46,7 +46,13 @@
* If running this program on OpenGL 1.0, texture objects are
* not used.
*/
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
#include <GL/glut.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment