Unformatted text preview:

CMSC 427:Spring 2006 Dave MountInstalling/Using OpenGLIntroduction: This document describes a bit about compiling and running OpenGL programs for C/C++on the various platforms around campus. In particular we will consider the following platforms.CSIC Linux Lab: The Dell machines running Redhat Linux in the CSIC Linux Lab on the third floorof the CSIC building. (Note that the WAM-lab Linux machines do not have GLUT installed,and so cannot be used at this time. If you have your own Linux system, these instructions areapplicable, but you will need to install the OpenGL, GLU, and GLUT libraries.)PC Windows: Your own PC running Microsoft Windows.To understand this more concretely, while you are reading this you should also download the sampleprogram, which we have made available. From the class web page go to the “OpenGL” link in theindex and then follow the link to the “Sample OpenGL Program,” or go directly to the following link.More detailed information can be found in the various “Readme” files contained within the bundle.OpenGL is the most widely used graphics library standard, that is, it is just a specification for agraphics library, which has been implemented by a number of vendors. OpenGL consists of twoprincipal components: GL (basic OpenGL) and GLU (OpenGL utilities). GL is responsible for thebasic low-level rendering tasks, and GLU provides support for some higher-level operations, suchas drawing curved surfaces. In addition, it is necessary to use a toolkit for creating windows andhandling user interaction. For C/C++ programming, we will use GLUT (OpenGL utility toolkit).(Java programmers will need to use a different toolkit, for example, the Java AWT (Abstract WindowToolkit), but we will not discuss that here.Installing OpenGL/Glut on your own PC: The following description assumes that you running on a PCrunning Microsoft Windows (98, 2000, NT or XP) and have Microsoft Visual Studio 6 or VisualStudio.NET. This does not apply to Linux or Mac’s, however. You first need to know the names of thefollowing two directories on your system:hWinDiri : This is your Windows system directory (e.g., C:\WINDOWS or C:\WINNT).hVCppi : Your visual C++ directory. For Visual Studio 6 this is something like:C:\Program Files\MicroSoft Visual Studio\VC98For Visual Studio.NET this might be:C:\Program Files\Microsoft Visual Studio.NET 2003\Vc7\PlatformSDKIf you are not sure, search for the file opengl32.lib.OpenGL should already be installed on your machine. To verify that OpenGL is installed on yoursystem, first do a search for the files opengl32.dll and glu32.dll. They should appear in your windowssystem directory (with lots of other dll files). You need to install Glut, however. The easiest way todo this is to visit the following web page.http://www.xmission.com/˜nate/glut.html1It contains precompiled GLUT libraries. (Download the “GLUT for Win32 dll, lib and header file”not the “source code distribution”.) After unbundling the file, copy the following files to the followingdirectories:glut32.dll =⇒ hWinDiri\SYSTEM32 (or wherever opengl32.dll is)glut32.lib =⇒ hVCppi\libglut.h =⇒ hVCppi\include\GL.By the way, the exact directory in which these files are installed is less important than the fact thatthe system can locate them. As long as these files are stored in directories that lie on the appropriateenvironment variables, e.g., PATH or INCLUDE, your system should be able to locate them.Now, you should be ready to go. If you have Visual Studio 6, then the quickest way to proceed is togo to the directory VisualCPP and double click the workspace file sample1.dsw. If you have VisualStudio.NET, go to the directory VisualStudioNET and double click the solution file sample1.sln.Please read the “Readme” files carefully for more detailed instructions on how to construct your ownprograms.CSIC Linux Lab: Compiling the programs involves a bewildering number of options, in order to specifythe location of the OpenGL and GLUT include files, libraries, and the runtime library directories. Theeasiest way to get started is the use the “Makefile” given in the Sample OpenGL program, mentionedabove. Edit the file to see which options can be adjusted. Enter “make” to compile the sampleprogram, after which you should be able to run the resulting executable.Unfortunately, there is no widespread agreement on how the various directories should be configuredon Unix/Linux platforms, and each system administrator makes his/her own choices when installingthings. Commands like “locate” can often be used to help you locate where these files are on any par-ticular Unix/Linux system. In case you are interested, in the CSIC Linux Labs the library files libGLand libGLU are located in /usr/X11R6/lib and libglut is located in /user/local/freeglut. The includefiles gl.h and glu.h are located in /usr/include/GL and glut.h is located /usr/local/freeglut/include/GL.Remote Execution: If you have an X-server on your PC at home (e.g., XFree86 or Reflection) you canremotely log into the WAM or Glue labs, compile your program, and run it. The graphics shouldappear on your PC display. Hint: before trying this with an untested OpenGL program, try a knownX11 application (for example, enter “xv” or “gimp”). If that works, then try running your program.If everything is configured properly, the graphics should appear on your screen. Beware, it may bequite slow because the graphics is being shipped over the network, but it is an option for your initialdevelopment and debugging.2CMSC 427:Spring 2006 Dave MountLighting in OpenGLThis handout briefly describes a number of OpenGL’s commands for controlling lighting and shading.See the reference documentation and tutorials on the web for more information.Options: Many of the capabilities of OpenGL can either be turned on or turned off. This is handledthrough various options, which can be either enabled or disabled. Here are a number of the options relatedto lighting.glEnable(GLenum cap), glDisable(GLenum cap):Enable/disable some option. The following options are useful for 3-dimensional hidden surface re-moval and lighting. By default, all are initially disabled.GL DEPTH TEST: Enables hidden surface removal (depth-buffering). In addition to setting this op-tion, you also need to enable the depth buffer in your initialization code, by adding GLUT DEPTHto glutInitDisplayMode, for example:glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH)By


View Full Document

UMD CMSC 427 - Installing/Using OpenGL

Download Installing/Using OpenGL
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Installing/Using OpenGL and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Installing/Using OpenGL 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?