Error: couldn't find RGB GLX visual or fbconfig ubuntu 12.04

I'm using Intel HD Graphics as graphics card and I'm trying to open an OpenGL program, but, when I try to run it, I have the following error: OpenGL GLX extension not supported by display ':0.0'

Then, I tried to run glxinfo, then I had the:

Error: couldn't find RGB GLX visual or fbconfig ubuntu 12.04 error.

How can I fix this error from not happening again?


To solve my problem I had to enter the following commands:

sudo apt-get remove --purge xserver-xorg

sudo apt-get install xserver-xorg

sudo dpkg-reconfigure xserver-xorg

And then: sudo reboot

But I think that if you on pure text mode, you don't need to reboot your computer, but you would have to do sudo /etc/init.d/gdm stop before you type the commands I mentioned above and, after typing then, you will have to use sudo /etc/init.d/gdm start to start the graphic interface again.