Install OpenGL glut library in Windows

Source: Internet
Author: User
Glut is not required by OpenGL, but it will bring some convenience to our learning. We recommend that you install it.
Glut in Windows: (the size is about 150 K)
Http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
If you cannot download from the above address, use the following connection:
Http://upload.programfan.com/upfile/200607311626279.zip
To install glut in Windows:
1. Unpack the downloaded package and obtain 5 files.
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 ).
4. Put the extracted glut. dll and glu32.dll In the System32 folder under the operating system directory. (Typical location: C:/Windows/system32)

OpenGL Study

You can download the official tutorials and example programs from http://www.OpenGL.org documentation on OpenGL's official website:
The OpenGL programming guide, which is the famous red book ")

If your English is not good, we recommend that you read:
OpenGL is a very good Chinese tutorial. Can be in http://www.vrforum.cn/forumdisplay.php? FID = 29 find its example code
OpenGL is an authoritative guide to programming. It is a Chinese translation of the Red Book, and its example is the red book.

* The Nate Robin example is very helpful for you to understand OpenGL. Http://www.gamedev.net/reference/articles/article839.asp

* The OpenGL Reference Manual (Blue Book) is not an entry book, but a function reference manual, which can be downloaded from the documentation of the http://www.OpenGL.org and used in actual learning

* The nehe example is also a favorite example for beginners. Http://nehe.gamedev.net, there is a part of Chinese Translation in http://www.chinagamedev.net

* ** Nehe's simple window example (Lesson 2) covers almost all the languages in the world. If you want to use your preferred unique language, refer to http://nehe.gamedev.net/data/lessons/lesson.asp? Lesson = 02 join at the bottom and learn from the C ++ example (most teaching materials are based on C ++, but fortunately we really pay attention to OpenGL itself)

Most examples of OpenGL require the OpenGL application toolkit: glut library. The following describes how to install it.

Visual c ++ 6.0 HOWTO:
1. Download glut Library: http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
2. Place the glut. h In the compressed package in the directory of.../Microsoft Visual Studio/vc98/include/GL.
Put glu32.lib in the directory of.../Microsoft Visual Studio/vc98/lib.
Put glu32.dll in the X:/Windows/systom32 directory (put Win98 users in the X:/Windows/systom directory)
3. Create a console project Win32 console application, add hello. C, and run:
# I nclude <Gl/glut. h>

Void display (void)
{
Glclear (gl_color_buffer_bit);/* clear all pixels */
Glcolor3f (1.0, 1.0, 1.0 );
Glbegin (gl_polygon);/* draw white polygon with corners at (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0 )*/
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 ();
Glflush ();/* Start processing buffered OpenGL routines */
}

Void Init (void)
{
Glclearcolor (0.0, 0.0, 0.0, 0.0);/* select clearing color */
Glmatrixmode (gl_projection );
Glloadidentity ();
Glortho (0.0, 1.0, 0.0, 1.0,-1.0, 1.0);/* initialize viewing values */
}

Int main (INT argc, char ** argv)
{
Gluinit (& argc, argv );
Fig;/* declare initial display mode (single buffer and rgba ).*/
Gluinitwindowsize (250,250);/* declare initial window size .*/
Maid (100,100);/* declare initial window position .*/
Valley createwindow ("hello");/* open window with "hello" in its title bar .*/
Init ();/* Call initialization routines .*/
Gludisplayfunc (Display);/* Register callback function to display graphics .*/
Glumainloop ();/* Enter main loop and process events .*/
Return 0;/* ansi c requires main to return Int .*/
}

OpenGL is the preferred environment for developing portable and interactive 2D and 3D graphics applications. It is also the most widely used computer graphics standard. OpenGL is a computer graphics processing system developed by SGI. It is a software interface of graphics hardware. GL represents the graphics library ). OpenGL is portable. Any OpenGL application does not need to consider the platform and operating system where its runtime environment is located. It will produce the same visual effect in any environment that complies with the OpenGL standard.

OpenGL is not a programming language, but an API (Application Programming Interface ). When we say that a program is based on OpenGL or that it is an OpenGL program, it means that it is written in a programming language such as C or C ++, one or more OpenGL library functions are called. As an API, OpenGL follows the C language call conventions.

OpenGL mainly includes three function libraries: core library, utility function library, and programming auxiliary library. The core library contains the most basic commands and functions of OpenGL. The core library provides more than one hundred functions, all of which are prefixed with "Gl, it is used to create various geometric models, perform coordinate transformations, generate illumination effects, perform texture ing, generate atomization effects, and perform all 2D and 3D graphics operations. The utility function library is a function library that is a higher layer than the core library. It provides more than 40 functions, all of which are prefixed with "Glu. OpenGL is a graphical standard and independent from any window system or operating system. OpenGL does not provide functions for window management and message event response, there is no function to read events with the mouse or keyboard, so some basic window management functions, event processing functions, and simple event functions are provided in the programming auxiliary library. These functions are prefixed with "Aux. It is worth mentioning that the aux programming auxiliary library has been largely replaced by the glut library. The following uses the glut library as an example.

GLUT stands for OpenGL utility toolkit, which is a tool kit unrelated to the window system. As a more powerful alternative to the aux library, it is used to hide the complexity of APIs in different window systems. The prefix of the glut subroutine uses "glut ".

1. The following uses Windows and visualC ++ as an example to describe how to install a pre-compiled library:

(1) Copy gult32.dll to system32 in windows.

(2) Copy gult32.lib to the lib directory of VC.

(3) Copy gult. h to include/GL of VC.

2. A simple OpenGL program

# I nclude <windows. h>

# I nclude <Gl/glut. h>

 

// Graphics subroutine

Void display (void ){

Glclearcolor ( 1.0f, 1.0f, 1.0f, 1.0f); // set the window to white when clearing the window

Glclear (gl_color_buffer_bit); // execute window cleanup

Glflush (); // refresh the command queue and buffer in OpenGL to execute all unexecuted commands.

}

 

Void main (INT argc, char ** argv ){

Gluinit (& argc, argv); // initialize the glut Library

Fig; // Display Mode

Glucreatewindow ("Hello OpenGL! "); // Create a window. The parameter is the title of the window.

Gludisplayfunc (Display); // draw the current window

Glumainloop (); // It is usually used at the end of a program to start running the program. All created windows are displayed.

}

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.