BasecodeCSE167S15

From Immersive Visualization Lab Wiki
Revision as of 21:02, 29 March 2015 by Jschulze (Talk | contribs)

Jump to: navigation, search

Contents

Starter Code for Programming Projects

The purpose of this web page is to introduce OpenGL programming and set up your computer so that you can begin developing OpenGL applications.

In order to display an image, you must create a drawing canvas, which is essentially 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 cumbersome and varies from system to system. The purpose of GLUT is to simplify and unify this initial step.

The PCs in the computer lab already have GLUT and Visual Studio installed.

For your personal computer we will show you how to download and install GLUT and configure Visual Studio to use it.

Starter Code on Lab Computer

  • Download the starter code from Github onto your computer.
  • Double click file "Cube.sln" to open it in Visual Studio.
  • Click the icon with the green arrow named "Local Windows Debugger". Confirm with "Yes" in the pop-up window.
  • With luck you will see a spinning cube.
  • If you see an error, your compiler probably can't find GLUT and you have to tell it where it is:
  • Locate the "Solution Explorer" window on the left hand side of your Visual Studio window.
  • Right-click "Cube" (not "Solution 'Cube'").
  • Select "Properties". This should bring up the "Cube Property Pages" window.
  • Left-click "C/C++".
  • At "Additional Include Directories" add the directory GLUT is installed in (you will need to find out where this is on your disk by searching for "glut")
  • Left-click "Linker".
  • At "Additional Library Directories" add the same directory as above.
  • Click "OK".

Starter Code on Personal Computer or lab computer without pre-installed GLUT

Install GLUT

  • Make a folder called c:\glut and download glut-3.7.6-bin.zip (not glut-3.7.6-src.zip) to that folder from http://www.xmission.com/~nate/glut.html.
  • Open c:\glut and right click on glut-3.7.6-bin.zip and select Extract Here.
  • Open the new folder (glut-3.7.6-bin) and verify that you see the following five files: glut.def, glut.h, glut32.dll, glut32.lib, README-win32.txt
  • Move glut32.dll to c:\Windows\System32 so that all programs can access it. If you don't have write privileges for this directory, you can put the .dll file into the directory your executable (.exe) resides in. This is typically your Debug or Release directory, just below your project directory.
  • Create a new directory under c:\glut\glut-3.7.6-bin and name it "GL". Move glut.h to this new directory (should be "c:\glut\glut-3.7.6-bin\GL").

Install the Project

  • Download cube.zip onto your machine and unpack it (right-click the file in Windows Explorer and select "Extract Here").
  • Double click file "Cube.sln" to open Visual Studio.

Configure Microsoft Visual Studio

  • Locate the "Solution Explorer" window on the left hand side of your Visual Studio window.
  • Right-click "Cube" (not "Solution 'Cube'").
  • Select "Properties". This should bring up the "Cube Property Pages" window.
  • Left-click "C/C++".
  • At "Additional Include Directories" add "C:\glut\glut-3.7.6-bin".
  • Left-click "Linker".
  • At "Additional Library Directories" add "C:\glut\glut-3.7.6-bin".
  • Click "OK".

Alternative Way of Installing GLUT

Krishna is sharing this tip:

If you are installing GLUT on a computer you have administrator privileges, you can put the GLUT files with the other system libraries. Then you don't have to point the compiler to them. This works similarly in all Windows versions, including Windows 8.

  • Copy glut32.dll to C:\System
  • Copy glut32.lib to C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib
  • Copy glut.h to C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\GL (create a folder called GL first in ...\include before copying glut.h)

Setup Instructions for Mac OSX

Aaron Schwartz compiled instructions on how to set up OpenGL on a Mac. Tyler Levine updated it for a newer OSX.

Janelle Shane shares her notes on the setup in XCode.