Configuring mesa3d in Ubuntu is simple and does not have to be as tedious as in windows.
I fully use the new version, which is more in line with my windows usage habits.
In Linux, open-source mesa3d is used to replace OpenGL APIs, while freeglut is used for glut.
Find the mesa3d Dev package in the new, note that it is not the runtime package (this package is installed by default, do not accidentally Uninstall.). Then there is a freeglut3-dev. Installation on it, letProgramThe dependency issue is automatically handled. After both are installed, find a compiler and test it.
// HW. c
# Include <Gl/glut. h> // same as in windows, glut. h itself includes Gl. h and Glu. h.
void display ()
{< br> glclear (gl_color_buffer_bit);
glbegin (gl_polygon);
glvertex2f (-0.5, -0.5);
glvertex2f (0.5,-0.5);
glvertex2f (0.5, 0.5);
glvertex2f (-0.5, 0.5 );
glend ();
glflush ();
}< br> int main (INT argc, char ** argv)
{< br> gluinit (& argc, argv);
glucreatewindow ("SP");
gludisplayfunc (Display);
glumainloop ();
return 0;
}< br>
compile GCC.
gcc hw. c-o HW-lglut
-lglut is the library file of the glut used.
then run the file
. /HW
if you see a white square in a small black window, it means the operation is successful. note that compiz needs to be closed during running; otherwise, the window will flash and disappear.