On Ubuntu 12.04 (precise) :
sudo apt-get install libgl1-mesa-dev libglu-dev libxt-dev libfreetype6-dev fontconfig mesa-utils
To install in Ubuntu karmic the R package "rgl", one needs to install the X11 header files :
sudo apt-get install xorg-dev
and the OpenGL libraries :
sudo apt-get install freeglut3 freeglut3-dev libgl1-mesa-dev libglu1-mesa-dev libice-dev libsm-dev libx11-dev libxau-dev libxdmcp-dev libxext-dev libxt-dev mesa-common-dev x11proto-core-dev x11proto-input-dev x11proto-kb-dev x11proto-xext-dev xlibmesa-gl-dev xtrans-dev
The installation of "rgl" then should work in R :
install.packages("rgl", dep=T)