first commit

This commit is contained in:
Jose Caban
2025-06-07 01:59:34 -04:00
commit 388ac241f0
3558 changed files with 9116289 additions and 0 deletions

View File

@@ -0,0 +1,212 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0053)http://www.students.uwosh.edu/~bradfj23/visualstudio/ -->
<?xml version="1.0" encoding="UTF-8"?><HTML xml:lang="en"
xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Using OpenGL and GLUT in Visual Studio .NET 2003</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<STYLE type=text/css>BODY {
FONT-FAMILY: Arial, Helvetica, sans-serif
}
IMG {
BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN: 5px; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none
}
LI {
MARGIN-BOTTOM: 15px
}
SPAN {
FONT-WEIGHT: normal; FONT-SIZE: smaller
}
TABLE {
BORDER-COLLAPSE: collapse
}
TD {
BORDER-RIGHT: black thin solid; BORDER-TOP: black thin solid; BORDER-LEFT: black thin solid; BORDER-BOTTOM: black thin solid
}
TH {
BORDER-RIGHT: black thin solid; BORDER-TOP: black thin solid; BORDER-LEFT: black thin solid; BORDER-BOTTOM: black thin solid
}
TD {
PADDING-RIGHT: 7px; PADDING-LEFT: 7px; PADDING-BOTTOM: 7px; PADDING-TOP: 7px
}
TT {
BACKGROUND-COLOR: #eeeeee
}
.OS {
WIDTH: 25%; BORDER-RIGHT-STYLE: none
}
.directory {
BORDER-LEFT-STYLE: none
}
.menu LI {
MARGIN-BOTTOM: 0px
}
</STYLE>
<META content="MSHTML 6.00.2900.2523" name=GENERATOR></HEAD>
<BODY>
<H1>Using OpenGL &amp; GLUT in Visual Studio .NET 2003</H1>
<H2>A Guide to Easier Graphics Programming <20> By <A
href="http://www.students.uwosh.edu/~bradfj23/">Jordan Bradford</A></H2>
<P>Visual Studio .NET is <A
href="http://www.students.uwosh.edu/~bradfj23/visualstudio/why.html">a fantastic
IDE</A>, and with it you can write programs that will run in both Windows and
Linux with no fuss. This guide will show you how to set up a Visual Studio
project that will do just that, provided it is a pure OpenGL application using
GLUT. This guide also assumes Visual Studio .NET 2003 (and/or 2002) is already
installed and you are familiar with its use.</P>
<H3><A id=contents>Contents</A></H3>
<P>Click here for the <A
href="http://www.students.uwosh.edu/~bradfj23/visualstudio/quick.html">Quick
Version</A> of this guide (if you simply need to refresh your memory).</P>
<OL class=menu>
<LI><A
href="http://www.students.uwosh.edu/~bradfj23/visualstudio/#step1">Installation</A>
(only needs to be done once)
<LI><A
href="http://www.students.uwosh.edu/~bradfj23/visualstudio/#step2">Create a
Visual Studio Project</A>
<LI><A href="http://www.students.uwosh.edu/~bradfj23/visualstudio/#step3">Add
Source Code</A>
<LI><A
href="http://www.students.uwosh.edu/~bradfj23/visualstudio/#step4">Modify
Project Properties</A>
<LI><A
href="http://www.students.uwosh.edu/~bradfj23/visualstudio/#step5">Enjoy
Visual Studio</A> </LI></OL>
<H3><A id=step1>Step 1: Installation (only needs to be done once)</A>
&nbsp;&nbsp;<SPAN>back to <A
href="http://www.students.uwosh.edu/~bradfj23/visualstudio/#contents">top
&#8593;</A></SPAN></H3>
<P>Windows comes with OpenGL, and Visual Studio comes with the OpenGL libraries,
but neither of them comes with GLUT. Get the newest version of GLUT here: <A
href="http://www.xmission.com/~nate/glut.html">GLUT 3.7.6 for Windows</A>. Put
the following files in the following locations:</P>
<TABLE>
<THEAD>
<TR>
<TH>File</TH>
<TH colSpan=2>Location</TH></TR></THEAD>
<TBODY>
<TR>
<TD rowSpan=2><TT>glut32.dll</TT></TD>
<TD class=OS><I>Windows XP | Server 2003</I>:</TD>
<TD class=directory><TT>C:\WINDOWS\system\</TT></TD></TR>
<TR>
<TD class=OS><I>Windows 2000</I>:</TD>
<TD class=directory><TT>C:\WINNT\system\</TT></TD></TR>
<TR>
<TD><TT>glut32.lib</TT></TD>
<TD colSpan=2><TT>C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Lib</TT></TD></TR>
<TR>
<TD><TT>glut32.h</TT></TD>
<TD colSpan=2><TT>C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\gl</TT></TD></TR></TBODY></TABLE>
<P><STRONG>Note:</STRONG><BR>If you plan on giving your program to friends to
run using Windows, you must also include the <TT>glut32.dll</TT> file. If they
don't have this file in the same directory as your application or in their
<TT>C:\WINDOWS\system</TT> folder, the program will not run.</P>
<H3><A id=step2>Step 2: Create a Visual Studio Project</A>
&nbsp;&nbsp;<SPAN>back to <A
href="http://www.students.uwosh.edu/~bradfj23/visualstudio/#contents">top
&#8593;</A></SPAN></H3>
<P>Because GLUT was designed to be window system independent <20> it makes its own
windows <20> it is better to let GLUT run as a console application than as a native
Windows application (which would require <TT>#include &lt;windows.h&gt;</TT>).
To create an empty console project in Visual Studio, do the following:</P>
<OL>
<LI>Create a new project ( <TT>File &#8594; New &#8594; Project...</TT> ). The <TT>New
Project</TT> dialog will appear.<BR><IMG
style="BORDER-RIGHT: black thin solid; BORDER-TOP: black thin solid; BORDER-LEFT: black thin solid; BORDER-BOTTOM: black thin solid"
height=443 alt="Create a new project"
src="Using OpenGL and GLUT in Visual Studio _NET 2003_files/step2.jpg"
width=415>
<LI>In the <TT>Project Types:</TT> pane, select <TT>Visual C++ Projects</TT>.
Then select <TT>Win32 Console Project</TT> in the <TT>Templates:</TT> pane.
Name your project and click <TT>OK</TT>. The <TT>Win32 Application Wizard</TT>
dialog will appear.<BR><IMG height=393 alt="Create a Win32 Console Project"
src="Using OpenGL and GLUT in Visual Studio _NET 2003_files/step2a.jpg"
width=531>
<LI>Click the <TT>Application Settings</TT> tab on the left, and check the
<TT>Empty Project</TT> box. Then click <TT>Finish</TT>.<BR><IMG height=437
alt="Create an empty Win32 Console Project"
src="Using OpenGL and GLUT in Visual Studio _NET 2003_files/step2b.jpg"
width=615><BR>Your empty console project will be created. </LI></OL>
<H3><A id=step3>Step 3: Add Source Code</A> &nbsp;&nbsp;<SPAN>back to <A
href="http://www.students.uwosh.edu/~bradfj23/visualstudio/#contents">top
&#8593;</A></SPAN></H3>
<P>Adding source files to the project should be familiar to you, so a detailed
explanation is not necessary. There are two facts you should know, however.</P>
<OL>
<LI>When you include GLUT in a program, it automatically includes the rest of
the OpenGL header files. So explicitly having<BR><BR><TT>#include
&lt;GL/gl.h&gt;</TT><BR><TT>#include &lt;GL/glu.h&gt;</TT><BR><BR>in either
Linux or Windows isn't necessary, provided you include GLUT.
<LI>Visual Studio can also recognize the forward slash as a directory
designation in <TT>#include</TT> directives <20> Windows normally uses a
backslash <20> so you shouldn't rewrite your code with one:<BR><BR><TT>#include
&lt;GL<STRONG>\</STRONG>glut.h&gt;</TT><BR><BR>If you use a backslash in
Linux, gcc will complain. </LI></OL>
<H3><A id=step4>Step 4: Modify Project Properties</A> &nbsp;&nbsp;<SPAN>back to
<A href="http://www.students.uwosh.edu/~bradfj23/visualstudio/#contents">top
&#8593;</A></SPAN></H3>
<P>Before compiling your project, you need to set up Visual Studio's linker so
it knows where to find GLUT. To do this, you must open the <TT>Property
Pages</TT> dialog for your project. There are two ways to do this:</P>
<OL>
<LI>Use Visual Studio's menu option ( <TT>Project &#8594; Properties</TT> ).<BR><IMG
style="BORDER-RIGHT: black thin solid; BORDER-TOP: black thin solid; BORDER-LEFT: black thin solid; BORDER-BOTTOM: black thin solid"
height=363 alt="Use menu: Project -> Properties"
src="Using OpenGL and GLUT in Visual Studio _NET 2003_files/step4_1.jpg"
width=453>
<LI>Use the <TT>Solution Explorer</TT> located in the upper right corner.
Right-click your project's name as shown and select
<TT>Properties</TT>.<BR><IMG height=636 alt="Use Solution Explorer"
src="Using OpenGL and GLUT in Visual Studio _NET 2003_files/step4_2.jpg"
width=211> </LI></OL>
<P>Using either option, the <TT>Property Pages</TT> dialog will open. Once it
appears, do the following:</P>
<OL>
<LI>From the <TT>Configuration:</TT> list box, select <TT>All
Configurations</TT>.<BR><IMG height=440 alt="Select All Configurations"
src="Using OpenGL and GLUT in Visual Studio _NET 2003_files/step4a.jpg"
width=644>
<LI>In the left pane, select the <TT>Linker</TT> subtree and then the
<TT>Input</TT> option. Add the given code to the <TT>Additional
Dependencies</TT> text box in the right pane. This tells Visual Studio where
to find GLUT. (Copy &amp; Paste: <STRONG><TT>opengl32.lib glu32.lib
glut32.lib</TT></STRONG> )<BR><IMG height=440 alt="Add libraries"
src="Using OpenGL and GLUT in Visual Studio _NET 2003_files/step4b.jpg"
width=644>
<LI>This step is optional. If you want to prevent your program from opening a
console window in addition to your GLUT window when it is run, select the
<TT>Command Line</TT> option in the left pane. Then add the given code to the
<TT>Additional Options:</TT> text box.<BR><IMG height=440
alt="Disable console window"
src="Using OpenGL and GLUT in Visual Studio _NET 2003_files/step4c.jpg"
width=644><BR>Visual Studio thinks it's still building a normal console
application, which is why a console window will appear if you run your program
from inside Visual Studio or by double-clicking its icon. The
<STRONG><TT>/SUBSYSTEM:WINDOWS</TT></STRONG> command fools Visual Studio into
thinking this is a windowed application, which means a console window isn't
necessary. However, when Visual Studio makes windowed applications, it wants
to start program execution from <TT>WinMain()</TT> or <TT>wWinMain()</TT>,
which you haven't defined. Setting the
<STRONG><TT>/ENTRY:mainCRTStartup</TT></STRONG> flag tells Visual Studio to
start execution at the usual <TT>main()</TT> instead. </LI></OL>
<P><STRONG>Note:</STRONG><BR>If you choose to disable the console window,
remember that you won't be able to see any console output from your program
using <TT>printf()</TT>, <TT>cout</TT>, <TT>cerr</TT>, etc.</P>
<H3><A id=step5>Step 5: Enjoy Visual Studio</A> &nbsp;&nbsp;<SPAN>back to <A
href="http://www.students.uwosh.edu/~bradfj23/visualstudio/#contents">top
&#8593;</A></SPAN></H3>
<P>Now your program is ready for development in an excellent IDE while still
being portable. Be sure to test your program on a Linux machine before
submitting it for grading. Your computer at home is most likely superior to the
ones in the lab, so inefficient code might not be apparent.</P>
<HR>
<P>Last Update: April 10, 2004</P>
<P><A href="http://validator.w3.org/check/referer"><IMG height=31
alt="Valid XHTML 1.1!"
src="Using OpenGL and GLUT in Visual Studio _NET 2003_files/valid-xhtml11.png"
width=88></A></P></BODY></HTML>