Programming and Graphics

(Kiana) #1

8.1 Glut 253


LIB = -I/usr/include/GL -I/usr/include/GL/freeglut -lX11 -lglut
phoebe: phoebe.cc
c++ -o phoebe phoebe.cc $(LIB)

The empty spaces in the third line must be generated by pressing theTabkey.


The first line defines the variableLIBas the union of the header files of
(a) the OpenGL and freeglut libraries located in the systemincludedirectories,
and (b)theX11andfreeglutlibraries. The compiler option-Isomethingadds
the directorysomethingto the top of the list of search directories.


To compile the program in Unix, we navigate to the working directory
and issue the command:


make phoebe

To run the executable, we type:


./phoebe

Color and transparency


Color is defined as a mixture of fundamental components that can be
separated by a prism. Color inGlutis determined by the quadruplet of para-
meters:


Red Blue Green Alpha

(RBGA), where “Alpha” determines the opacity. Each parameter varies be-
tween 0 and 1; Alpha=0 corresponds to transparent, and Alpha=1 corresponds
to opaque.


A blank window


The following C++ code contained in the filewindow.ccconsists of the
main program and the user-defined functionblank. The modest purpose of this
code is to generate the empty graphics window shown in Figure 8.1.1(a):


#include <freeglut.h>
using namespace std;

void blank();

int main(int argc, char **argv)
{
glutInit(&argc, argv);
Free download pdf