This document summarizes the steps I took to compile the code available from the author's website related to the textbook "Interactive Computer Graphics, 6th Edition" by Angel and Shreiner. Specifically, this document summarizes the steps I took to compile the code using Cygwin on my home computer. (The GPU on my computer is an AMD Radeon HD 7570, and according to the OpenGL Extensions Viewer, it supports OpenGL 4.1.) Note that there are two ways that general OpenGL programs can be compiled under cygwin. One makes use of the X Window System and GLX. While I have gotten some OpenGL programs to

tangibleassistantSoftware and s/w Development

Dec 3, 2013 (3 years and 9 months ago)

90 views

Compi
ling Angel's OpenGL

code using C
ygwin

By Carl Sable

This document summarizes the steps I took to compile the code available from the author's
website related to the textbook

"Interactive Computer Graphics, 6th Edition" by Angel and
Shreiner.

Specifically, this document summarizes the steps I took to compile the code using
Cygwin on my home computer. (The GPU on my computer is an AMD Radeon HD 7570, and
according to the OpenGL Extensions Viewer, it supports OpenGL 4.1.)


Note that there are tw
o ways that general OpenGL programs can be compiled under cygwin. One
makes use of the X Window System and GLX.
While I have gotten some OpenGL programs to
compile this way, this is NOT how I compiled code from the textbook. However, since I used
this meth
od to compile other programs first, it is possible that some of the Cygwin packages I
installed might be necessary. I believe, however, that the only necessary package that
may

not be
installed by default is the Devel "gcc
-
g++" package

(i.e., you need the
proper compiler).
It might
be
easiest

to setup Cygwin with the entire Devel category of packages installed
.


The other way

to compile OpenGL programs with Cygwin

involves linking to Native Windows
libraries. It appears from the Makefiles provided with the
textbook's code that this is what they
have done.


Code from

textbook can be obtained here:
http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_ED
ITION/CODE/


I created a folder for all code from the textbook. Within that folder, I placed

the "include",
"include/GL", "lib/windows", and "Common" directories with all the files available from the
website. (Note that some of the header files in the
"include/
GL
"

subdirectory
were

identical to
include files
that had already been

installed
for my

Cygwin installation, perhaps because I had
previously installed packages to compile other OpenGL code a different way. In any case, I don't
think you need any
non
-
standard
header files other than those provided by the book's website.)


I created a separat
e subfolder for each chapter of the book (since it seems that there are separate
Makefiles provided for each chapter). I did not make separate Mac and Windows subdirectories
within the chapter directories (I am not testing on a Mac).
The i
nstructions

in th
is document

are
related to the Ch
apter
2
code

(although the same approach worked for the code
from Chapter 3
)
.
I started
by placing

the Makefile from within the Chapter 2 directory of the website (I removed
the .txt extension), example1.cpp, fshader21.glsl
, and vshader21.glsl

in my Chapter 2 directory
.


In the Makefile, I edited the CXXINCS and LDDIRS paths to mo
ve back just one directory
instead of
two

(because I had removed the extra

levels

due to the separation of Windows and
Mac code)
. Also, this took s
ome time to figure out,
but
I had to add the following line to the
Makefile (I put it above the CXXOPTS line):


CXX = g++
-
3


The reason for this addition is that the
-
mno
-
cygwin flag does not work with g++
-
4, and the
provided pre
-
compi
led libraries from th
e website
in the
"
lib/windows
"

directory

do not work the
the up
-
to
-
date cygwin cross compilers. (After I figured this out, I had to remove a previously
Compi
ling Angel's OpenGL

code using C
ygwin

By Carl Sable

compiled version of InitShader.o in the Common subdirectory that I had compiled
before making
this chang
e
. The mak
e utility did not realize

to recompile it after changing the compiler.)


After this, running
"
make
"

worked for example1. I was able run example1.exe either by typing
"
./example1
" from the C
ygwin window or double clicking the executable from a fol
der. I then
copied over the rest of the Chapter 2 examples, and "make" correctly compiled all of the
examp
les at once. They all ran fine. Later, the same process worked for the Chapter 3 examples.


One further note is that when I compiled the code using Cy
gwin on the computer in the
classroom, I had to make a change to the actual code in each example before it would compile.
Above the call to glewInit, I had to add the line:


glewExperimental=GL_TRUE;


I found one explanation of what this does here:
http://
www.opengl.org/wiki/OpenGL_Loading_Library


However, this page makes it seem like this should always be necessary, but

this was n
ot
necessary on my home machine!