How to install OpenGL C++?


#1

The title says it all.


#2

Copied from a forum. I haven’t tried but here are the commands to install:

  1. sudo apt-get update

-This will update your apt database to the most recent available packages.

  1. sudo apt-get install build-essential
  • This installs the necessary development tools for building source code.
  1. sudo apt-get install freeglut3-dev
  • This installs the development libraries and headers for freeglut.

Your done! Extremely simple! However you must remember that when compiling you must add a ‘-lglut’ as a comand line argument to gcc. If you don’t it cannot find the library’s and you will get undefined reference errors.

example command line: gcc simple.c -lglut

At this point if your program compiles and runs then you are finished. However the first time I tried to run mine I received a ‘libGL warning: 3D driver claims to not support visual 0x42’. This error means I cannot display the required colors to run the program. In my case I had the most recent drivers for my video card. So I did some research on my monitor and found out it can display a color depth of 24 instead of the 16 it was set at. To fix this problem you must edit the /etc/X11/xorg.conf file as root and set the ‘DefaultDepth 24’. Reboot and the problem is solved.

This is my first post (and tutorial) on the ubuntuforums. If people feel that this tutorial is not needed they can feel free to remove it. If anyone wants to add anything related to freeglut or OpenGl please feel free.

Edit: added relevant forum https://ubuntuforums.org/showthread.php?t=345177


#3

How do I get GLFW and GLEW