OpenGL Development Environment configuration in vc6.0 (required for OpenGL)

Source: Internet
Author: User
OpenGL Development Environment configuration in vc6.0 (required for OpenGL)

Step 1: select a compiling environment

Now {
Tagshow (event, 'windows ');
} "Href =" javascript:; "target =" _ Self ">WindowsThe mainstream compiling environments of the system include Visual Studio, broland C ++ builder, Dev-C ++, and so on. They all support OpenGL. But here we choose VC ++ 6.0 as the learning OpenGL environment.

Step 2: Install the glut Toolkit

Glut is not required by OpenGL, but it will give us {
Tagshow (event, '% D1 % A7 % CF % b0 ');
} "Href =" javascript:; "target =" _ Self ">LearningBrings some convenience, recommended {
Tagshow (event, '% B0 % B2 % D7 % b0 ');
} "Href =" javascript:; "target =" _ Self ">Install.

Glut in Windows: (the size is about 150 K) itpub personal space S./e f bfiv
Http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip

If you cannot download from the above address, use the following connection:
4Y ;? ^/Zua0http: // upload.programfan.com/upfile/200607311626279.zip

To install glut in Windows:
6a/bqo & hzr0r [01. Unpack the downloaded package and obtain five itpub personal spaces} k2g @ ODI
2. Take my installation directory as an example:
Ld "C t1om [0 (1)" D:/program files/Microsoft Visual Studio/vc98/include/GL folder ". Put the extracted glut. h In this gl folder. You can create one by yourself without the GL folder.
R VG] f R4 ~ $ J6n0 (2) "D:/program files/Microsoft Visual Studio/vc98/lib folder "). Put the extracted glut. lib and glu32.lib in the folder where the static function library is located, that is, the Lib folder. Itpub personal space E [T # M % K. Z-HD! Qi
(3) Place the extracted glut. dll and glu32.dll In the System32 folder under the operating system directory. (Typical location: C:/Windows/system32) This is an important dynamic link library setting!

Step 3: Create a project as follows:

(1) create a Win32 console application. (Taking my project name simplegl as an example) itpub personal space 9n00009y0j3? I0a (W4 ^
(2) link OpenGL libraries: click Project in Visual C ++, click Settings, find link, and add opengl32.lib glu32.lib Glaux at the beginning of Object/library modules. lib glu32.lib.
2sk "w5lntcy _ 0 (3) Click the C/C ++ label in Project Settings and change _ console in Preprocessor definitions to _ windows. Click OK.

Now, the preparation work is almost complete. Do not underestimate this step. If you do not set it, errors will always occur during compilation and running.

Step 4: Create the simplest OpenGL program

1. Add the following content to the stdafx. h file:
We} un4x # V V0 # include <windows. h> itpub personal space 9y' ICS (m1a j0d
# Include <Gl/Glu. h> itpub personal space I & w4oe f3gnh
# Include <Gl/Gl. h> itpub personal space 0h9ho-/1e 'zl
# Include <Gl/glut. h> itpub personal space 4p9j7i) ^ C. L # y5'
# Include <Gl/Glaux. h>
{V} 9Q # U [w7s/02. Add it to the Project main program: (take my program as an example in simplegl. cpp) itpub personal space qnom! Jzkjh/L
# Include <windows. h> itpub personal space qp7j ^. v7l # d8q * B/y
# Include <Gl/glut. h>

// Called to draw sceneitpub personal space TKB, P, c
Void rendersence (void)
0a, u] x/c5g) H-| xp0 {itpub personal space * t] TRH
// Clear the window with current clearing coloritpub personal space 8A $ ^ W) J, 'g9k "/
Glclear (gl_color_buffer_bit); itpub personal space/h8z '7l % h c cq s '? : P
// Flush drawing commandsitpub personal space o "D2 '# y {
Glflush ();
[7xqg $ pt; rlvq9by0}

// Set up the rendering stateitpub personal space L r8c, a "K
Void setuprc (void) itpub personal space B/ej6kf6o * bbr I]
{
E q &}:~ } E1n3c ~ * C0glclearcolor (0.0f, 0.0f, 1.0f, 1.0f); // the background color is blue.
2_nj (m2t7 }! Muc0}

Add the following to main:
* DV ;~ _: R0gluinitdisplaymode (glu_single | glu_rgb); itpub personal space % V2 @ w/v: k5us
Valley createwindow ("simple"); // The Window name is "simple"
$ O-e; p8e6s (RB:] kF-Y8Ax0glutDisplayFunc (rendersence );
Jzxt & sne0setuprc ();
1B & h g Fc (XOF/I 'xq0glumainloop ();

Note: The main function originally calls the itpub personal space b8i} $'s % c {-y/"^
Ruturn 0; itpub personal space M. z1x Q & aqb
This statement cannot be deleted; otherwise, an error occurs.

3. debugging results,

 

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.