Use OpenGL/GLUT in Ubuntu
The Ubuntu version is 12.04 LTS.
Article 1 Basic compilation environment Configuration
1. Create a basic compilation environment
Sudo apt-getinstall build-essential
2. Install OpenGL Library
Sudo apt-getinstall libgl1-mesa-dev
3. Install OpenGL Utilities
Sudo apt-getinstall libglu1-mesa-dev
4. Install OpenGL Utility ToolKit
Sudo apt-get install libglut-dev
Problem 1:
! An error occurred while running this command. The system prompts that the software package cannot be found!
To install the libglut3-dev, the error is the same.
Solution:
Install the freeglut3-dev instead of libglut-dev
Sudo apt-get installfreeglut3-dev
5. Compile the source code example. c.
6. Compile and run
Gcc example. c-oexample. out-lGL-lGLU-lglut
./Example. out
You can see the teapot here.
Article 2 Use glut in Codeblocks
1. Install codeblocks and create a new GLUT Project
Problem 2:
! When selecting the GLUT location, errors are always prompted. In fact, lib and. H files are already in/usr!
Solution:
Do not use the GLUT Project that comes with Codeblocks
Create a project manually, including the Linked Library file. The procedure is as follows:
2. Create a Console Application project
3. Contains link libraries related to OpenGL/Glut
Project à Build Options à Linkersettings
Add file: libGL. so libglut. so libGLU. sO
For example
4. Compile, compile, and run the source code.
The running effect is as follows,
References:
Http://blog.csdn.net/qqbaby2005/article/details/7798061
Http://hi.baidu.com/yanqiuge/item/aedd36189bc8e217e3f9861d
Http://blog.csdn.net/xiayang05/article/details/7647632
Http://blog.csdn.net/wangchenggggdn/article/details/7865973
Www.google.com.hk/url? Sa = t & IDC = j & q = & esrc = s & source = web & cd = 1 & ved = 0 cdemo-jaa & url = http://wiki.ubuntu-tw.org/index.php? Title = Howto_Install_OpenGL_Development_Environment & ei = 2syyUOm_K4PkiALdmoEw & usg = AFQjCNGo5zsj_X9pqZCL_JSQmldwLcrWkQ