Main reference: http://blog.csdn.net/sdlgxxy/article/details/6225267
One, download the relevant OpenGL file for http://download.csdn.net/source/3063599
The files used in OpenGL library configuration are divided into the following three categories:
Dynamic link library file (. dll)
Glaux.dll, Glu32.dll, Glut32.dll, Opengl32.
Header file (. h)
Gl. H, Glaux. H, GLU. H, Glut.h.
Library file (. lib)
GLAux.Lib, Glu32.lib, Glut32.lib, OpenGL32.Lib.
3. Configure the above file
1) Copy the DLL file to C:/windows/system32 "If your machine is a 64-bit system, you need to put the. dl file under C:?windows/syswow64"
2) H file is placed in the ${MINGW}/INCLUDE/GL file Plus, if there is no GL folder, create a new one. [MinGW here is the compiler directory used by Eclipse]
3) library files are placed in the MinGW Lib
4. Open Eclipse, create a new C or C + + project, select the compiler option should be mingw instead of Goorss, as follows:
, you can first write a HelloWorld to verify that the eclipse environment is healthy.
5) If you can, you can create a new C + + project to perform OpenGL testing with the following code:
#include <windows.h>#include<GL/gl.h>#include<GL/glut.h>#defineWindow_width 640#defineWindow_height 480//Main Loopvoidmain_loop_function () {//Z Angle Static floatangle; //Clear Color (screen)//and depth (used internally to block obstructed objects)Glclear (Gl_color_buffer_bit |gl_depth_buffer_bit); //Load identity Matrixglloadidentity (); //Multiply in Translation matrixGltranslatef (0,0, -Ten); //Multiply in rotation matrixGlrotatef (Angle,0,0,1); //Render Colored QuadGlbegin (gl_quads); Glcolor3ub (255, the, the); GLVERTEX2F (-1,1); Glcolor3ub ( the,255, the); GLVERTEX2F (1,1); Glcolor3ub ( the, the,255); GLVERTEX2F (1, -1); Glcolor3ub (255,255, the); GLVERTEX2F (-1, -1); Glend (); //Swap buffers (color buffers, makes previous render visible)glutswapbuffers (); //increase angle to rotateAngle + =0.25;}//Initialze OpenGL Perspective MatrixvoidGl_setup (intWidthintheight) {Glviewport (0,0, width, height); Glmatrixmode (gl_projection); Glenable (gl_depth_test); Gluperspective ( $, (float) Width/height,.1, -); Glmatrixmode (Gl_modelview);}//Initialize GLUT and start main loopintMainintargcChar**argv) {Glutinit (&argc, argv); Glutinitwindowsize (Window_width, window_height); Glutinitdisplaymode (Glut_rgb|glut_double); Glutcreatewindow ("GLUT Example!!!"); Glutdisplayfunc (main_loop_function); Gl_setup (Window_width, window_height); Glutmainloop ();}
It is not possible to run directly at this time because the libraries we added cannot be found at compile time and need to be added statically
On the project, right click on select Properties, into the configuration page, as shown below configuration, note do not change,
After configuring this step, recompile the project and if you follow the steps above, you should be able to compile successfully.
Eclipse uses OpenGL