Vous êtes sur la page 1sur 3

Setup OpenGL GLUT in Visual C++ 6.

0 of Windows

OpenGL GLUT provides the graphics interface and other useful utilities for running
OpenGL in Windows. Here are the steps to set up OpenGL GLUT in Visual C++ of
Windows.

1. Go to http://web.ntpu.edu.tw/~jyhuang/Course/95(1)-ComputerGrahics.htm
and download "glut-3.7.6-bin.zip".
2. Unzip "glut-3.7.6-bin.zip". This generates four files: "glut.h", "glut32.lib",
"glut32.dll", and "readMe.txt". Note that you must choose the file view option
to view all files (including system files). Otherwise "glut32.dll" will not show
up.
3. Do following copies:
o copy "glut.h" to C:\..\..\VC98\include\GL (Visual C++ include
directory)
o copy "glut32.lib" to C:\..\..\VC98\lib (Visual C++ library directory)
o copy "glut32.dll" to C:\WINDOWS\SYSTEM or
C:\WINNT\SYSTEM32 (for NT), where your system files are located.

Then you are ready to run OpenGL codes in Visual C++ Studio.

Creating Workspace/Project in Visual C++ 6.0

In this email I attached the .cpp file I handed out to you in today's class. This is the
only file we need to run the program of spin square demonstrated in the class. Here
are the steps how to make a project and run it:
1. Open the Visual C++ Studio with empty workspace.
2. Choose menu File/New...
3. In the dialog box, click on the Projects tab.
4. Choose Win32 Console Application (not Win32 Application).
5. Choose a path for Location and make Project Name "Test", click OK.
6. Choose option: a simple application, and click Finish.
7. Now you have created a new project workspace named "Test". In the Fileview,
open the Source Files directory, and double click on "test.cpp", then its content will
be shown in the main window.
8. Replace the main() whole function with the content of "spinSquare.cpp", which is
attached in the email.
9. Compile "StdAfx.cpp" and then "test.cpp", and build all.
10. Run the program. You will see a square window with a magenta square in it. If
you locate the mouse pointer in the window and press the left button, the magenta
square will rotate. There is another window showing up, which display the program
string output and execution status. You can use this window for debugging.

Creating Workspace/Project in Visual C++ 7.0 (VS.NET 2003)

1. Open the Visual Studio .NET.


2. Choose menu File/New/Project
3. In the dialog box, click on the "Visual C++ Projects"
4. Choose Win32 Console Project (not Win32 Project).
5. Choose a path for Location and make Name and New Solution Name "Test", click
OK.
6. Click Finish.
7. Now you have created a new project named "Test". In the Solution Explorer, open
the Source Files directory, and double click on "Test.cpp", then its content will be
shown in the main window.
8. Replace the _tmain() whole function with the content of "spinSquare.cpp", which is
attached in the email.
9. Compile "StdAfx.cpp" and then "test.cpp", and build all.
10. Run the program. You will see a square window with a magenta square in it. If
you locate the mouse pointer in the window and press the left button, the magenta
square will rotate.

Setup OpenGL GLUT in Visual C++ 7.0 of Windows

OpenGL GLUT provides the graphics interface and other useful utilities for running
OpenGL in Windows. Here are the steps to set up OpenGL GLUT in Visual C++ of
Windows.

1. Go to http://www.xmission.com/~nate/glut.html and download "glut-3.7.6-


bin.zip" (the current version might be newer).
2. Unzip "glut-3.7.6-bin.zip". This generates four files: "glut.h", "glut32.lib",
"glut32.dll", and "readMe.txt". Note that you must choose the file view option
to view all files (including system files). Otherwise "glut32.dll" will not show
up.
3. Do following copies:
o copy "glut.h" to C:\..\..\Microsoft Visual Studio .NET
2003\Vc7\include (Visual C++ include directory), for better
compatiability, you may want to put it into C:\..\..\Microsoft Visual
Studio .NET 2003\Vc7\include\GL.
o copy "glut32.lib" to C:\..\..\Microsoft Visual Studio .NET 2003\Vc7\lib
(Visual C++ library directory)
o copy "glut32.dll" to C:\WINDOWS\SYSTEM or
C:\WINNT\SYSTEM32 (for NT), where your system files are located.

Then you are ready to run OpenGL codes in Visual Studio.NET.

A Simple OpenGL Program

Here is a simple OpenGL program to start with (after you setup GLUT, see above).
Please click here to download the file for VC++6.0.
Please click here to download the file for VS.NET 2003
Capture Images in Windows

You need this technique to include your rendered images in your report. Here are the
steps to capture your rendered image in Windows:
1. Click on the image window (the top bar should be blue).
2. While holding down the Alt key, press Print Screen (this key is located in the same
row with functions keys, on the right).
3. Launch Microsoft Photo Editor (or other imaging software such as Photoshop),
open a new file.
4. Under the Edit menu, choose Paste. Then you'll get the image.

Vous aimerez peut-être aussi