Prerequisites: 1. The c ++ environment under Ubuntu is configured, and gcc and g ++ are available. 2. use eclipseforc + for OpenGL development step 1: run the following command on the ubuntu terminal to install the library file required by opengl $ sudoapt-getinstallbuild-essential $ sudoapt-getinstallfreeglut3-dev Step 2: run the opengl instance, test Configuration
Prerequisites:
1. The c ++ environment under Ubuntu has been configured, and gcc and g ++ are available.
2. Use eclipse for c + for OpenGL Development
Step 1:
Run the following command on the ubuntu terminal to install the library files required by opengl.
$ Sudo apt-get install build-essential
$ Sudo apt-get install freeglut3-dev
Step 2:
Run the opengl instance to test whether the configured environment is successfully installed.
Create a new project file under eclipse. Suppose we name it Test and create a new C ++ source code file in the project Test. Here we name it main. cpp, in main. enter the code in the cpp file.
# Include
Void init ();
Void display ();
Int main (int argc, char * argv [])
{
Gluinit (& argc, argv );
Fig );
Gluinitwindowposition (0, 0 );
Gluinitwindowsize (300,300 );
Valley createwindow ("OpenGL 3D View ");
Init ();
Gludisplayfunc (display );
Glumainloop ();
Return 0;
}
Void init ()
{
GlClearColor (0.0, 0.0, 0.0, 0.0 );
GlMatrixMode (GL_PROJECTION );
GlOrtho (-5, 5,-5, 5, 5, 15 );
GlMatrixMode (GL_MODELVIEW );
GluLookAt (0, 0, 10, 0, 0, 0, 0, 1, 0 );
}
Void display ()
{
GlClear (GL_COLOR_BUFFER_BIT );
GlColor3f (1.0, 0, 0 );
Gluwireteapot (3 );
GlFlush ();
}
Right-click the project file name
Test-> click Properties-> C/C ++ Bulid-> Settings-> gcc c ++ Linker-> Libraries,
Add several databases in this window,
These are respectively GLU, glut, GL,
Click OK.
If you want to use opencv,
Add the cv, cxcore, highgui, and other library files here,
Set as needed
Add the path/usr/include/GL to the incudepath under gcc c ++ Compiler-> nodes
If you want to use libraries in opencv, add the opencv path, which is usually/usr/include/opencv.
Running the above program will display the opengl running result in the shape of a teapot