1. Install the C + + compilation package.
2. Install OpenGL and Freeglut Library
sudo apt-get install Mesa-common-dev
sudo apt-get install Freeglut3-dev
3. Testing:run This code, comes from OpenGL Red Book, by Save it as a CPP file. Then open the terminal and navigate to the directory containing this CPP file.
g++ TEXT.CPP-LGLUT-LGL
Then you'll get an a.out. Run it by
./a.out4. Done
1#include"gl/freeglut.h"2#include"gl/gl.h"3 4 /*display Function-code from:5 http://fly.cc.fer.hr/~unreal/theredbook/chapter01.html6 This is the actual usage of the OpenGL library.7 The following code is the same for any platform*/8 voidrenderfunction ()9 {TenGlclearcolor (0.0,0.0,0.0,0.0); One glclear (gl_color_buffer_bit); AGLCOLOR3F (1.0,1.0,1.0); -Glortho (-1.0,1.0, -1.0,1.0, -1.0,1.0); - Glbegin (Gl_polygon); theGLVERTEX2F (-0.5, -0.5); -GLVERTEX2F (-0.5,0.5); -GLVERTEX2F (0.5,0.5); -GLVERTEX2F (0.5, -0.5); + glend (); - Glflush (); + } A at /*Main Method-main Entry point of application - The Freeglut Library does the window creation work for us, - regardless of the platform.*/ - intMainintargcChar**argv) - { -Glutinit (&argc, argv); in Glutinitdisplaymode (glut_single); -Glutinitwindowsize ( -, -); toGlutinitwindowposition ( -, -); +Glutcreatewindow ("Opengl-first Window Demo"); - Glutdisplayfunc (renderfunction); the Glutmainloop (); * return 0; $}
Note:fell free to context me.
Linux (Ubuntu 14.04) setting up OpenGL