I used to renew it!
Sudo apt-Get install Mesa-common-dev mesademos libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev
I found and installed them one by one in Suntory, with the same effect, and then
Create a file named sample. CPP/** // * Light. c
This program draws an OpenGL window using GLUT and displays a ball for illumination.
*/
/** // * Because the header file glut. h contains the Gl. h and Glu. H, you only need to include this file */
# Include <Gl/glut. h>
# Include <stdlib. h>
/** // * Initialize the material attributes, light source attributes, and illumination model, and open the depth buffer */
Void Init (void)
...{
Glfloat mat_specular [] =... {1.0, 1.0, 1.0, 1.0 };
Glfloat mat_shininess [] =... {50.0 };
Glfloat light_position [] =... {1.0, 1.0, 1.0, 0.0 };
Glclearcolor (0.0, 0.0, 0.0, 0.0 );
Glshademodel (gl_smooth );
Glmaterialfv (gl_front, gl_specular, mat_specular );
Glmaterialfv (gl_front, gl_shininess, mat_shininess );
Gllightfv (gl_light0, gl_position, light_position );
Glable (gl_lighting );
Glable (gl_light0 );
Glenable (gl_depth_test );
}
/** // * Call the glut function to draw a ball */
Void display (void)
...{
Glclear (gl_color_buffer_bit | gl_depth_buffer_bit );
Glusolidsphere (1.0, 40, 50 );
Glflush ();
}
/** // * Defines the reshape function of GLUT. W and H indicate the width and height of the current window */
Void reshape (int w, int H)
...{
Glviewport (0, 0, (glsizei) W, (glsizei) H );
Glmatrixmode (gl_projection );
Glloadidentity ();
If (W <= H)
Glortho (-1.5, 1.5,-1.5 * (glfloat) h/(glfloat) W, 1.5 * (glfloat) h/(glfloat) W,-10.0, 10.0 );
Else
Glortho (-1.5 * (glfloat) W/(glfloat) h, 1.5 * (glfloat) W/(glfloat) h,-1.5, 1.5,-10.0, 10.0 );
Glmatrixmode (gl_modelview );
Glloadidentity ();
}
/** // * Define the keyboard response function */
Void keyboard (unsigned char key, int X, int y)
...{
/** // * Press ESC to exit */
Switch (key)
...{
Case 27:
Exit (0 );
Break;
}
}
Int main (INT argc, char ** argv)
...{
/** // * Initialize the glut environment */
Gluinit (& argc, argv );
/** // * Display Mode Initialization */
Fig );
/** // * Defines the window size */
Gluinitwindowsize (300,300 );
/** // * Define the window position */
Gluinitwindowposition (100,100 );
/** // * Display window with the title of execution function */
Ngcreatewindow (argv [0]);
/** // * Call the OpenGL initialization function */
Init ();
/** // * Register the OpenGL plotting function */
Gludisplayfunc (Display );
/** // * Response function when the size of the registration window changes */
Glureshapefunc (reshape );
/** // * Register the keyboard response function */
Glukeyboardfunc (keyboard );
/** // * Enter the glut message loop and start executing the Program */
Glumainloop ();
Return 0;
}
Then
G ++ sample. cpp-o Sample-lglut
./Sample
That's right.
This article from: http://blog.csdn.net/nauty_li/article/details/2217625