Courses: Getting Started

From Gravity
Jump to: navigation, search

Development Environment

Visual Studio Express
If you've chosen to install Visual C++ Express, please go to

http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/

and follow the directions there to download and set up the Windows Platform SDK as well. If the Platform SDK is not installed, the preprocessor will likely complain about not being able to find GL/gl.h when you try to build the code from the first lab.

In summary, you need to set up:

  1. VC++ Express
  2. Platform SDK
  3. GLUT (remember to add glut32.lib to the list of 'Additional Dependencies' on the Project:Properties:Linker:Input panel)
  4. Your own code (C++ Win32 Console Application)


GLUT

In order to display an image, you must create some sort of drawing canvas. In modern operating systems, the basic drawing canvas is a window. With OpenGL, you create a window and then create an OpenGL drawing context associated with that window, which allows you to use your video hardware to draw 3D objects directly into that window. Opening that window and creating the OpenGL context is cumbersom and varies from system to system. GLUT was developed in order to simplify and unify this initial step.

During the first discussion session we will show you how to download and install GLUT and configure Visual Studio to use it. After that we will compile and run a sample program to test that everything is working. You can follow these same instructions if you would like to install GLUT on your home computer to work on the homework projects.

  1. Installing GLUT - OpenGL Utility Toolkit
  2. Configuring Microsoft Visual Studio

Installing GLUT
GLUT is available from http://www.xmission.com/~nate/glut.html. Make a folder called c:\glut and download the glut-3.6.7-bin.zip (not glut-3.6.7-src.zip) to that folder. Open c:\glut and right click on glut-3.6.7-bin.zip and select Extract Here. Open the new folder (glut-3.6.7-bin) and veryify that you see the following 5 files:

 * glut.def
 * glut.h
 * glut32.dll
 * glut32.lib
 * README-win32.txt
 glut32.dll is the compiled code which handles all of the GLUT functions.
 glut.h is the header file which lists all of the GLUT functions. This must 
 be included in any source code that uses GLUT (possibly several files in a 
 multi-file program).
 glut32.lib is a library file which must be linked with your program so that 
 it knows how to use glut32.dll.

Go back to c:\glut and make these 2 folders: c:\glut\include\GL and c:\glut\lib. Copy glut.h into c:\glut\include\GL and copy glut32.lib into c:\glut\lib. Normally we would put glut32.dll in c:\windows\system32 (or c:\winnt\system32) so that all programs would have access to it. However, we do not have access to do this in the lab, so I will show you a work around after we build our first program.


Configuring Microsoft Visual Studio

In order to use glut.h and glut32.lib we must tell Visual Studio where these files reside.

  • From the Tools menu, select Options.
  • In Visual Studio 6, select the "Directories" tab or in Visual Studio .NET select "Projects" and then "VC++ Directories" from the left side.
  • Select "Include Files" from the pull down menu on the right side. Add "c:\glut\include".
  • Select "Library Files" from the pull down menu on the right side. Add "c:\glut\lib".
  • Press the OK button. Visual Studio is now configured.


GLUI

Download the GLUI source code from http://glui.sourceforge.net/ You want Source: glui_v2_2.zip Once you have downloaded the zip file, extract it to a folder. Inside the folder you will see the source code and a folder called msvc (that stands for Microsoft Visual C). Open that folder and double click on glui.dsw (if you do not see the file extension, it has an icon of an infinity sign). This will open in either Visual Studio 6.0, or Visual Studio .NET (visual studio 7).

If this window pops up

ConvertDotNet.jpg

Then you are using Visual Studio .NET. Select "Yes to All". We need to make one small change to the code. Go back to the msvc folder, then go one folder up, to the source code. Drag the file "glui.h" into Visual Studio. You will see toward the top, the following 4 include files:

#include <GL/glut.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <string.h>

Move the first include to the end, so it looks like this:

#include <stdlib.h> 
#include <stdio.h> 
#include <string.h> 
#include <GL/glut.h>

Save glui.h (ctrl+s or File->save), and then close it. Now right click on _glui_library in the side column, and select Build.

This will build the GLUI library and put a folder called "lib" in with the source code. In the "lib" folder is a file called glui.lib. Copy this lib file and the glui.h file into a folder called c:\dev\glui (or anywhere you want. The rest of the instructions assume it is in c:\dev\glui).

GLUI is now built and "installed". We need to configure Visual Studio so it knows where to look for the header and library files (which will be used by every program you write that uses GLUI).

  • From the Tools menu, select Options.
  • In Visual Studio 6, select the "Directories" tab or in Visual Studio .NET select "Projects" and then "VC++ Directories" from the left side.
  • Select "Include Files" from the pull down menu on the right side. Add "c:\dev\glui".
  • Select "Library Files" from the pull down menu on the right side. Add "c:\dev\glui".
  • Press the OK button. Visual Studio is now configured.



Prepared by Vid Petrovic and Jason Kimball

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox