OpenGL development and configuration under Visual Studio [reprint + arrangement]

Source: Internet
Author: User

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:

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.