Opengl and GLUT
Total Page:16
File Type:pdf, Size:1020Kb
Appendix A OpenGL and GLUT What is OpenGL? OpenGL seems to be as close to an industry standard as there is for creating 2D and 3D graphics applications. OpenGL provides a library of graphics functions for you to use within your programming environment. It provides all the necessary communication between your software and the graphics hardware on your system. The OpenGL API is a portable API that can be compiled and run on many platforms. OpenGL programs are typically written in C and C++. What is GLUT? GLUT (pronounced like the glut in gluttony) is the OpenGL Utility Toolkit, a window system independent toolkit for writing OpenGL programs. It implements a simple windowing application programming interface (API) for OpenGL. GLUT makes it considerably easier to learn about and explore OpenGL programming. GLUT is designed for constructing small to medium sized OpenGL programs. While GLUT is well-suited to learning OpenGL and developing simple OpenGL applications, GLUT is not a full-featured toolkit so large applications requiring sophisticated user interfaces are better off using native window system toolkits. GLUT is simple, easy, and small. The GLUT source code distribution is portable to nearly all OpenGL implementations and platforms. GLUT is not open source. Mark Kilgard maintains the the copyright. What libraries and header files will I need to compile and link OpenGUGLUT programs? To compile and link OpenGL programs, you'll need the OpenGL header files and libraries. Windows: If you are running Windows 98/NT/2000 then this library has already been installed in your system. Otherwise download the Windows OpenGL library from Microsoft at: ftp:/@p.microsoft. com/softlib/mslfiles/opengl95. exe Mac OS X: If you are running MacOS X then download the OpenGL SDK from Apple at: http://developel:apple.com/opengl/ LINUXIBSD: If you are running LINUX then download Mesa - the OpenGL work-alike at: http://www.mesa3d.org/ UNIX: The OpenGL libraries are available directly from your UNIX vendor The OpenGL Utility Toolkit (GLUT) is available for download at: http://www.opengl.org/resources/libraries/glut. html Note that you only need to download the glutdlls.zip archive, but you may also want to download the source code and the HTML version of the API. To run OpenGL programs that take advantage of OpenGL 1.2 or above: you will need to download vendor-specific OpenGL Drivers for your particular graphics card. Refer to: http://www.opengl. org/documentation/spec. html/ for more details. Where do I install these files? Microsoft Windows 95 and above: If you're using Visual C++ under Windows 9x, NT or 2K, your compiler comes with include files for OpenGL and GLU, as well as .lib files to link with. Install g1ut.h in your compiler's include directory, glut32.lib in your compiler's lib directory, and glut32.dll in your Windows system directory (c:\windows\system for Windows 9x, or c:\winnt\system32 for Windows NTl2000). In summary, a fully installed Windows OpenGL development environment will look like this: File Location [compiler]\include\g1 [compiler]\lib [system] where [compiler] is your compiler directory (such as c:\Program Files\Microsoft Visual Studio\VC98) and [system] is your Windows 9x/NT/2000 system directory (such as c:\winnt\system32 or c:\windows\system). You'll need to instruct your compiler to link with the OpenGL, GLU, and GLUT libraries. In Visual C++ 6.0, you can accomplish this with the Project menu's Settings dialog box. Scroll to the Link tab. In the Objectllibrary modules edit box, add glut32.lib, glu32.lib, and opengl32.lib to the end of any text that is present. For UNIX or UNIX-like operating systems: If you don't find the header files and libraries that you need to use in standard locations, you need to point the compiler and linker to their location with the appropriate -I and -L options. The libraries you link with must be specified at link time with the -1 option; -1glut -1GLU -1GL -1Xmu -1X11 -1m is typical. For Mac OS X: Apple provides excellent documentation on how to access header and library files and code using their OpenGL SDK at: http://developer,apple.com/opengl/ For Linux and other systems: You can find excellent documentation for this at: http://www.mesa3d.org/ More OpenGL Documentation If you would like some more information, then I would suggest you spend time browsing the OpenGL main web site at: http://www.opengl.org: You will find all related documentation and supporting libraries on this web-site. Appendix B Downloading and running Sample Code How do you download and install the sample code? Download the sample code (in zipped format) from: http://wwwspringeronline.com/O-387-95504-6 Most of our code is portable to UNIX or any platform with OpenGL installed. Go to the directory where you want to install the sample code. Unzip the downloaded zip file into this folder. You should now see the following folders and files installed: OpenGLL contains the examples referred to in the book, grouped by the example number that they are used within. For e.g., under the folder: OpenGL/Examplel-l/you will find the source code for Examplel-1 in the file Examplel-l.cpp. OpenGLL contains the code for the utility functions: Vector utilities: vectoz h BMP image reading and writing: bmp.cpp, bmp.h VRML models reading: vrml.h, vrml.cpp ' Interpolation routines: linearinterpolation.cpp, 1inearinerpolation.h cubicinterpolatiomcpp, cubicinterpo1ation.h OpenGL/ModelsL contains the VRML and Alias models used in our examples. OpenGL/ImagesL contains the images used as textures in our examples. How do you compile and link the programs? We detail this process for Microsoft Visual C++ compiler. Any other visual compiler will be similar. UNIXJLinux users will need to compile and link their programs from the command line or from a MakeFile as appropriate (See Appendix A). 1. Startup Microsoft Visual Studio 2. Create a Project To create an Open GL project, we are going to need to modify one of the standard projects defined by Microsoft's Visual Studios. Select File > New from the main menu. Next select the Projects tab and select the Win32 Console Application project. Don't forget to enter the project name and the path to the project folder. 3. Specify The Settings Select the Project>Settings from the Main Menu. Select the Link tab. This allows you to edit some of the linking options of the compiler. Select the General category from the drop down list. Select the All ConJprations option from the list. This will make our settings valid for both compiling the project in Debug mode as well as compiling the project in Build mode. Finally, add the glut32.libY glu32.lib and opengl32,lib to the Object/library modules box. Click the OK button to save the changes. gnamte debug info r Ignore all default libraries Link incrementally Generate mapme r Enable pmfiling Common Qplions: kemal32.libuser32.lib gdi3Z.libwinspool.lib comdIg32.lib A ' sdvap132,libshe1132 lib ole32.lib oleaut32.lib uuidlib odbc32Sib odbccp32.lib /nologo /subsystem:wnsole r : 4. Add the necessary files to the Project The next step is to add the required .cpp (or .c) files to our project so we can test the installation. Select Project > Add to Project>Files from the Main Menu. For this example, select our file Examplel-4/Examplel-4.cpp. Visual Studios will automatically add this to your project and save it in your project's folder. Follow this step to add more files if needed. 5. Compile and Execute Finally, press Ctrl-F5 to build and execute the program. Examplel should look something like this: Enjoy! Appendix c Maya Personal Learning Edition (PLE) What is Maya? Academy Award winning Maya software is the world's most powerfully integrated 3D modeling, animation, effects, and rendering solution. Maya also adds to the quality and realism of 2D graphics. That's why film and video artists, game developers, visualization professionals, Web and print designers turn to Maya to take their work to the next level. What is Maya PLE? Maya Personal Learning Edition is a special version of Maya software, which provides free access to Maya for non-commercial use. It gives 3D graphics and animation students, industry professionals, and those interested in breaking into the world of computer graphics (CG) an opportunity to explore all aspects of the award winning Maya software in a non-commercial capacity. Where do I download the soffware? You can download the software from the following URL http://www.alias.com/eng/products-sewices/mya/myaqle/ Follow the instructions on how to install the program onto your desktop. This page also provides more details on software and hardware requirements for running the program. Bibliography What follows is a bibliography in computer graphics. In addition to being a list of references from the various chapters, it also contains references to books and journals where the latest research in the field is being published. ADAM9 1 Adams, L. Supercharged C++ Graphics, Windcrest, 199 1 APOD99 Apodaca,A.A., L. Gritz., Advanced RenderMan: Creating CGI for Motion Pictures, Morgan Kaufmann, 1999 BADL91 Badler, N.I., B.A. Barksy, D. Zeltzer (ed.), Making Them Move: Mechanics, Control, andAnimation of Articulated Figures, Morgan Kaufman, 1991. BART87 Bertels, R., J. Beatty, B. Barsky, An Introduction to Splines for Use in Computer Graphics and Geometric Modeling, Morgan Kaufmann, 1987. BOVIOO Bovik, A,, Handbook of Image and Video Processing, Academic Press, 2000 COHEOl Cohen, E., R. F. Riesenfeld, G Elber, Geometric Modeling with Splines: An Introduction, AK Peters, Ltd., 2001. CUNN92 Cunnighamn, S., N.