1. Download the glut Toolkit
Http://www.opengl.org/resources/libraries/glut/
2. Go to the VC installation directory.
Vc \ include \ GL, copy the. h file in the Toolkit.
Copy the. Lib file to\ Vc \ Lib
Copy the. dll file to the System32 folder in the system directory.
3. Create a C ++ project and test the project as follows:CodeThe environment is configured successfully.
# Include
<Gl/glut. h>
# Include <Gl/Gl. h>
# Include <Gl/Glaux. h>
# Pragma comment (Lib, "opengl32.lib ")
# Pragma comment (Lib, "glu32.lib ")
# Pragma comment (Lib, "Glaux. lib ")
# Include <windows. h>
Void myinit (void );
Void callback myreshape (glsizei W, glsizei H );
Void callback display (void );
Void myinit (void)
{
Glclearcolor (0.0, 0.0, 0.0, 0.0 );
Glclear (gl_color_buffer_bit );
}
Void callback myreshape (glsizei W, glsizei H)
{
Glviewport (0, 0, W, 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) h/(glfloat) W,
1.5 * (glfloat) h/(glfloat) W,-1.5, 1.5,-10.0, 10.0 );
Glmatrixmode (gl_modelview );
Glloadidentity ();
}
Void callback display (void)
{
Glcolor3f (1.0, 1.0, 0.0 );
Auxwiresphere (1.0 );
Glflush ();
}
Void main (void)
{
// Set the display mode: single cache | rgba color mode
Auxinitdisplaymode (aux_single | aux_rgba );
// Initialize the window position
Auxinitposition (400,200,500,500 );
// Set the window title
Auxinitwindowa ("OpenGLProgram");
Myinit ();
Auxreshapefunc (myreshape );
Auxmainloop (Display );
}