First knowledge of OpenGL

Source: Internet
Author: User

(1) download glut and place it in the appropriate location

(2) Configure vs2005 Project Properties

First part, transferred from reference site: http://muggleyoung.blog.hexun.com/22800074_d.html

As one of the mainstream graphics APIs, OpenGL has superior features in some cases than DirectX.

1. closely integrated with C language.
OpenGL commands are initially described using C language functions. For those who have learned C language, OpenGL is easy to understand and learn. If you have been familiar with graphics. h of TC, you will find that it is even easier to plot Using OpenGL than TC.

2. Powerful portability.
Although micro-soft direct3d is also a very good graphic API, it is only used for Windows systems (now you need to add an Xbox game machine ). OpenGL is not only used for windows, but also for Unix/Linux and other systems. It is applicable to large computers and various specialized computers (such as medical display devices. In addition, the basic commands of OpenGL are hardware-independent or even platform-independent.

3. High-Performance graphic rendering.
OpenGL is an industrial standard, and its technology keeps up with the times. Currently, all graphics card manufacturers provide strong support for OpenGL, and the fierce competition leads OpenGL Performance.
In summary, OpenGL is a very Nb graphic software interface. As to whether there are many Nb games, check out professional games such as doom3 and quake4.
OpenGL official website (English)
Http://www.opengl.org

The following describes OpenGL programming in windows.

Preparations before learning OpenGL

Step 1: select a compiling environment
Currently, mainstream windows compiling environments include Visual Studio, broland C ++ builder, Dev-C ++, and so on. They all support OpenGL. However, Visual Studio 2005 is selected as the learning environment for OpenGL.

Step 2: Install the glut Toolkit
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" in "My Computer" and find the folder in which it is located (if it is visualstudio2005, it should be under its installation directory
"VC/platformsdk/include/GL folder "). 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)

Step 3: Create an OpenGL Project

The following uses visualstudio2005 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.
Add a code file named "OpenGL. c" to the project, and use. C as the end of the file.
The solution is no different from the normal project.

Second part: Reprinted from http://blog.tianya.cn/blogger/post_show.asp? Blogid = 78856 & postid = 14520900

Add opengl32.lib glu32.lib Glaux. lib to Project Properties> Configuration Properties> linker> input> additional dependencies.

Two major problems you have encountered:

-): Error lnk2019: unresolved external symbol _ imp _ glflush @ errors of this type

Or
1> pt. OBJ: Error lnk2019: external symbol that cannot be parsed _ auxsolidsphere @ 8, which is referenced in function _ main
1> pt. OBJ: Error lnk2019: external symbol that cannot be parsed _ auxinitwindowa @ 4, which is referenced in function _ main
1> pt. OBJ: Error lnk2019: external symbol that cannot be parsed _ auxinitposition @ 16, which is referenced in function _ main
1> pt. OBJ: Error lnk2019: external symbol that cannot be parsed _ auxinitdisplaymode @ 4, which is referenced in function _ main


The reason is that the preceding dependency is not added to the additional dependency.Lib File 

Solution: Add "opengl32.lib glu32.lib Glaux. lib" to project properties-> Configuration properties-> linker-> input-> additional dependencies


(2) Error c2664: "auxinitwindoww": you cannot convert parameter 1 from "const char [7]" to "lpcwstr"
It has nothing to do with the type to be pointed to; conversion requires reinterpret_cast, C style conversion or function style Conversion

Errors and solutions:

Not passing in a unicode string-put an "L" before the string literal: l "XXXXX" or use the text ("XXXXX") or _ T ("XXXXX ") macros...


Certificate ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Install OpenGL in vs2010 to download the missing files.
Download source 1: csdn download
Download the files required for the OpenGL installation package:
Http://d.download.csdn.net/down/2560229/ssagnn23
Including:
Gl. h Glaux. h Glu. h glut. h
Glaux. Lib glu32.lib glu32.lib glut. Lib opengl32.lib
Glaux. dll glu32.dll glu32.dll glut. dll opengl32.dll

Vs2008 does not contain files such as Gl. H, Glaux. H, Glu. H, Glaux. Lib, glu32.lib, and opengl32.lib. After the address is downloaded, the downloaded file is allocated to different folders in the system. The configuration method is as follows:

(1) Copy Glaux. dll, glu32.dll, and glut. DLL to the C:/Windows/system32 directory. opengl32.dll and glu32.dll should already exist in the System32 directory.
(2) Copy Gl. H, Glaux. H, Glu. H, and glut. h to C:/program files/Microsoft Visual Studio 9.0/VC/include/GL.
(3) Copy Glaux. Lib, glu32.lib, glu32.lib, opengl32.lib, and glut. lib to C:/program files/Microsoft Visual Studio 9.0/VC/lib.

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.