Install freeglut or mesa first. Take freeglut as an example. after installation, gluth will appear in usrshortdegl and libgluso will appear in usrlib. if not, copy it yourself.
Install freeglut or mesa first.
Take freeglut as an example. after installation, glut. h will appear in/usr/include/GL and libglut. so will appear in/usr/lib. if not, copy it yourself.
Then write a test program, such as test. c, and compile it with the following command:
Gcc-lglut test. c-o test
Generate the executable file test, and then:
./Test
If the box is displayed, the installation is successful :)
If there are no existing test examples in hand, the attachment is the first example of openGL Redbook hello. c
- # Include
- Void display (void)
- {
- /* Clear all pixels */
- GlClear (GL_COLOR_BUFFER_BIT );
- /* Draw white polygon (rectangle) with corners
- * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
- */
- GlColor3f (1.0, 1.0, 1.0 );
- GlBegin (GL_POLYGON );
- GlVertex3f (0.25, 0.25, 0.0 );
- GlVertex3f (0.75, 0.25, 0.0 );
- GlVertex3f (0.75, 0.75, 0.0 );
- GlVertex3f (0.25, 0.75, 0.0 );
- GlEnd ();
- /* Don't wait!
- * Start processing buffered OpenGL routines
- */
- GlFlush ();
- }
- Void init (void)
- {
- /* Select clearing color */
- GlClearColor (0.0, 0.0, 0.0, 0.0 );
- /* Initialize viewing values */
- GlMatrixMode (GL_PROJECTION );
- GlLoadIdentity ();
- GlOrtho (0.0, 1.0, 0.0, 1.0,-1.0, 1.0 );
- }
- /*
- * Declare initial window size, position, and display mode
- * (Single buffer and RGBA). Open window with "hello"
- * In its title bar. Call initialization routines.
- * Register callback function to display graphics.
- * Enter main loop and process events.
- */
- Int main (int argc, char ** argv)
- {
- Gluinit (& argc, argv );
- Fig );
- Gluinitwindowsize (250,250 );
- Gluinitwindowposition (100,100 );
- Fig ("hello ");
- Init ();
- Gludisplayfunc (display );
- Glumainloop ();
- Return 0;/* ansi c requires main to return int .*/
- }