Saturday, June 27, 2009

eMac,Gcc and Graphics.h

We are back where we began.Nearly a year after we pulled off a coup by installing Ubuntu on the rather dated Apple eMacs of our lab, we were summoned back with the unenviable task of running 2d/3d animation C programs in the boxes.This ,of course, was not possible using the archaic Ubuntu 5.04,so we were off installing 8.04.Doing this was no great deal, once you figure out that you have to use the option 'live video=ofonly' when booting from the CD.

The graphical display does not work once the CD has booted ,so go to the command prompt (Ctrl-Alt-F1).Copy everything from here and save the file as xorg.conf.Now replace the file /etc/X11/xorg.conf with the file you just created and type 'sudo /etc/init.d/gdm restart'.OK,so installing Ubuntu was no big deal.But how do you run graphics programs when you consider that GCC has no graphics.h library?

Google came to my rescue yet again and I landed myself with this invaluable link.The libgraph source given in the link works equally well for Ubuntu's powerpc version and we got 2d programs up and running in record time!For 3d programming ,you need the header GLUT.H.Fortunately you don't need to compile a source file as all you need to do is to install the Ubuntu repository package 'libglut3-dev'.

Was it worth the effort?Yes,when you consider that we can now claim to have setup an entire Lab all by ourselves.But as part of my search,I also learnt that graphics.h is not present by default in gcc's library because it is considered to be outdated and of no practical use today.It's only purpose is to help students learn outdated code and pass a paper called "Computer Graphics"! :(

On the other hand, OpenGL/GLUT is a popular tool for 3D programming,especially games and multimedia.BilliardGL is a particularly popular game created entirely using OpenGL.So I guess it was worth all those bunked hours after all!

No comments: