This article is reproduced from: programming enthusiast ForumMasterpiece of eastcowboy 《OpenGL getting started(If you want to use a computer to draw pictures, click here to visit and learn the series of articles of the eastcowboy hero) to modify and organize the original article. Copyright and ownership belongEastcowboy.
First download the development of essential files: http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
To install glut in Windows:
1. Unpack the downloaded package and obtain 5 files.
Configuration Under Visual Studio 2005:
2. Search for "Gl. h, and find the folder where it is located (if it is visualstudio2005, it should be the "Vc \ platformsdk \ include \ GL folder" under its installation directory "). Put the extracted glut. h in this folder.
3. Put the extracted glut. lib and glu32.lib in the folder where the static library is located (for visualstudio2005, it should be the "Vc \ Lib" folder under its installation directory ).
Configuration Under Visual Studio 2008:
2. Search for "Gl. h, and find the folder where it is located (if it is visualstudio2008, it should be the "Vc \ include \ folder" under its installation directory "). Put the extracted glut. h in this folder.
3. Put the extracted glut. lib and glu32.lib in the folder where the static library is located (for visualstudio2008, it should be the "Vc \ Lib" folder under its installation directory ).
4. Put the extracted glut. dll and glu32.dll In the System32 folder under the operating system directory. (Typical location: c: \ windows \ system32)
Create an OpenGL project:
Taking Visual Studio as an example.
Select File-> New-> Project, select Win32 console application, select a name, and then press OK.
Click application settings on the left of the displayed dialog box, locate the empty project, and click Finish.
Then addCodeFile named "OpenGL. c". Use. C as the end of the file.
It's just like the normal project.
Assign the following code to OpenGL. C and press F5.
Code
// # Include <Gl/glut. h> // In vs2005
# Include < GLUT. h > // In vs2008
Void Mydisplay ( Void )
{
Glclear (gl_color_buffer_bit );
Glrectf ( - 0.5f , - 0.5f , 0.5f , 0.5f );
Glflush ();
}
Int Main ( Int Argc, Char * Argv [])
{
Gluinit ( & Argc, argv );
Gluinitdisplaymode (glu_rgb | Glu_single );
Gluinitwindowposition ( 100 , 100 );
Gluinitwindowsize ( 400 , 400 );
Glucreatewindow ( " First OpenGLProgram " );
Gludisplayfunc ( & Mydisplay );
Glumainloop ();
Return 0 ;
}
The result is as follows: